Chapter 3 - Relational Model
Chapter 3 - Relational Model
Basic Structure
Let us consider the account table. It has three
column headers,
account_number, branch_number, balance
These headers are attributes
For each, there is a set of permitted values,
called the DOMAIN of that attribute.
For attribute branch_name the domain is the set of all
branch names. At physical level the domain of branch
name is string of characters
Let,
D1 - set of all account no.s
D2 set of all branch_names
D3 - set of all balances
Basic Structure
Any row of Account table must consist of a 3tuples(v1, v2, v3)
v1 account no. (v1 is in D1)
v2 branch name (v2 is in D2)
v3 balance (v3 is in D3)
i.e. Account is a subset of
D1 x D2x D3
Basic Structure
Database Schema
T[Au, Aw, , Az] and t.(Au, Aw, , Az) where Au, Aw, , Az is a
list of attributes from R, refers to the subtuple of values
<vu, vw, , vz) from t corresponding to the attributes
specified in the list
Keys
A super key of an entity set is a set of one or
more attributes whose values uniquely
determine each entity.
A candidate key of an entity set is a minimal
super key
Customer-id is candidate key of customer
account-number is candidate key of account
Non-Key Attributes
The attributes other than the Candidate Key
attributes are called Non-Key attributes.
OR
The attributes which do not participate in
any of the Candidate keys
Foreign key
A foreign key is a copy of a primary key
that has been exported from one relation
into another to represent the existence of
a relationship between them. A foreign
key is a copy of the whole of its parent
primary key i.e. if the primary key is
composite, then so is the foreign key
Relational algebra
Relational Algebra
Assignment Operation
Extended Relational-algebra
operations
Generalized projection
Outer join
Left
Right
Full
Aggregate Functions
Generalized Projection
Rename Operation
X (E)
Rename Operation
How to Read it
Result of relational-algebra query
expression E under the name X, and with
the attributes renamed to A1, A2, . . . , An
Aggregate Functions
Aggregate Functions
sum
salary
(employee)
count-distinct
departmentno
(employee)
View Definition
View Definition