Database Systems!: Fundamentals of Databases
Database Systems!: Fundamentals of Databases
Fundamentals of Databases
Dr. Seema Jehan
Outline!
• Relational Database model’s logical structure
• ANSI/SPARC Architecture
Relational Data Model!
• Data Model
• Data Structures
• Constraints
• Operations
• Keys and Identifiers
• Integrity and Consistency
• Null Values
• Surrogates
The Relational Model!
• The logical view of the relational database is based on a logical
construct called a relation.
aali.bscs18seecs@se
100
ALI
AYESHA
2002-10-2
H.N34, ST,63,I-10/3, ISLAMABAD
LAHORE
3.54
ecs.edu.pk
• Example:
• Email must be unique
• Email’s are not allowed to be NULL.
• GPA must be less than 4.0
• DOB must be greater than 1900-01-01
Relational Model- Operations!
• Operations support change and retrieval of data
select Email, DOB
from Student
Where HOMETOWN=‘Lahore’ and GPA>3.0
DOB
CMS_ID
LAST_NAME
FIRST_NAME
EMAIL
ADDRESS
HOMETOWN
GPA
DATE
INTEGER
Varchar(50)
Varchar(50)
Varchar(50)
Varchar(100)
Varchar(50)
INTEGER
TIME
aali.bscs18see
2002-
100
ALI
AYESHA
[email protected]. H.N34, ST,63,I-10/3, ISLAMABAD
LAHORE
3.54
10-2
pk
iahmad.bscs18
2001- H.No43, ST. 5, SEC J, DHA-
101
AHMAD
IFRAH
[email protected] KARACHI
3.14
11-22
Phase1, ISLAMABAD
du.pk
eomer.bese18
2000- H.23, ST.37,SEC J, Phase-2, Bahria
102
OMER
EISHA
[email protected] RAWALPINDI
2.83
09-10
town - phase 2, ISLAMABAD
du.pk
Relational Model- Keys and
Identifiers!
• Keys are uniqueness constraints
• Making Email the primary key in Student will force all
Emails to be unique in Student.
Student
[email protected].
H.N34, ST,63,I-10/3, ISLAMABAD
LAHORE
3.54
pk
iahmad.bscs18seecs@seecs.
H.No43, ST. 5, SEC J, DHA-Phase1, ISLAMABAD
KARACHI
3.14
edu.pk
Regular Student
Student
stud.bscs18seecs
2002-10-2
ALI
AYESHA
LAHORE
[email protected]
H.N34, ST,63,I-10/3, ISLAMABAD
@seecs.edu.pk
stud.bscs18seecs
2002-10-2
LAHORE
AYESHA
ALI
F
YES
@seecs.edu.pk
iahmad.bscs18see
2001-11-22
KARACHI
IFRAH
AHMAD
F
UNKNOWN
[email protected]
eomer.bese18seec
2000-09-10
LAHORE
EISHA
OMER
F
NO
[email protected]
zali.bese18seecs@
2001-09-10
ISLAMABAD
ZOHAIB
ALI
M
Inapplicable
seecs.edu.pk
Surrogates-Things and Names!
Employee
Employee
Name! Address!
Email
Name
Address
Email!
Name-based Representation
Employee
Email!
Surrogate-based Representation
Exercise!
ANSI/SPARC 3-level DB
Architecture!
• A database is divided into schema and data
• This separation allows data access more efficient and
effective.
Data!
ANSI/SPARC 3-level DB
Architecture!
• Likewise, for each application running on the schema we
can create an external schema.
Data!
ANSI/SPARC 3-level DB
Architecture!
External External External
Schema! Schema! Schema!
Conceptual
Schema!
Internal
Schema!
Database!
Conceptual Schema!
• Describes all conceptually relevant, general, time-
invariant structural aspects of reality
STUDENT
EMAIL
DOB
CITY
NAME
GENDER
GPA
Conceptual
Schema!
Internal
Schema!
Database!
Logical Data Independence!
• Logical data independence is a measure of how much the
conceptual schema can change without affecting the
application program.
External External External
Schema! Schema! Schema!
Conceptual
Schema!
Internal
Schema!
Database!
ANSI/SPARC DBMS ARCHITECTURE!
Exercise!
Summary!
• Major aspects of a relational data model are data
structures,integrity constrains and operations.