Sei sulla pagina 1di 10

Database

A collection of data is referred to as


database and a database (management)
system is basically a computer based
record keeping system.
Database

systems

redundancy,

data

help

reduce

data

inconsistency

and

facilitate sharing of data, standardization


of data and data security.
A database is implemented through three
general

levels:

internal

(closest

to

physical storage), conceptual (describes


entire data and its relationships) and
external (closest to the users).

Data independence allows modification of


a scheme definition without affecting
other scheme definitions.
There

are

two

levels

of

data

independence: logical and physical.


There are three models available for
database management: relational, network
and hierarchical.
A relational data model organizes the
data into tables known as relations.
A network data model represents data by
collection of records and relationships
among data are represented by links
(pointers).

A hierarchical data model represents data


by records organized in form of trees and
the

relationships

among

data

are

represented by links.
A view is a virtual table derived from one
or more underlying base tables.
There is no stored file created for
storing a views contents, rather, only he
view definition is stored.
The relational algebra is a collection of
operations

on

relations.

The

various

operations

of

relational

algebra

are

select, project, Cartesian product, union,


set difference, set intersection, join etc.

The selection extracts columns from a


relation. (Symbol ).
The Cartesian product yields a relation
with all possible combinations of the
tuples of two relations operated upon.
(Symbol X).
The union yields a relation containing
tuples

from

the

operand

relations.

(Symbol ).
The set difference finds tuples that are
in one relation but not in another. (Symbol
-).
That set intersection finds tuples that
are common to the two operand relations.
(Symbol ).

Structured Query Language


SQL is a language that enables us to
create

and

operate

on

relational

databases.
The various processing capabilities of
SQL are:
Data

definition

language

interactive

and

embedded

manipulation

language

(DML),

(DDL),
data
view

definition, authorization, integrity and


transaction control.
The DDL provides statements for the
creation and deletion tables and indexes.

The DML provides and statements to


enter, update, delete data and perform
complex queries on these tables.
The ANSI standards supports these data
types:
CHAR,

DECIMAL

INT(INTEGER),

(DEC),

NUMERIC,

SMALLINT,

FLOAT,

REAL, DOUBLE PRECISION(DOUBLE).


Most implementations also support DATE
and TIME types.
The CREATE TABLE command creates a
new table.
The SELECT command lets us make
queries on the database. Rows returned
are restricted using WHERE clause.

Results are sorted using ORDER BY clause


and the GROUP BY clause divides the
result obtained into groups and the
HAVING clause sets conditions for the
GROUP BY clause.
SQL aggregate functions (avg, min, max,
sum, count) calculate the summary values
from the data in a particular column.
SELECT INTO creates a new table by
extracting data from another table.
Multiple

queries

are

combined

using

UNION operator.
The

INTERSECT

operators

common rows from two tables.

returns

The MINUS operator returns rows unique


to the first table.
The rows are added to relations using
INSERT command.
The rows are removed from a relation
using DELETE command.
The UPDATE command lets us change
some or all of the values in an existing
rows.
The CREATE VIEW creates view from a
table.
Joins

are

the

means

to

extract

information from more than one table.


A join may be an equi join, a natural join,
non-equi join or self join.

The ALTER TABLE changes the definition


of an existing table.
The DROP TABLE drops a table from the
database.
The DROP VIEW drops a view from the
database.

Potrebbero piacerti anche