Download as pdf or txt
Download as pdf or txt
You are on page 1of 26

Midterm Review

• Major Database Concepts (Chap 1, 2)

• Conceptual Modeling
– ER Model (Chap 7)
• Exclude 7.8
– EER (Chap 8)
• Exclude 8.6, 8.7
• Relational Data Model
– Concepts & Constraints (Chap 3.1-3.4)

• ER/EER-to-Relational Mapping (Chap 9)


• Relational Query Languages
– Relational Algebra (Chap 6.1, 6.2, 6.3, 6.5)
• Exclude 6.3.4, 6.4

1
Review of Major DB Concepts
• Data and Information
– Data: raw facts that can be recorded and have an implicit meaning.
– Information: processed data that has value for decision making
• Database
– A collection of data. Essential to organize data for retrieval and
maintenance.
– Characteristics of Database
• Metadata
• DBMS: Database management system
• Database system: DBMS + Data

2
University Database

Faculty
Registration
Entities: Assignment
students, faculty, courses,
offerings, enrollments
Relationships:
faculty teach offerings,
Grade students enroll in Course
Recording offerings, offerings made Scheduling
of courses, ...

University Database

3
A Database System

4
A Simple File System

5
Review of Major DB Concepts (Cont.)

• Data Model
– Definition
– Main categories
• Database Schemas and Instances (States)
• DBMS architecture
– Three –Schema architecture
– Data independence
• DBMS languages: DDL,DML, SDL, VDL
6
Levels of Abstraction
payroll billing records

View 1 View 2 View 3 External


schemas

Conceptual schema

Physical schema

13
Data Independence
• Logical Data Independence: The capacity to
change the conceptual schema without having to change the
external schemas and their application programs

• Physical Data Independence: The capacity to


change the internal schema without having to change the
conceptual schema.

14
Database Models
• A set of logical constructs
– Represent data structure & data relationships
• Two types of database models
– Conceptual model
• Logical nature of data representation
• What is represented
– Implementation model
• How the data are represented
• How the data structure are implemented
16
Implementation Database Models
• Hierarchical database model
• Network database model
• Relational database model

17
Data Modeling Using
the ER Model and EER
• ER Model Concepts
– Entities and Attributes
– Entity Types, Value Sets, and Key Attributes
– Weak Entity Types
– Roles and Attributes in Relationship Types
– Relationships and Relationship Types
– Structural constrains on relationship types (2 methods)
• 1. Cardinality ratios, and Participation constraints (e.g., Fig 7.2)
• 2. Specify (min, max), e.g. Fig 7.15
– ER diagram notation (Fig 7.14)
• Relationships of Higher Degree
• Extended Entity-Relationship (EER) Model

18
Graphical Representation
• Roles are edges labeled with role names (omitted if
role name = name of entity set). Most attributes have
been omitted.
• E.g.
– A program can be offered to any number of student, but
every student must major in exact one program.

STUDENT MajorsIn PROGRAM

– A degree program can have many student majoring in and a


student can major in at most 4 programs in the same
university.
19
Graphical Representation
• Roles are edges labeled with role names (omitted if
role name = name of entity set). Most attributes have
been omitted.

20
Relational Data Model

• Relational Model Concepts


• Characteristics of Relations
• Relational Integrity Constraints
– Key Constraints
– Entity Integrity Constraints
– Referential Integrity Constraints
• Operations
21
Definition Summary
Informal Terms Formal Term
Table Relation
Column Attribute/Domain
Values in a column Domain
Row Tuple/Instance
Table Definition Schema of Relation
Populated Table Extension
22
Integrity Rules
• Entity integrity: primary keys
– Each table has column(s) with unique values
– Ensures entities are traceable
• Referential integrity: foreign keys
– Values of a column in one table match values
from a source table
– Ensures valid references among tables

23
Formal Definitions I
• Superkey: column(s) with unique values
– See complete definition in lecture notes (week 5) and text book
chap 3.2.2
• Candidate key: minimal superkey
• Null value: special value meaning value
unknown or inapplicable
• Primary key: a designated candidate key;
cannot contain null values
• Foreign key:
– Satisfy two conditions:
• 1. Dom(R1.FK)=Dom(R2.PK)
• 2. t1[FK]=t2[PK] or NULL
column(s) whose values must match the values in a candidate
key of another table
24
Formal Definitions II
• Entity integrity
– No two rows with the same primary key value
– No null values in a primary key
• Referential integrity
– Foreign keys must match candidate key of
source table
– Foreign keys in some cases can be null

25
Self-Referencing Relationships
• Foreign key that references the same table
• Represents relationships among members of
the same set
• Not common but important when occurring

26
ER-to-Relational Mapping
• Mapping from ER to Relational
– Map each entity to a table
– Map each attribute to a column
– Map relationships
• Map many-to-many relationships to a table
• Use key propagation for one-to-one and one-to-
many relationships
• If relationship has attributes then map it a table

27
ER-to-Relational Mapping (Cont.)

• Mapping keys
• For strong entities use the key as the key for
the corresponding table
• For weak entities use the combination of the
entity’s key and the key from the strong
entity
• Use the keys from the two entity types as
the key for the relationship (table)
28
EER Mapping
• Mapping high degree relationship type
• Mapping generalization and specialization

= First alternative:
S
Create one table for S(s1, s2, s3)
s1 s2 s3 Create one table for A(s1, a)
Create one table for B(s1, b)
A B = Second alternative:
Create one table for A(s1, s2, s3,a)
a b Create one table for B(s1, s2,s3,b)

29
EER Modeling
= Mapping disjoint and overlapping
generalization and specialization
= Third alternative: Create one table
S
= If Disjoint:
s1 s2 s3 C(s1, s2,s3, a, b)
Note: s3 is the qualifying attribute
A B

= If Overlapping:
a b C(S1, s2, s3, aflag, a, bflag, b)
When aflag true then take value of a
When bflag true then take value of b

30
EER Mapping
• Mapping of Shared Subclass
– 9.2.2 (pp297)
• Mapping of Categories
– 9.2.3 (pp297-298)

32
Lecture notes for Relational
Algebra

33
34

You might also like