Docsity

Database management system (DBMS) relational model, Slides of Database Management Systems (DBMS)

Toggle sidebar
bg1
3.1
Introduction to Relational Model
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
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f
pf30
pf31
pf32
pf33
pf34
pf35
pf36
pf37
pf38
pf39
pf3a
pf3b
pf3c
pf3d
pf3e
pf3f
pf40
pf41
pf42
pf43
pf44
pf45

Partial preview of the text

Download Database management system (DBMS) relational model and more Slides Database Management Systems (DBMS) in PDF only on Docsity!

Introduction to Relational Model

 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

Relation

 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 aiDi  Example: Jones Smith Curry Lindsay customer-name Main North North Park customer-street Harrison Rye Rye Pittsfield customer-city attributes tuples

Relation Schema and Instance

 Let A 1 , A 2 , …, An be the attributes of a relation. Then

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

instance (specified by a table)

Keys (1)

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.

Database (1)

 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 inrepetition 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.

Database (2)

 The schema (conceptual model) of a database

consists of the schemas of the relations in the

database

 The instance of a database is the current values

(instances) of the relations in the database

 Any relation that is not of the conceptual model but is

made visible to a user as a “virtual relation” is called a

view.

Relational Algebra

 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.

Select Operation – Example

• Relation r A^ B^ C^ D

        1 5 12 23 7 7 3 10

• A=B ^ D > 5 (r)

A B C D     1 23 7 10

Project Operation – Example

 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 )

Project Operation

 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 accountaccount-number, balance ( account )

Union Operation

 Notation: rs  Defined as: rs = { t | tr or ts }  For rs to be valid.

  1. r, s must have the same arity (same number of attributes)
  2. The attribute domains must be compatible (e.g., 2nd column of r deals with the same type of values as does the 2nd column of s )  E.g. to find all customers with either an account or a loan  customer-name ( depositor )   customer-name ( borrower)

Set Difference Operation – Example

 Relations r, s: r – s : A B    1 2 1 r A B   2 3 s A B   1 1

Cartesian-Product Operation-Example

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

Cartesian-Product Operation

 Notation r x s  Defined as: r x s = { t q | tr and qs }  Assume that attributes of r(R) and s(S) are disjoint. (That is,

R  S = ).

 If attributes of r(R) and s(S ) are not disjoint, then renaming must be used.