Lec 01
Lec 01
Database Systems
Teaching Staff’s Information
Lecturer: Dr. LIAO Jing (Week 1-8)
Email: [email protected]
Phone: 3442-8619
Office: G6413
Other TAs:
---Homework and midterm grading
Mr. WAN Ziyu [email protected]
Ms. ZHANG Peiying [email protected]
Mr. WU Ronghuan [email protected]
Mr. ZHANG Zhiyuan [email protected]
Course Overview
Course Format:
Lecture
Time: Monday 12:00pm - 2:50pm
Venue: YEUNG LT-2
Delivery mode: Face-to-Face
Tutorial
Time: Week 6-13 (2 Q&A and 6 Labs)
Venue: MMW 2450
Delivery mode: Face-to-Face
Assessment
Coursework -- 40% :
Mid-term -- 25%
Date: Week 7, Mon (Mar. 4th)
Time: Lecture time
Format: Face-to-face, Open-book exam
Homework assignments (3 times) -- 15%
Lab attendance (At least 5 of the 6 labs) -- 3% bonus
(such that coursework is capped to 40%)
Hardware
Software
- OS
- DBMS
- Applications
People
Procedures
Data
Database System
an integrated system of hardware, software, people, procedures,
and data
that define and regulate the collection, storage, management,
and use of data within a database environment 18
DB System Architecture
Interactive Appl. Prog’er
Naïve user user DBA
Application Application
(SQL) query DB schema
interfaces programs
Application Database
programs manager
object code DBMS
File manager
Data files DB
Data dict.
disk storage
DB System Architecture
Database Users
Naive Users:
Running application programs
Interactive Users:
Using query languages
Application Programmers
Writing embedded DML in a host language
DB System Architecture
Database Administrator (DBA)
DBA is the person who has central control over the DB
Main functions of DBA:
schema definition
storage structure and access method definition
schema and physical organization modification
granting of authorization for data access
integrity constraint specification
DB System Architecture
Data Query Language (DQL)
- a language used to make queries in databases
- e.g. search records with giving conditions
(sex=“Female”)
Data Manipulation Language (DML)
- a language that enables users to manipulate data
- e.g. insert or delete records
Data Definition Language (DDL)
- a language for defining DB schema
- e.g., create, modify, and remove database objects such
as tables, indexes, and users.
Data Abstraction: 3-level architecture
Data Abstraction
Data Abstraction
Abstract view of the data
simplify interaction with the system
hide details of how data is stored and manipulated
Levels of abstraction
Physical/internal level: internal schema uses a physical data
model and describes the complete details of data storage and
access paths for the database.
Conceptual level: conceptual schema describes the structure of
the whole database for a community of users and hides the details
of physical storage structures.
View/external level: external schema describes the part of the
database that a particular user group is interested in and hides the
rest from that group.
Data Independence
the ability to modify a schema definition in one level without
affecting a schema in the next higher level
there are two kinds (a result of the 3-level architecture):
physical data independence
-- the ability to modify the physical schema without
altering the conceptual schema and thus, without
causing the application programs to be rewritten
logical data independence
-- the ability to modify the conceptual schema without
causing the application programs to be rewritten
Data Abstraction: 3-level architecture
Data Models
Data Model (conceptual level)
A collection of conceptual tools for describing data, data
relationships, operations, and consistency constraints
the “core” of a database
The Entity-Relationship Model
Preliminaries
Proposed by P. Chen in 1976
Direct, easy-to-understand graphical notation
Translates readily to relational schema for database
design
Ideas/requirem E/R Relational Relational
ents design schema database
Three basic concepts:
Entity, Attribute, Relationship
ER Model Concepts
Entity
a distinguishable object with an independent
existence
Example: John Chan, CityU, HSBC, …
Entity Set
a set of entities of the same type
Example: Student, University, Bank, ...
ER Model Concepts
Attribute(Property) -- a piece of information describing
an entity
Example: Name, ID, Address, Sex are attributes
of a student entity
Example:
studentID is a key of the STUDENT entity set: since there
are no two students having the same value on studentID.
HKID is another key of the STUDENT entity set: since there
are no two students having the same value on HKID.
Name is not a key of the STUDENT entity set: since two
students may have the same name.
ER Model Concepts
Relationship -- an association among several entities
Example: Patrick and Eva are friends
Patrick is taking cs3450
a relationship can carry attributes: properties of the relationship
Example: Patrick takes cs3450 with a grade of B+
One-to-
one(1:1)
One-to-many Many-to-
(1:N) many (M:N)
1 1
R
Example COMPANY Database
We need to create a database schema (definition) based on the
following (simplified) application requirements of the COMPANY
Database:
N-to-1
Many
employees in
the same
department
Relationship instances of the M:N WORKS_ON
relationship between EMPLOYEE and PROJECT
M-to-n
Many employee
work on many
projects
ER Model Diagram
Weak Entity Set
an entity set that does NOT have enough attributes to form a key
Role Indicators
manager
employee Works-for
worker
ER Model Diagram
Derived Attribute: An attribute which can be derived
from other attributes is known as derived attribute.
Summary of ER-Diagram Notation
Symbol Meaning
ENTITY TYPE
RELATIONSHIP TYPE
ATTRIBUTE
KEY ATTRIBUTE
MULTIVALUED ATTRIBUTE
COMPOSITE ATTRIBUTE
DERIVED ATTRIBUTE
E1 R E2 TOTAL PARTICIPATION OF E2 IN R
1 N
E1 R E2 CARDINALITY RATIO 1:N FOR E1:E2 IN R