You are on page 1of 10

CSC271 Database Systems

Relational Model

Sets and Cross Product


Relational model of the data is based on the mathematical foundation

of sets and was proposed by E. F. Codd.


Consider following sets

name = {Junaid, Sarmad, Kutab, }


! Set

street = {Main, North, Park, }


! Set

of all customer names

city

of all street names

= {Haripur, Rawalpindi, Peshawar, }

Compute name x street x city


Now find a subset of the cross product

Relation as a Set
Say r = { (Junaid, Main, Haripur),

(Sarmad, North, Rawalpindi),


(Kutab,

North, Rawalpindi),

(Junaid, Park, Peshawar) }


Is r a set?
IF r (name x street x city)
THEN

r is a relation on (name x street x city)

Relation Example - Customer


Columns as
attributes

Name
Junaid
Sarmad
Kutab
Junaid

Street
Main
North
North
Park

City
Haripur
Rawalpindi
Rawalpindi
Peshawar

Order of tuples is irrelevant;


tuples may be stored in an arbitrary order
WHY?
4

Rows as
tuples

Basic Structure
Given sets of domains D1, D2, . Dn
E.g.

Person names and City names

A relation r is a subset of

D1 x D2 x x Dn
Thus, a relation is a set of tuples (a1, a2, , an)

where each ai Di
Degree (or arity) of the relation is number of

attributes n involved in the relations.

Attributes and Domains


Every attribute (column) of a relation has a name
The set of allowed values for each attribute is called

the domain of the attribute


The

special value null is a member of every


domain

Attribute values are (normally) required to be atomic;

that is, indivisible


E.g.

the value of an attribute can be an account


number, but cannot be a set of account numbers

Domain is said to be atomic if all its members are

atomic
6

Relation Schema
A1, A2, , An are attributes
S = (A1, A2, , An ) is a relation schema
Example:

CustomerSchema = (name, street, city)

r (S) denotes a relation r on the relation schema S


Example:

customer (CustomerSchema)

Database
A database consists of multiple relations
Information about an enterprise is broken up

into parts, with each relation storing one part of


the information
Account

: information about accounts

Customer

: information about customers

Depositor

: information about which customer


owns which account

Example Database
Accounts

Customers

Depositors
9

Summary
Topics covered
Relation,

relation instance, and relation

schema
Tuples

and Attributes

Reading List: DSC Chapter#2.


Next Lecture: Relational Algebra

10

You might also like