Introduction to
Database Systems
Intro to Database Systems 1
Database and Database System
A database is a shared collection of
logically related data designed to meet the
information needs of an organization.
Components of a Database Systems
Database
Hardware
Software - DBMS
Users
Intro to Database Systems 2
Users
Application Programmer - writes
programs that use the database
Database Designers - designs
conceptual and logical database
Database Administrator (DBA)
Data Administrator
End - user - interacts with the system
from an on-line terminal by using
Query Languages etc.
Intro to Database Systems 3
Data & Database Administration
Data Administrator – a business manager
responsible for controlling the overall
corporate data resources
Database Administrator (DBA) - a technical
person responsible for development of the
total system
Intro to Database Systems 4
Advantages
▪ Control of data ▪ Improved data
redundancy accessibility and
▪ Data consistency responsiveness
▪ Multipurpose use of ▪ Increased productivity
data
▪ Improved maintenance
▪ Sharing of data, through data
▪ Enforcement of independence
standards
▪ Increased concurrency
▪ Economy of scale
▪ Balance conflicting user ▪ Improved backup and
requirement recovery services.
Intro to Database Systems 5
Disadvantages
▪ Complexity
▪ Size
▪ Cost of DBMS
▪ Additional hardware costs
▪ Cost of conversion
Intro to Database Systems 6
Relational Database Systems
7
Relational Model
STUDENTS
Relation Name
RegNo Name DOR Prog Yr Heading
P567 Kamau 02/05/99 BSc 3
Relation
T123 Onyango 23/04/00 BSc (CS) 3
J777 Mwaniki 02/06/00 BComm 1
Body
P900 Rono 23/04/00 BSc 4
T877 Otieno 04/04/98 BSc(CS) 3
Relational Model 8
Relational Data Structures
A relation corresponds to a table. A tuple corresponds to a
row and an attribute to a column
A domain is a set of values, from which one or two
attributes draw their actual values. Example the TOWN
domain is the set of all legal town names
A relation on domains D1, D2, .... Dn (not necessarily all
distinct) consists of a heading and a body
The heading consists of a fixed set of attributes A1, A2, ...
An such that each attribute Ai corresponds to exactly one of
the underlying domains Di
Relational Model 9
Relational Data Structures
The heading consists of a fixed set of attributes A1, A2, ...
An such that each attribute Ai corresponds to exactly one of
the underlying domains Di
The body consists of a time-varying set of tuples where each
tuple in turn consists of a set of attribute-value pairs (Ai,
Vi), one such pair for each attribute Ai in the heading
Degree - The degree of a relation is the number of attributes
of contains.
Cardinality – The cardinality of a relation is the number of
tuples it contains
Relational Model 10
Relational Data Structures
Properties of Relations
The relation has a distinct name
Each attribute has a distinct name
Each cell of the relation contains one atomic value
The values of an attribute are from the same domain
The order of attributes has no significance
No duplicate rows
The order of rows has no significance (theoretically)
Relational Model 11
Relational Data Structures
Relational Keys
Candidate Key - a set of unique identifiers
Primary Key - The candidate key selected to be the primary key
Composite Key - a candidate key that consists of two or more
attributes
Foreign Key - A foreign key is an attribute(s) in one relation R2
whose values are required to match those of the primary key of
some relation R1
Relational Model 12
Relational Data Integrity
Entity Integrity - No attribute participating in the primary
key of a relation is allowed to accept null values
Referential Integrity - If a relation R2 includes a foreign
they FK matching the primary key PK of some relation R1,
then every value of FK in R2 must either (a) be equal to the
value of PK in some tuple R1 or (b) be wholly null i.e. each
attribute value participating in that FK value must be null.
Relational Model 13
Relational Data Integrity
Enterprise Constraints – Additional rules
specified by the users or DBA
Domain Constraints – restriction on the values
allowed for attributes
Participation Constraints – Determines
whether the existence of a relation depends upon
it being related to another relation through a
relationship
Relational Model 14
Relational Data Languages
The Data Manipulation Languages (DML) of
relational databases is based on Relational
Algebra. Each operator of the relational algebra
takes either one or two relations as its input and
produces a new relation as its output
Relational Model 15