Week
2:
Introduc)on to Advanced
Database systems
Dr. Sarah Al-Shareef
saashareef@[Link]
Department of Computer Science
Umm Al-Qura University
Acknowledgment: All course slides are either referenced to Elmasri. & Navathe Book online presenta=ons, Dr. Salahadin
Mohammed Adam & Ms. Mashael Alkadi (with certain amendments) or are personally developed by the instructor.
Today’s Agenda
• About this course
• Who should take this course
• Administra)ve issues:
– Assessment scheme
– Course and class policies
– Tenta)ve course )meline
• Review fundamentals of database design
1436/1437 - First Semester Advanced Database Systems 1
About this Course
• This course provides advanced data modelling, such as
object, object-rela)onal, and XML, and the suppor)ng
theore)cal founda)on.
• In addi)on, it provides some techniques of advanced
schema mapping.
• Finally, it should give you some basics on advanced
database systems implementa)on and management,
such as: indexing, query processing, local and
distributed transac)on processing, and security.
1436/1437 - First Semester Advanced Database Systems 2
About this Course
• Topics to be covered:
– The enhanced en)ty-rela)onship (EER) model.
– Object and Object-rela)onal databases.
– XML databases.
– Advanced database indexing techniques.
– Database transac)on and query processing.
– Distributed databases.
– Database security.
– Database tuning and recovery.
• References: There are plenty of good books on DBS; here are some:
– Database Systems: Models, Languages, Design And Applica=on Programming. By Ramez
Elmasri and Shamkant B. Navathe.
– Fundamentals of Databases. By Ramez Elmasri and Shamkant B [Link]
– Database Systems: Design, Implementa=on, and Management, By Peter Rob, Steven Morris
and Carlos Coronel
1436/1437 - First Semester Advanced Database Systems 3
Who Should Take This Course?
• Knowledge of database design.
– Topics covered in “Fundamentals of Databases” course (1401312-3).
• Ability to setup your own database system management environment.
– What you’ve learned in 1401312-3 and applied in the course project.
• Knowledge of programming languages to be used for building interfaces
and DBSM.
– Any of: Java, Python, Perl, C++
• Good problem-solving skills.
• Good English
– All references are in English.
1436/1437 - First Semester Advanced Database Systems 4
Assessment and Workload
• 15% [id] Quizzes
– 4 Quizzes overall with 2.5% each.
• 20% [gr] Project
– You should form a team of 4 students.
– Cross-sec)on is NOT allowed.
– 4 milestones and a final presenta)on (4%,4%,7%,7% and 3%).
• 5% [gr] In-class par7cipa7on
– 2 assignments with 5 points each.
• 20% [id] Midterm exam
• 40% [id] Final exam
• Workload:
– For an average grade, 1 credit = 3 hours/week of academic ac)vi)es: lectures,
assignments, reading, discussions, .. etc.
– Your course has 3 credits (i.e. 3x3=9 hpw).
– There will be 3 hpw of lectures (i.e. you are expected to work for 9-3=6hpw).
1436/1437 - First Semester Advanced Database Systems 5
Course Policies
• Please be at the class on )me.
– Latecomers will not be allowed to apend the class.
• Please mute your mobiles while you are in the class.
– You will be forced to leave the class if your mobile rang.
• Any absence from quizzes or exams will make you loose their marks unless
you have got a medical excuse or any other excuse approved by the
department.
• Each student is expected to apend all lectures.
– Each absence will be counted as one-half lost mark of your total grade.
• Each student must verify her apendance by answering post-lecture
surveys.
– Post-lecture surveys are not graded.
– Verified apendance iff apended AND submit post-lecture survey.
1436/1437 - First Semester Advanced Database Systems 6
Tenta)ve Timeline
Week Topics Assessments
2 Intro + Advanced relational algebra and SQL
3 The Enhanced Entity-Relationship (EER) model 4% Milestone1
4 Object and Object-Relational Databases 5% Quiz 1
5 XML
6 Database File Indexing Techniques 5% Quiz 2
7 Query Processing and Query Optimization 4% Milestone2
8 Techniques
9 Midterm Break
10 Database Tuning and Physical Design Issues 20% Midterm
11 Advanced Database Transaction Processing 7% Milestone3
12 Database Recovery Protocols 5% Quiz 3
13
Distributed Databases (DDB)
14 7% Milestone4
15 Database Security 5% Quiz 4
16 Final presentations 3%
17 Final Exams
1436/1437 - First Semester Advanced Database Systems 7
Today’s Agenda
• About this course
• Who should take this course
• Administra)ve issues:
– Assessment scheme
– Course and class policies
– Tenta)ve course )meline
• Review fundamentals of database design
1436/1437 - First Semester Advanced Database Systems 8
Review of Fundamentals of Database Design
• The main steps in DB Design
– Requirement collec)on and analysis
– Data modelling
– Func)onal modelling
• Rela)onal Data model
1436/1437 - First Semester Advanced Database Systems 9
The Main Steps in DB Design
1. Requirement collec)on and analysis
– How the data is collected and analysed.
2. Data modelling
– How data should be organized and stored in the database.
– Includes:
• Conceptual data model
• Logical data model
• Physical data model
3. Func)onal modelling
– How data is processed
1436/1437 - First Semester Advanced Database Systems 10
1. Requirement Collec)on & Analysis
• Main objec)ves:
– To determine the data requirements of the DB in terms of primi)ve
objects.
– To classify and describe the informa)on about these objects.
– To iden)fy and classify the rela)onships among the objects.
– To determine the types of transac)ons that will be executed on the DB
and the interac)ons between the data and the transac)ons.
– To iden)fy rules governing the integrity of the data.
• Requirement analysis can be gathered by data modeller from:
– Exi)ng documents
– Users
– Exis)ng systems
1436/1437 - First Semester Advanced Database Systems 11
Example
• Required: A database to record the students’
enrolment in the CS courses.
• Assume that aver requirement analysis we
iden)fied the following 3 en))es:
– Course
– Enrol
– Student
1436/1437 - First Semester Advanced Database Systems 12
2. Data Modelling: Conceptual Data Model
• Main objec)ves:
– To iden)fy en))es
– To iden)fy the highest-level rela)onships among en))es.
• No apributes are specified.
• Example:
Student Enrol Course
3 main en))es: Student, Enrol, Course
1436/1437 - First Semester Advanced Database Systems 13
2. Data Modelling: Logical Data Model
• Main objec)ves:
– Describe the data in as much details as possible,
without regard to how they will be physically
implemented in the database.
• This includes:
– En))es & rela)onships among them.
– All apributes for each en)ty are specified.
– The primary key for each en)ty is specified.
– Foreign keys are specified.
– Many-to-many rela)onships are resolved.
– Normalisa)on is performed at this level.
1436/1437 - First Semester Advanced Database Systems 14
Example
Name Name GPA
Course Enroll Student
CID SID
1436/1437 - First Semester Advanced Database Systems 15
2. Data Modelling: Physical Data Model
• Features:
– Specifica)on all tables and columns
– Foreign keys are used to iden)fy rela)onships between tables.
– Denormalisa)on may occu based on user requirements.
– Physical considera)ons may cause the physical data model to
be quite different from the logical data model.
• Steps:
– Convert en))es into tables.
– Convert rela)onships into foreign keys.
– Convert apributes into columns.
– Modify the physical data model based on physical constraints
and requirements.
1436/1437 - First Semester Advanced Database Systems 16
The Rela)onal Data Model
• The logical model behind the rela)onal DB (RDB). Data
is always represented as rela)ons (2-dim. tables).
• Basic Concepts:
– Rela)on
– Apribute
– Schema
– Tuple
– Keys
– Constraints
– Func)onal dependency
– Normaliza)on
September 26, 2016 ICS 424: recap 17
Rela)on
• The way to represent data is through rela)ons.
• A rela7on is a two-dimensional table.
• The order of rows and columns can be exchanged, and it is
s)ll the same rela)on.
Example:
Course
CID Title
ICS 102 Java Rela)on
ICS 202 Data structures
Rela)on name
ICS 334 Databases
1436/1437 - First Semester Advanced Database Systems 18
Apribute
• An apribute is the name of a column in a rela)on.
It usually describes the meaning of the content in
the column.
• Example:
Apributes
Course
CID Title
ICS 102 Java
ICS 202 Data structures
ICS 334 Databases
1436/1437 - First Semester Advanced Database Systems 19
Schema
• A schema is a descrip)on of a class of rela)on. It consists of
the name of the rela)on and the set of apributes in the
rela)on.
That it is a set of apributes means that the apributes are
unordered.
• Example:
Course
CID Title
ICS 102 Java
ICS 202 Data structures
ICS 334 Databases
Schema for the above rela)on: Course(CID, Title)
1436/1437 - First Semester Advanced Database Systems 20
Tuple
• A tuple is a row in a table. A rela)on can be seen
as a set of tuples.
• Example:
Course
CID Title
ICS 102 Java
A rela)on of
ICS 202 Data structures 3 tuples
ICS 334 Databases
1436/1437 - First Semester Advanced Database Systems 21
Keys
• Superkey:
– A combina)on of apributes that can be uniquely used to iden)fy a record.
– A table may have many superkeys
• Candidate key:
– A superkey but without extraneous data.
– A table can have one or more candidate keys
• Primary key
– One of the candidate keys is chosen to be the primary key.
– There can only be one primary key in a table
• Alternate key
– All the candidate keys, minus the primary key.
– The number of alternate keys in a table is one less than the number of
candidate keys.
1436/1437 - First Semester Advanced Database Systems 22
Constraints
• NOT NULL
– No null values are allowed in an apribute specified as NOT NULL
• UNIQUE
– No duplicate values are allowed in a column specified as UNIQUE.
• Primary key
– Must be UNIQUE and NOT NULL
• Foreign key
– Must refer to a value of a candidate key in the parent table
– Can be null
– Can be duplicate
1436/1437 - First Semester Advanced Database Systems 23
Func)onal dependency
• A func)onal dependency occurs when one or more apributes in a rela)on
uniquely determine other apribute(s). If A and B are apributes, this can be
wripen A --> B which would be the same as sta)ng "B is func)onally
dependent upon A."
• Apribute A is the determinant and apribute B is the func7onally
dependent.
• If the determinant is part of the primary key (and not the whole key),
then the dependency is called par7al dependency.
• If both the determinant and the func)onally dependent apributes are non
key apributes, then the dependency is called transi7ve dependency.
1436/1437 - First Semester Advanced Database Systems 24
Normalisa)on
• UNF (Un Normalized form)
– A rela)on is in UNF if it contains at least one mul)-valued apribute
• INF
– A rela)on is in 1NF if it has no mul)-valued apribute.
• 2NF
– A rela)ons is in 2NF if it is in 1NF and has no par)al dependency.
• 3NF
– A rela)on is in 3NF if its is in 2NF and contains no transi)ve dependency.
• BCNF
– A rela)on is in BCNF if and only if, every determinant is a candidate key.
1436/1437 - First Semester Advanced Database Systems 25
Case Study: Mobile Game App
• For Example, if you want to develop a DB for a
mobile game applica)on, what are the
informa)on that we’re concerned about?
Hint: always start simple
1436/1437 - First Semester Advanced Database Systems 26
An example of a game UML
1436/1437 - First Semester Advanced Database Systems 27
What’s Next?
• Forming teams:
– Please divide yourselves into groups of 4 students.
– Send me an email including:
• Your team name
• Your leader name
• Your team members
– Your email subject line should be:
ADB Project Team – Group 1 – YourTeamName
• Read Chapter 2 of Elmasri’s book and then answer the online quiz
on the eLearn system.
• Next lecture, review rela)onal algebra and SQL commands so get
ready for some compe))on between teams with bonuses points
for the top 3 team. (in-class par)cipa)on)
– Each team members should sit next to each others.
1436/1437 - First Semester Advanced Database Systems 28