Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
DESIGNING DATABASE
APPLICATIONS
Copyright 2015 McGraw-Hill Education. All rights reserved. No reproduction or distribution without the prior written consent of McGraw-Hill Education.
LEARNING OUTCOMES
5-7
Entity Identifiers
5-9
Entity Identifiers
5-10
Attributes
5-11
Simple versus Composite
5-13
Single-Valued versus Multi-Valued
5-16
Stored versus Derived
5-17
Null-Valued
5-20
Basic Data Relationships
The
relationships
that are stored
in a database
are between
instances of
entities
5-21
Basic Data Relationships
5-23
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
5-24
Many-to-Many
5-25
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
5-26
Documenting Relationships The
Chen Method
The Chen method uses diamonds for
relationships and lines with arrows to
show the type of relationship between
entities
5-27
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
5-28
DEALING WITH MANY-TO-MANY
RELATIONSHIPS
There are problems with many-to-many
relationships
1. The relational data model cannot handle
many-to-many relationships directly
It is limited to one-to-one and one-to-many
relationships
Many-to-many relationships need to be replaced
with a collection of one-to-many relationships
2. Relationships cannot have attributes
An entity must represent the relationship
5-29
Composite Entities
5-31
Composite Entities
5-32
SCHEMAS
5-33
The Relational Data Model
5-35
Columns and Column
Characteristics
Two or more tables within the same relational
schema may have columns with the same
names
When the same column name appears in more
than one table and tables that contain that
column are used in the same data manipulation
operation
The name of the column must be qualified by
preceding it with the name of the table and a period
Example:
CUSTOMER.Customer Number, First Name, Last
Name, Phone Number
5-36
Rows and Row Characteristics
5-40
REPRESENTING DATA
RELATIONSHIPS
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)
5-41
Foreign Keys And Primary Keys In
The Same Table
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)
5-42
Referential Integrity
The relational data model enforces a constraint
called referential integrity
Referential integrity - states that every non-null foreign
key value must match an existing primary key value
Referential integrity ensures the consistency of
the cross-references among tables
Referential integrity constraints are stored in the
database that are enforced automatically by the
DBMS
5-43
The Data Dictionary
Data dictionary - a file that stores definitions of
information types, identifies the primary and foreign
keys, and maintains the relationships among the tables
The structure of a relational database is stored in the
database's data dictionary, or catalog
The data dictionary is made up of a set of relations,
identical in properties to the relations used to hold data
Information found in a data dictionary:
Definitions of the columns that make up each table
Integrity constraints placed on relations
Security information (which user has the right to perform which
operation of which table)
5-44
The Data Dictionary
5-45
RELATIONSHIPS AND BUSINESS
RULES
The correct design for a specific
business depends on the business rules
What is correct for one organization may not
be correct for another
Not a matter of right or wrong database
design, but an issue of how the business
operates
5-46
Normalization
5-48
NORMAL FORMS
Nested
normal
forms
5-49
First Normal Form (1NF)
5-51
Third Normal Form (3NF)