0% found this document useful (0 votes)
35 views

COMM 335 - Information Systems Technology and Development Database Design

Uploaded by

raymond
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
35 views

COMM 335 - Information Systems Technology and Development Database Design

Uploaded by

raymond
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 11

COMM 335 - Information Systems

Technology and Development Database Design

Winter 2019 – Term 1

© 2019 – Y.M. Cheung COMM 335 - Winter 2019 Term 1 1


© 2019 – Y.M. Cheung COMM 335 - Winter 2019 Term 1 2

Learning Objectives
Learning Objective 1
1. Design a relational database using
Entity Relationship Diagram (ERD)

2. Discuss the problems or anomalies caused by  Design a relational database using


unnormalized databases and the need for Data
Entity Relationship Diagram (ERD)
Normalization

© 2019 – Y.M. Cheung COMM 335 - Winter 2019 Term 1 3 © 2019 – Y.M. Cheung COMM 335 - Winter 2019 Term 1 4
Database Modeling Database Modeling (cont’d)

 Also called data modeling, is a technique  When designing a database, you can think of it as
used to develop an anomaly-free database three different realms (domain):
with database integrity.  Database designer
 Database builder
 A model is a representation of real objects,
 Database user
events, or systems.
 Most models are built using specific symbols.
 Models are used for understanding, analyzing,
and documenting real systems.

© 2019 – Y.M. Cheung COMM 335 - Winter 2019 Term 1 5 © 2019 – Y.M. Cheung COMM 335 - Winter 2019 Term 1 6

What is Entity Relationship


Database Modeling Notation Diagram (ERD)?

 Entity Relationship Diagram (ERD) depicts the


relationship among entities in the database.
 The ERD shows:
 Entities: Customer, Sales Order, Item

 Relationship between Entities: customer places an


order
 Relationship Cardinality: one-to-one (1:1), one-to-
many (1:M), or many-to-many (M:N).

© 2019 – Y.M. Cheung COMM 335 - Winter 2019 Term 1 7 © 2019 – Y.M. Cheung COMM 335 - Winter 2019 Term 1 8
Entity Relationship
Diagram (ERD) Database Entities
An order is  Entity: A person, object, event, or concept in
placed by only
one customer.
the user environment about which the
organization wishes to maintain data, e.g.
 Person : STUDENT, CUSTOMER
 Object : PRODUCT, BUILDING
 Event : SALE, REGISTRATION
A customer may  Concept : ACCOUNT, COURSE
place zero or
more orders.

© 2019 – Y.M. Cheung COMM 335 - Winter 2019 Term 1 9 © 2019 – Y.M. Cheung COMM 335 - Winter 2019 Term 1 10

Attributes Attributes in Ellipses

 Attribute: A property or characteristic of an


entity, e.g.
 CUSTOMER : CustomerNo, Name, Address, Phone
 EMPLOYEE: EmployeeID, Name, HireDate

 Originally shown in data models as ellipses.


 Data modeling products today commonly show
attributes in rectangular form.

© 2019 – Y.M. Cheung COMM 335 - Winter 2019 Term 1 11 © 2019 – Y.M. Cheung COMM 335 - Winter 2019 Term 1 12
Attributes in Entity Rectangle Entity Identifiers

 An attribute (or a combination of attributes) that


uniquely identifies an entity occurrence, e.g.
 CustomerNo of CUSTOMER entity.
 Identifiers in data models become candidate
keys in database design
 Entities have identifiers.
 Tables (or relations) have keys.
 The candidate key selected for identifying the
entity occurrence is the Primary key.

© 2019 – Y.M. Cheung COMM 335 - Winter 2019 Term 1 13 © 2019 – Y.M. Cheung COMM 335 - Winter 2019 Term 1 14

Entity Relationships Entity Relationships (cont’d)

 An Entity Relationship Diagram (ERD) shows


 For a single occurrence of one entity (one
the relationships among entities.
customer), cardinality defines the maximum
 Three different types of relationships among and minimum number of occurrences that
entities are: might relate to the other entity (sales orders).
 One-to-one relationships (1:1)  The name given to the relationship (one-to-
 One-to-many relationships (1:M) one, one-to-many, and many-to-many) refers to
 Many-to-many relationships (M:N) the maximum cardinalities.

© 2019 – Y.M. Cheung COMM 335 - Winter 2019 Term 1 15 © 2019 – Y.M. Cheung COMM 335 - Winter 2019 Term 1 16
Entity Relationship Diagram (ERD)
with Crow’s Feet Symbols How To Build an ERD

 Step 1: Determine the relevant business transactions


Step 1: What is the maximum number Step 3: What is the maximum number of
of orders a customer can place? customers who can place a specific
that the organization must support.
Many order? One
 Step 2: Determine the business rules for a specific
business transaction.
 Step 3: Determine business entities and the
Step 4: What is the minimum number of relationship among them.
Step 2 What is the minimum number customers who can place a specific
of orders a customer can place? Zero order? One  Step 4: Determine the entity identifier(s) for each
entity.
 Step 5: Draw entity relationship diagram.

© 2019 – Y.M. Cheung COMM 335 - Winter 2019 Term 1 17 © 2019 – Y.M. Cheung COMM 335 - Winter 2019 Term 1 18

ERD Relationship
How To Build an ERD (cont’d) Cardinality Symbols

 Step 6: Optimize the entity relationship diagram by


removing many-to-many relationships.

 Step 7: Add business-related attributes to the entity


relationship diagram.

 Step 8: Implement relationships.

 Step 9: Develop relational database tables.

 Step 10: Build relational database tables.

© 2019 – Y.M. Cheung COMM 335 - Winter 2019 Term 1


19

© 2019 – Y.M. Cheung COMM 335 - Winter 2019 Term 1

One-to-Many Relationship Use Intersection Table to Remove


Possibilities Many-to-Many Relationships

Intersection
Table

© 2019 – Y.M. Cheung COMM 335 - Winter 2019 Term 1 21 © 2019 – Y.M. Cheung COMM 335 - Winter 2019 Term 1 22

EspressoCoffee Sales Transaction


ERD with Foreign Keys Conceptual Database Tables
© 2019 – Y.M. Cheung COMM 335 - Winter 2019 Term 1 23 © 2019 – Y.M. Cheung COMM 335 - Winter 2019 Term 1 24

From the ER Diagram to the


In-Class Exercise One Relational Database

 Draw an ER diagram to represent the following description:


ER Diagram Database
 A professor may teach a minimum of zero and a maximum of
three classes. Entities Tables
 The minimum number of professors required to teach a class is Attributes Columns/Fields
one, as is the maximum number of professors.
 A class may contain no students at all or that up to thirty One-to-many Primary key to foreign key of the
students may be enrolled. child table
 A student must take at least one class but no more than five
Many-to-many 3 tables: 2 parent tables and an
classes
intersection table
 You should specify all the elements including entities,
attributes, relationships, and cardinality.

© 2019 – Y.M. Cheung COMM 335 - Winter 2019 Term 1 25 © 2019 – Y.M. Cheung COMM 335 - Winter 2019 Term 1 26

In-Class Exercise Two Learning Objective 2

 Translate the ER diagram in the previous


exercise to the relational database design.
 Discuss the problems or anomalies
 You should include all columns and specify caused by unnormalized databases and
the primary and foreign keys. the need for Data Normalization

Solutions will be discussed in class.


© 2019 – Y.M. Cheung COMM 335 - Winter 2019 Term 1 27 © 2019 – Y.M. Cheung COMM 335 - Winter 2019 Term 1 28

Database Integrity Database Integrity (cont’d)

 Database Integrity refers to the database  Rule 3. Domain Integrity. The field values must be
from a predefined domain.
containing accurate, valid and complete data.
o For example, the Date field must have a date and not any
other values.
 Rule 1. Entity Integrity. Each record in the database
must have a unique identifier (i.e. a unique primary  Rule 4. Referential Integrity. Data referenced and
key). No two records in the database table can have stored in related tables must be consistent across the
the same primary key value. database.
o For example, a customer address should be the same in
 Rule 2. Primary Key Integrity. The primary key value any table in which it is referenced. Referential integrity is
cannot be null (empty). Each record must have a value improved when the customer address is stored in one
location only.
for the primary key field. Details to be covered
in the Tutorials.

© 2019 – Y.M. Cheung COMM 335 - Winter 2019 Term 1 29 © 2019 – Y.M. Cheung COMM 335 - Winter 2019 Term 1 30

Database Anomalies Deletion Anomalies


 Database anomalies are three types of problems in
 Deletion problem. Deleting Vincent as a customer will
database tables:
cause the deletion of four records. These four records
1. Deletion Problem. Deleting one record (customer) causes hold vital information about four orders and four items.
deletion of other records.
2. Update Problem. Updating one field (address) requires updating
multiple fields.
3. Insertion Problem. Inserting a new field (customer) is problematic
because the primary key is null.
© 2019 – Y.M. Cheung COMM 335 - Winter 2019 Term 1 31 © 2019 – Y.M. Cheung COMM 335 - Winter 2019 Term 1 32
Update Anomalies Insertion Anomalies

 Update problem. To update Vincent’s customer


address, four records would need to be updated.
What happens if one of these
four records is not updated?

 Insertion problem. To identify a unique record, we have to


use the customer number, order number, and item number.
That means these three fields together form the primary key.
If we want to insert a new customer who hasn’t placed an order
yet, then the order number and item number fields would be
empty.
This violates database integrity Rule No 2:
The Primary Key Value Cannot Be Null.)

© 2019 – Y.M. Cheung COMM 335 - Winter 2019 Term 1 33 © 2019 – Y.M. Cheung COMM 335 - Winter 2019 Term 1 34

Accountants and Data


Anomaly-Free Databases Normalization

 A well-designed  Update anomalies can generate conflicting and


database is free of obsolete database values.
Deletion, Update,  Insertion anomalies can result in unrecorded
and Insertion
transactions and incomplete audit trails.
(DUI) anomalies.
 Deletion anomalies can cause the loss of
 Database
anomalies are accounting records and the destruction of audit
removed through trails.
a process called
Accountants should understand data normalization and
Normalization
be able to determine whether a database is properly
and/or database
normalized.
design modeling.
© 2019 – Y.M. Cheung COMM 335 - Winter 2019 Term 1 35 © 2019 – Y.M. Cheung COMM 335 - Winter 2019 Term 1 36

You might also like