Appendix C
Appendix C
DESIGNING
DATABASES
© 2014 by McGraw-Hill Education. This is proprietary material solely for authorized instructor
use. Not authorized for sale or distribution in any manner. This document may not be copied,
scanned, duplicated, forwarded, distributed, or posted on a website, in whole or part.
2
INTRODUCTION
The core chapters introduced:
• Database - maintains information about various types
of objects (inventory), events (transactions), people
(employees), and places (warehouses)
Attributes
There are several types of attributes
including:
• Simple versus composite
• Single-valued versus multi-valued
• Stored versus derived
• Null-valued
7
Null-Valued
Null-valued attribute – Assigned to an
attribute when no other value applies or
when a value is unknown
Example: A person who does not have a
mobile phone would have null stored at
the value for the Mobile Phone Number
attribute
14
DOCUMENTING ENTITY-
RELATIONSHIP DIAGRAMS
The two most commonly used styles of ERD
notation are:
1. Chen
2. Information Engineering
The Chen model uses rectangles to represent
entities
• Each entity's name appears in the rectangle
and is expressed in the singular, as in
CUSTOMER
• Attributes are expressed in ovals
15
One-to-One
One-to-one (1:1) – A relationship
between two entities in which an instance
of entity A can be related to only one
instance of entity B and entity B can be
related to only one instance of entity A
19
One-to-Many
One-to-many (1:M) – A relationship between two
entities, in which an instance of entity A, can be
related to zero, one, or more instances of entity B
and entity B can be related to only one instance of
entity A
20
Many-to-Many
Many-to-many (M:N) – A relationship
between two entities in which an instance
of entity A can be related to zero, one, or
more instances of entity B and entity B
can be related to zero, one, or more
instances of entity A
21
Documenting Relationships –
The Chen Method
The Chen method uses diamonds for
relationships and lines with arrows to
show the type of relationship between
entities
22
Documenting Relationships –
The Chen Method
There is no obvious way to indicate weak
entities and mandatory relationships
• An ORDER should not exist in the database without
a CUSTOMER
• ORDER is a weak entity and its relationship with a
CUSTOMER is mandatory
• Some database designers have added a new symbol
to the Chen method for a weak entity, a double-
bordered rectangle
23
Composite Entities
Composite entities - Entities that exist to
represent the relationship between two
other entities
Example:
• There is a many-to-many relationship
between an ITEM and an ORDER
An ORDER can contain many ITEM(s) and over
time, the same ITEM can appear on many
ORDER(s)
25
Composite Entities
26
Composite Entities
27
RELATIONSHIP CONNECTIVITY
AND CARDINALITY
Cardinality - expresses the specific number of entity
occurrences associated with one occurrence of the
related entity
In the Chen model, the cardinality is indicated by placing
numbers beside the entities in the format of (x, y)
• The first number is the minimum value and the
second number is the maximum value
28
Example:
• CUSTOMER.Customer Number, First Name, Last
Name, Phone Number
32
LOGICALLY RELATING
TABLES
The use of
identifiers
represent
relationships
between
entities
36
LOGICALLY RELATING
TABLES
When a table contains a column that is the
same as the primary key of a table, the column
is called a foreign key
Foreign key - A primary key of one table that
appears as an attribute in another file and acts
to provide a logical relationship between the two
files
Example:
• CUSTOMER(Customer Number, First Name, Last Name,
Phone Number)
• ORDER(Order Number, Customer Number, Order Date)
37
LOGICALLY RELATING
TABLES
Foreign keys do not necessarily need to
reference a primary key in a different table
• They need only reference a primary key
Example:
• EMPLOYEE(Employee Number, First Name,
Last Name, Department, Manager Number)