Lec 5 - IDB
Lec 5 - IDB
Introduction to
Database Systems
Mohammad Imran
Lecturer
Department of Information Technology
Balochistan University of Information Technology, Engineering & Management Science
Introduction to Database Systems Spring 2015 Mohammad Imran April 21, 2015 1
Balochistan University of Information Technology, Engineering & Management Sciences
Lecture 5
Relational Data Model
Introduction to Database Systems Spring 2015 Mohammad Imran April 21, 2015 2
Balochistan University of Information Technology, Engineering & Management Sciences
Introduction to Database Systems Spring 2015 Mohammad Imran April 21, 2015 3
Balochistan University of Information Technology, Engineering & Management Sciences
4
Introduction to Database Systems Spring 2015 Mohammad Imran April 21, 2015 4
Balochistan University of Information Technology, Engineering & Management Sciences
5
Introduction to Database Systems Spring 2015 Mohammad Imran April 21, 2015 5
Balochistan University of Information Technology, Engineering & Management Sciences
RDBMS
• Relational Database Management System
• Based on Relational Model
• So lets see what a relational model is
Introduction to Database Systems Spring 2015 Mohammad Imran April 21, 2015 7
Balochistan University of Information Technology, Engineering & Management Sciences
Relational Model
• Edgar Frank Codd (aka E.F. Code)
• (19 August 1923 – 18 April 2003)
• English computer scientist, Worked for IBM
• Invented the relational model for database
management, basis for relational databases
• Made valuable contributions to computer
science
• Relational model, a very influential general
theory of data management, remains his
most mentioned achievement
Introduction to Database Systems Spring 2015 Mohammad Imran April 21, 2015 8
Balochistan University of Information Technology, Engineering & Management Sciences
Relational Model
• Primary data model, which is used widely around the
world for data storage and processing
• Model is simple and it has all the properties and
capabilities required to process data with storage
efficiency
Introduction to Database Systems Spring 2015 Mohammad Imran April 21, 2015 9
Balochistan University of Information Technology, Engineering & Management Sciences
Introduction to Database Systems Spring 2015 Mohammad Imran April 21, 2015 10
Balochistan University of Information Technology, Engineering & Management Sciences
Tables
• In relational data model, • A Table
relations are saved in the
format of Tables CMS-ID Name Session Phone
Introduction to Database Systems Spring 2015 Mohammad Imran April 21, 2015 11
Balochistan University of Information Technology, Engineering & Management Sciences
Tuple
• A single row of a table, • Tuple: highlighted in Red
which contains a single
CMS-ID Name Session Phone
record for that relation is
123456 Ali Spring 15 1111-
called a tuple 1111111
Introduction to Database Systems Spring 2015 Mohammad Imran April 21, 2015 12
Balochistan University of Information Technology, Engineering & Management Sciences
Relation Instance
• A finite set of tuples in • Relation Instance: highlighted in Red
the relational database
CMS-ID Name Session Phone
system represents
123456 Ali Spring 15 1111-
relation instance 1111111
Introduction to Database Systems Spring 2015 Mohammad Imran April 21, 2015 13
Balochistan University of Information Technology, Engineering & Management Sciences
Relation Schema
• A relation schema describes
o relation name (table name)
o attributes, and their names
Introduction to Database Systems Spring 2015 Mohammad Imran April 21, 2015 14
Balochistan University of Information Technology, Engineering & Management Sciences
Introduction to Database Systems Spring 2015 Mohammad Imran April 21, 2015 15
Balochistan University of Information Technology, Engineering & Management Sciences
Relation Key
• Each row has one or • Relation Key: highlighted
more attributes, known
CMS-ID Name Session Phone
as relation key, which
123456 Ali Spring 15 1111-
can identify the row in 1111111
Introduction to Database Systems Spring 2015 Mohammad Imran April 21, 2015 16
Balochistan University of Information Technology, Engineering & Management Sciences
Attribute domain
• Every attribute has some pre-defined value scope, known
as attribute domain
o Age (1-99)
o Married (yes or no)
Introduction to Database Systems Spring 2015 Mohammad Imran April 21, 2015 17
Balochistan University of Information Technology, Engineering & Management Sciences
Constraints
• Every relation has some conditions that must hold for it to
be a valid relation
• These conditions are called Relational Integrity
Constraints
• There are three main integrity constraints:
o Key constraints
o Domain constraints
o Referential integrity constraints
Introduction to Database Systems Spring 2015 Mohammad Imran April 21, 2015 18
Balochistan University of Information Technology, Engineering & Management Sciences
Key Constraints
• There must be at least one minimal subset of attributes in the relation,
which can identify a tuple uniquely
• This minimal subset of attributes is called key for that relation
• If there are more than one such minimal subsets, these are called
candidate keys
• Key constraints force that
o in a relation with a key attribute, no two tuples can have identical values
for key attributes
o a key attribute can not have NULL values.
• Key constraints are also referred to as Entity Constraints
Introduction to Database Systems Spring 2015 Mohammad Imran April 21, 2015 19
Balochistan University of Information Technology, Engineering & Management Sciences
Domain Constraints
• Attributes have specific values in real-world scenario
o For example, age can only be a positive integer
• Same constraints have been tried to employ on the
attributes of a relation
• Every attribute is bound to have a specific range of values
o For example
• age cannot be less than zero
• telephone numbers cannot contain a digit outside 0-9
Introduction to Database Systems Spring 2015 Mohammad Imran April 21, 2015 20
Balochistan University of Information Technology, Engineering & Management Sciences
Introduction to Database Systems Spring 2015 Mohammad Imran April 21, 2015 21
Balochistan University of Information Technology, Engineering & Management Sciences
Introduction to Database Systems Spring 2015 Mohammad Imran April 21, 2015 22
Balochistan University of Information Technology, Engineering & Management Sciences
Relational Model
Introduction to Database Systems Spring 2015 Mohammad Imran April 21, 2015 23
Balochistan University of Information Technology, Engineering & Management Sciences
Thank you
24
Introduction to Database Systems Spring 2015 Mohammad Imran April 21, 2015