





























































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!






























































Introduced by E.F. Codd in 1970 Relational DBMS systems include Oracle, DB2, Sybase, Informix. Main Characteristics: Database is perceived as a set of tables Query results are also tables Main advantages: Simple With solid math base Relational model: Database structure: the database is represented by tables Integrity constraints: the tables satisfy certain constraints Data manipulation: operators are available for data manipulation
Informally, a relation is a table; a tuple corresponds to a row of such a table and an attribute to a column; the number of tuples is called the cardinality and the number of attributes is called the degree. Order of tuples is irrelevant (tuples may be stored in an arbitrary order); duplicate tuples are not allowed in a relation. Formally, given sets D 1 , D 2 , …. Dn a relation r is a subset of D 1 x D 2 x … x Dn Thus a relation is a set of n-tuples ( a 1 , a 2 , …, an ) where ai Di Example: Jones Smith Curry Lindsay customer-name Main North North Park customer-street Harrison Rye Rye Pittsfield customer-city attributes tuples
R = ( A 1 , A 2 , …, An ) is the relation schema E.g. Customer-schema = ( customer-name, customer-street, customer-city ) The current value of the relation is the relation
Let R be a relation schema, r(R) be any relation on R, and K R K is a superkey of R if values for K are sufficient to identify a unique tuple of each possible relation r(R). By “possible r ” we mean a relation r that could exist in the enterprise we are modeling. Example: { customer-name, customer-street } and { customer-name } are both superkeys of Customer , if no two customers can possibly have the same name. K is a candidate key if K is minimal superkey Example: { customer-name } is a candidate key for Customer , since it is a superkey (assuming no two customers can possibly have the same name), and no subset of it is a superkey.
A database consists of relations and integrity constraints Information about an enterprise is broken up into parts, with each relation storing one part of the information E.g.: account : stores information about accounts depositor : stores information about which customer owns which account customer : stores information about customers Relational schemas should be carefully designed E.g. Storing all information as a single relation such as bank ( account-number, balance, customer-name , ..) results in repetition of information (e.g. two customers own an account) the need for null values (e.g. represent a customer without an account) Normalization theory (discuss later ) deals with how to design relational schemas Basic operations of insert, delete, and update may violate constraints.
Basically, the relational algebra is a set of operators that take relations as their operands and return a relation as their result. Six basic operators Select project union set difference Cartesian product rename The operators take one or more relations as inputs and give a new relation as a result.
1 5 12 23 7 7 3 10
A B C D 1 23 7 10
Relation r : A^ B^ C 10 20 30 40 1 1 1 2 A C 1 1 1 2 = A C 1 1 2 A,C ( r )
Notation: A1, A2, …, Ak ( r ) where A 1 , A 2 are attribute names and r is a relation name. The result is defined as the relation of k columns obtained by erasing the columns that are not listed Duplicate rows removed from result, since relations are sets E.g. To eliminate the branch-name attribute of account account-number, balance ( account )
Notation: r s Defined as: r s = { t | t r or t s } For r s to be valid.
Relations r, s: r – s : A B 1 2 1 r A B 2 3 s A B 1 1
Relations r, s : r x s : A B 1 1 1 1 2 2 2 2 C D 10 10 20 10 10 10 20 10 E a a b b a a b b A B 1 2 r C D 10 10 20 10 E a a b b s
Notation r x s Defined as: r x s = { t q | t r and q s } Assume that attributes of r(R) and s(S) are disjoint. (That is,
If attributes of r(R) and s(S ) are not disjoint, then renaming must be used.