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

Chapter 6 Database Design

The chapter discusses transforming data models into database designs. It covers topics such as creating tables, selecting primary keys, specifying column properties, creating relationships between tables, and representing different types of relationships.

Uploaded by

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

Chapter 6 Database Design

The chapter discusses transforming data models into database designs. It covers topics such as creating tables, selecting primary keys, specifying column properties, creating relationships between tables, and representing different types of relationships.

Uploaded by

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

David M. Kroenke and David J.

Auer
Database Processing
Fundamentals, Design, and Implementation

Chapter 6
Database Design
Chapter Objectives
• To understand how to transform data models into
database designs
• To be able to identify primary keys and understand when
to use a surrogate key
• To understand the use of referential integrity constraints
• To understand the use of referential integrity actions
• To be able to represent ID-dependent, 1:1, 1:N, and N:M
relationships as tables
• To be able to represent weak entities as tables

KROENKE AND AUER - DATABASE PROCESSING, 15th Edition 6-2


© 2019 Pearson Education, Inc.
Chapter Objectives
• To be able to represent supertypes/subtypes as tables
• To be able to represent recursive relationships as tables
• To be able to implement referential integrity actions
required by minimum cardinalities

KROENKE AND AUER - DATABASE PROCESSING, 15th Edition 6-3


© 2019 Pearson Education, Inc.
Steps for Transforming a
Data Model into a Database Design

KROENKE AND AUER - DATABASE PROCESSING, 15th Edition 6-4


© 2019 Pearson Education, Inc.
Create a Table for Each Entity
EMPLOYEE (EmployeeNumber, EmployeeName, Phone,
Email, HireDate, ReviewDate, EmpCode)

Primary key is
designated by
the key symbol

Note
shadowless
table

KROENKE AND AUER - DATABASE PROCESSING, 15th Edition © 6-5


2019 Pearson Education, Inc.
Select the Primary Key
• The ideal primary key
is short, numeric, and
fixed.
• Surrogate keys meet
the ideal, but have no
meaning to users.

KROENKE AND AUER - DATABASE PROCESSING, 15th Edition © 6-6


2019 Pearson Education, Inc.
Specify Candidate (Alternate) Keys
• The terms candidate key and alternate
key are synonymous.
• Candidate keys are alternate identifiers of
unique rows in a table.
• Will use AKn.m notation, where n is the
number of the alternate key, and m is the
column number in that alternate key.

KROENKE AND AUER - DATABASE PROCESSING, 15th Edition 6-7


© 2019 Pearson Education, Inc.
Specify Candidate (Alternate) Keys

KROENKE AND AUER - DATABASE PROCESSING, 15th Edition 6-8


© 2019 Pearson Education, Inc.
Specify Column Properties:
Null Status
• Null status indicates
whether or not the
value of the column
can be NULL.

KROENKE AND AUER - DATABASE PROCESSING, 15th Edition © 6-9


2019 Pearson Education, Inc.
Specify Column Properties:
Data Type
• Generic data types:
– CHAR(n)
– VARCHAR(n)
– DATE
– TIME
– MONEY
– INTEGER
– DECIMAL

KROENKE AND AUER - DATABASE PROCESSING, 15th Edition © 6-10


2019 Pearson Education, Inc.
Specify Column Properties:
Data Type + Null Status

KROENKE AND AUER - DATABASE PROCESSING, 15th Edition © 6-11


2019 Pearson Education, Inc.
Specify Column Properties:
Data Constraints
• Data constraints are limitations on data values:
– Domain constraint—column values must be in a
given set of specific values.
– Range constraint—column values must be within a
given range of values.
– Intrarelation constraint—column values are limited
by comparison to values in other columns in the same
table.
– Interrelation constraint—column values are limited
by comparison to values in other columns in other
tables (referential integrity constraints on foreign
keys).

KROENKE AND AUER - DATABASE PROCESSING, 15th Edition 6-12


© 2019 Pearson Education, Inc.
Verify Normalization
• The tables should be normalized based on
the data model.
• Verify that all tables are:
– BCNF
– 4NF

KROENKE AND AUER - DATABASE PROCESSING, 15th Edition 6-13


© 2019 Pearson Education, Inc.
Create Relationships:
1:1 Strong Entity Relationships
• Place the key of one entity in the other
entity as a foreign key.
– Either design will work—no parent, no child
– Minimum cardinality considerations may be
important.
• O-M will require a different design than M-O.
• One design will be very preferable.

KROENKE AND AUER - DATABASE PROCESSING, 15th Edition 6-14


© 2019 Pearson Education, Inc.
Create Relationships:
1:1 Strong Entity Relationships

KROENKE AND AUER - DATABASE PROCESSING, 15th Edition 6-15


© 2019 Pearson Education, Inc.
Create Relationships:
1:N Strong Entity Relationships
• Place the primary key of the table on the
one side of the relationship into the table
on the many side of the relationship as the
foreign key.
• The one side is the parent table and the
many side is the child table, so “place the
key of the parent in the child.”

KROENKE AND AUER - DATABASE PROCESSING, 15th Edition 6-16


© 2019 Pearson Education, Inc.
Create Relationships:
1:N Strong Entity Relationships

KROENKE AND AUER - DATABASE PROCESSING, 15th Edition 6-17


© 2019 Pearson Education, Inc.
Create Relationships:
N:M Strong Entity Relationships
• In an N:M strong entity relationship there is no
place for the foreign key in either table.
– A COMPANY may supply many PARTs.
– A PART may be supplied by many COMPANYs.

KROENKE AND AUER - DATABASE PROCESSING, 15th Edition © 6-18


2019 Pearson Education, Inc.
Create Relationships:
N:M Strong Entity Relationships
• The solution is to create an intersection table
that stores data about the corresponding rows
from each entity.
• The intersection table consists only of the
primary keys of each table which form a
composite primary key.
• Each table’s primary key becomes a foreign key
linking back to that table.
COMPANY_PART_INT (CompanyName, PartNumber)

KROENKE AND AUER - DATABASE PROCESSING, 15th Edition 6-19


© 2019 Pearson Education, Inc.
Create Relationships:
N:M Strong Entity Relationships
COMPANY_PART_INT (CompanyName, PartNumber)

KROENKE AND AUER - DATABASE PROCESSING, 15th Edition © 6-20


2019 Pearson Education, Inc.
Relationships Using ID-Dependent Entities:
Four Uses for ID-Dependent Entities
• Representing N:M Relationships
– We just discussed this
• Association Relationships
• Multivalued Attributes
• Archetype/Instance Relationships

KROENKE AND AUER - DATABASE PROCESSING, 15th Edition 6-21


© 2019 Pearson Education, Inc.
Relationships Using ID-Dependent Entities:
Association Relationships
• An intersection table
– Holds the relationships between two strong entities in
an N:M relationship
– Contains only the primary keys of the two entities:
• As a composite primary key
• As foreign keys
• An association table
– Has all the characteristics of an intersection table
– PLUS it has one or more columns of attributes
specific to the associations of the other two entities

KROENKE AND AUER - DATABASE PROCESSING, 15th Edition 6-22


© 2019 Pearson Education, Inc.
Relationships Using ID-Dependent Entities:
Association Relationships
QUOTATION (CompanyName, PartNumber, Price)

KROENKE AND AUER - DATABASE PROCESSING, 15th Edition © 6-23


2019 Pearson Education, Inc.
Relationships Using ID-Dependent Entities:
Multivalued Attributes

As a data model As a database


design

KROENKE AND AUER - DATABASE PROCESSING, 15th Edition 6-24


© 2019 Pearson Education, Inc.
Relationships Using ID-Dependent Entities:
Archetype/Instance Pattern

As a data model As a database


design

KROENKE AND AUER - DATABASE PROCESSING, 15th Edition 6-25


© 2019 Pearson Education, Inc.
Relationships Using Weak Entities:
Archetype/Instance Pattern

As a data model As a database


design

KROENKE AND AUER - DATABASE PROCESSING, 15th Edition 6-26


© 2019 Pearson Education, Inc.
Mixed Entity Relationships

As a
As a data database
model design

KROENKE AND AUER - DATABASE PROCESSING, 15th Edition 6-27


© 2019 Pearson Education, Inc.
Mixed Entity Relationships:
The SALES_ORDER Pattern

As a data model

KROENKE AND AUER - DATABASE PROCESSING, 15th Edition 6-28


© 2019 Pearson Education, Inc.
Mixed Entity Relationships:
The SALES_ORDER Pattern

As a database
design

KROENKE AND AUER - DATABASE PROCESSING, 15th Edition 6-29


© 2019 Pearson Education, Inc.
Subtype Relationships
As a data As a
model database
design

KROENKE AND AUER - DATABASE PROCESSING, 15th Edition 6-30


© 2019 Pearson Education, Inc.
Recursive Relationships:
1:1 Recursive Relationships
As a data As a
model database
design

KROENKE AND AUER - DATABASE PROCESSING, 15th Edition 6-31


© 2019 Pearson Education, Inc.
Recursive Relationships:
1:N Recursive Relationships
As a data As a
model database
design

KROENKE AND AUER - DATABASE PROCESSING, 15th Edition 6-32


© 2019 Pearson Education, Inc.
Recursive Relationships:
N:M Recursive Relationships
As a data As a
model database
design

KROENKE AND AUER - DATABASE PROCESSING, 15th Edition 6-33


© 2019 Pearson Education, Inc.
Design for Minimum Cardinality
• Relationships can have the following types of
minimum cardinality:
– O-O: parent optional and child optional
– M-O: parent mandatory and child optional
– O-M: parent optional and child mandatory
– M-M: parent mandatory and child mandatory
• We will use the term action to mean a
minimum cardinality enforcement action.
• No action needs to be taken for O-O
relationships.

KROENKE AND AUER - DATABASE PROCESSING, 15th Edition 6-34


© 2019 Pearson Education, Inc.
David Kroenke and David Auer
Database Processing
Fundamentals, Design, and Implementation
(13th Edition)

End of Presentation

KROENKE AND AUER - DATABASE PROCESSING, 15th Edition 6-35


© 2019 Pearson Education, Inc.
All rights reserved. No part of this publication may be reproduced, stored in a
retrieval system, or transmitted, in any form or by any means, electronic,
mechanical, photocopying, recording, or otherwise, without the prior written
permission of the publisher. Printed in the United States of America.

KROENKE AND AUER - DATABASE PROCESSING, 15th Edition 6-36


© 2019 Pearson Education, Inc.

You might also like