INTRODUCTION TO
RELATIONAL
DATABASE SYSTEMS
Author: Poonam Sharma
RELATIONAL DATABASE
The relational model uses a collection of
tables to represent both data and the
relationships among those data.
Today it is the primary data model for
many commercial data processing
applications because of its simplicity.
Relational database consists of a collection
of tables.
A row in a table represents a relationship
among a set of values.
Informally, a table is an entity set and a
row is an entity.
Author: Poonam Sharma
RELATION
Formally, given sets D1, D2, …. Dn a relation r is a subset of
D1 x D2 x … x Dn
Thus, a relation is a set of n-tuples (a1, a2, …, an) where each ai Di
Example: If
◦ customer_name = {Jones, Smith, Curry, Lindsay, …}
/* Set of all customer names */
◦ customer_street = {Main, North, Park, …} /* set of all street names*/
◦ customer_city = {Harrison, Rye, Pittsfield, …} /* set of all city names */
Then r = { (Jones, Main, Harrison),
(Smith, North, Rye),
(Curry, North, Rye),
(Lindsay, Park, Pittsfield) }
is a relation over
customer_name x customer_street x customer_city
Author: Poonam Sharma
Example of a Relation
Author: Poonam Sharma
Attribute Types
Each attribute of a relation has a name
The set of allowed values for each attribute is called
the domain of the attribute
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
The special value null is a member of every domain
Author: Poonam Sharma
Relation Schema
A1 , A2, …, An are attributes
R = (A1, A2, …, An ) is a relation schema
Example:
Customer_schema = (customer_name,
customer_street, customer_city)
r(R) denotes a relation r on the relation
schema R
Example:
customer (Customer_schema)
Author: Poonam Sharma
Relation Instance
The current values (relation instance)
of a relation are specified by a table
An element t of r is a tuple,
represented by a row in a table
attributes
(or columns)
customer_namecustomer_street customer_city
Jones Main Harrison
Smith North Rye tuples
Curry North Rye (or rows)
Lindsay Park Pittsfield
customer
Author: Poonam Sharma
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 : stores information about accounts
depositor : stores information about which customer
owns which account
customer : stores information about customers
Storing all information as a single relation such as
bank(account_number, balance, customer_name, ..)
results in
◦ repetition of information
e.g.,if two customers own an account (What gets repeated?)
◦ the need for null values
e.g., to represent a customer without an account
Author: Poonam Sharma
CUSTOMER RELATION
Author: Poonam Sharma
The depositor Relation
Author: Poonam Sharma
DEFINITION SUMMARY
Informal Terms Formal Terms
Table Relation
Column Attribute
Row Tuple
Values in a column Domain
Table Definition Schema of a Relation
Populated Table Extension
Author: Poonam Sharma