You are on page 1of 18

Database Systems

CSC 246
L03
1
E-R Database Model
Composite Keys
 A primary key that is made up of more than one
attribute is known as a composite key.
 Composite keys commonly occur in relationships
tables.
 Primary and foreign keys are the most basic
components on which relational database theory
is based.

2
E-R Database Model
Foreign Key
 A foreign key is an attribute (or combination of attributes)
in one table whose values must either match the primary
key in another table or be null.
 Foreign keys enforce referential integrity by completing
an association between two entities.
– the foreign key value refers to an existing valid tuple in
 another table.
 Foreign keys provide a method for navigating between
different instances of an entity.

3
4
E-R Database Model
Examples of E-R diagrams
 Example 1: Student (S) and Projects (P)
Relationship: Works (W)
 Example 2: Customer (C) and Accounts (A)
Relationship: Deposits (D)
 Example 3: Tourist (T) and Flights (F)
Relationship: Reserves (R)

5
E-R Database Model
E-R Database Model
E-R Database Model
Relational Databases
 A relation is a two-dimensional table with
the following properties:
– Entries in each table are single-valued.
– Each row is distinct and contains information
about one entity occurrence.
– Each column has a distinct name and contains
a specific range of values.
– The order or rows or columns is immaterial.
11
Example COMPANY Database
 We need to create a database schema design based
on the following (simplified) requirements of the
COMPANY Database:
– The company is organized into DEPARTMENTs. Each
department has a name, number and an employee who
manages the department. We keep track of the start date
of the department manager. A department may have
several locations.

12
Example COMPANY Database
– Each department controls a number of
PROJECTs. Each project has a unique name,
unique number and is located at a single location.

13
Example COMPANY Database
– We store each EMPLOYEE’s Name, social
security number, address, salary, sex, and
birthdate.
• Each employee works for one department.
• We keep track of the direct supervisor of each
employee.

14
Class Exercise
 The Kumasi GCUC Library at Kenyase has asked
you to develop a Database System for their books
and Borrowing Members, with a hope to develop
programs that will help them keep track of books
lent, who they are lent to, when lent, and when
the books are due back, and any fines accrued.
What relations are necessary? What attributes
would they have? Design an ER diagram for the
Database.
18

You might also like