Sie sind auf Seite 1von 3

Lecture Notes For DBMS and Data Mining and Data Warehousing

Lecture 9
Relational Model
 A relational database consists of a collection of tables, each of which is assigned a unique
name.
 A row in table represents a relationship among a set of values.
 Table is a collection of rows or relationships which is similar to a mathematical relation
i.e. a set of tuples.
Basic Structure
 A mathematical binary relation is an association of values from one set to another set. Ex.
Less-than relation associates a set of integers with another set of integer. Consider

1, 1,
2, 2,
A= 3, B= 3,
… …

Relationship less-than from A to B = 1, 1,


2, 2,
3, 3,
… …

Or it can be represented as set of tuples <x,y> where x is an element from A and y is an


element from B such that x<y i.e.

Relationship less-than from A to B = {<1,2>,<1,3>,<1,4>…,<2,3>,<2,4>,…,<3,4>…}.


Similarly,
Relationship equal-to from A to B= {<1,1>,<2,2>,<3,3>…}.
And
Relationship greater than from A to B = {<2,1>,<3,1>,<3,2>,<4,1>,<4,2>,<4,3>…}

While the Cartesian product of A and B contains all such tuple <x,y> where x belongs to
A and y belongs to B i.e. A × B =

  1,1   1,2   1,3  ...


 2,1   2,2   2,3  ...
 
 
 3,1   3,2   3,3  ...

 ... ... ... ...

 So we can see any relation from A to B above will be a subset of A × B.
 Now Suppose in a relational model a table T has columns titled as A, B and C. If T is
representing an entity set then A, B, C will be its attributes. Every attribute corresponds to
a limited number of values that can be assigned to it.

Department of Electrical and Electronics By: Sulabh Bansal


Lecture Notes For DBMS and Data Mining and Data Warehousing

 The set of values that can be assigned to a particular column is called domain for that. So
A, B and C will have their specified domains. Suppose those domain sets are denoted as
DA, DB, and DC.
 Any row of the table will have a value from DA in first column, DB in second column, and
DC in third column. So a row of relational table is similar to a tuple of a mathematical
relation between the sets DA, DB, and DC.
 For Example: Consider an BOOK table having attributes acc-no, title, and author. To
make it simple we restrict the domain for acc-no. as A={100, 101, 102}, for title as
B={“DBMS”, “COMPILER”, “OS”} and for author as C={“Ramanuj”, “Aristotle” and
“Silbershatz”}. That means the first column of BOOK can have any value from only A,
second from only B and third from only C. the Cartesian product of these domain sets can
be represented in a tabular form as :
100 “DBMS” “Ramanuj”
100 “DBMS” “Aristotle”
A×B×C= 100 “DBMS” “Silbershatz”
100 “COMPILER” “Ramanuj”
100 “COMPILER” “Aristotle”
100 “COMPILER” “Silbershatz”
100 “OS” “Ramanuj”
100 “OS” “Aristotle”
200 “DBMS” “Ramanuj”
200 “DBMS” “Aristotle”
200 “DBMS” “Silbershatz”
200 “COMPILER” “Ramanuj”
200 “COMPILER” “Aristotle”
200 “COMPILER” “Silbershatz”
200 “OS” “Ramanuj”
200 “OS” “Aristotle”
200 “OS” “Silbershatz”
300 “DBMS” “Ramanuj”
300 “DBMS” “Aristotle”
300 “DBMS” “Silbershatz”
300 “COMPILER” “Ramanuj”
300 “COMPILER” “Aristotle”
300 “COMPILER” “Silbershatz”
300 “OS” “Ramanuj”
300 “OS” “Aristotle”
300 “OS” “Silbershatz”

 Now we can observe any valid table representing the entity set BOOK for a library given
above restriction on domains will have only a subset of the rows from the above table
which represents A × B × C. For Example a valid entity set for all books in the library
can be
BOOK 100 “DBMS” “Silbershatz”
200 “DBMS” “Ramanuj”
300 “COMPILER” “Silbershatz”

 So we can say any table of relational model is actually similar to the mathematical
relation.
 Every row of such relational table is similar to a tuple of a mathematical relation. Let the
tuple variable ‘t’ refers to the first tuple (first row) in above mentioned BOOK table then

Department of Electrical and Electronics By: Sulabh Bansal


Lecture Notes For DBMS and Data Mining and Data Warehousing

we can various elements of the tuple as t[acc-no]= 100, t[title]= “DBMS” and t[author] =
“Silbershatz”.

Query Languages
 A language in which a user requests information from the database is called a query
language.
o Procedural- user instructs the system to perform a sequence of operations on the
database to compute the desired result. E.g. Relational algebra
o Nonprocedural- user describes the information desired without giving a specific
procedure for obtaining the desired information. E.g. tuple calculus, domain
calculus.

Department of Electrical and Electronics By: Sulabh Bansal

Das könnte Ihnen auch gefallen