Beruflich Dokumente
Kultur Dokumente
Indeed your Lord knows that you stand up in prayer, sometimes almost two-thirds of the night, and sometimes
half the night or sometimes a third of it – and also a group of those along with you; Allah keeps measure of the
night and day; He knows that you, O Muslims, will not be able to measure the night, so He has inclined towards
you with mercy – therefore recite from the Qur’an as much as is easy for you; He knows that soon some of you
will fall ill, and some will travel in the land seeking the munificence of Allah, and some will be fighting in Allah’s
cause; therefore recite from the Qur’an as much as is easy for you, and establish prayer and pay the obligatory
charity, and lend an excellent loan to Allah; and whatever good you send ahead for yourselves, you will find it
with Allah, better and having a great reward; and seek forgiveness from Allah; indeed Allah is Oft Forgiving,
Most Merciful.
DATA MODELLING
Data Modeling
Conceptual Data
Business Rules
Modeling
3
Chapter 3
BUSINESS RULES
Statements that define or constrain some
aspect of the business
Examples:
Every student in the university must have one or
more faculty advisors
Every student in the university must be assigned
to one discipline only.
Is this a business rule?
A student is any person who has applied for
admission or taken a course or training program 4
from any credit or noncredit unit of the university.
Chapter 3
CONCEPTUAL MODELING
Entity-Relationship Model
A logical representation of data for an
organization
Expressed in terms of entities, attributes and
relationships
Entity-Relationship Diagram
A graphical representation of an entity-
relationship model
Chapter 3
E-R MODEL CONSTRUCTS
Entities:
Entity instance–person, place, object, event, concept (often
corresponds to a row in a table)
Entity Type–collection of entities (often corresponds to a
table)
Relationships:
Relationship instance–link between entities (corresponds to
primary key-foreign key equivalencies in related tables)
Relationship type–category of relationship…link between
entity types
Chapter 3
Sample E-R Diagram (Figure 3-1)
Chapter 3
CLASS ACTIVITY
Write business rules for the following ERD
Chapter 3
SOLUTION (CLASS ACTIVITY)
A CUSTOMER may submit any number of ORDERs.
However, each ORDER must be submitted by exactly
one CUSTOMER.
Chapter 3
WHAT SHOULD AN ENTITY BE?
SHOULD BE:
An object that will have many instances in the database
An object that will be composed of multiple attributes
An object that we are trying to model
SHOULD NOT BE:
A user of the database system
An output of the database system (e.g., a report)
10
Chapter 3
Figure 3-4 Example of inappropriate entities
System System
user Inappropriate output
entities
Appropriate
entities
11
Chapter 3
DIFFERENCE BETWEEN
CONCEPTUAL, LOGICAL AND
PHYSICAL DATA MODEL
CONCEPTUAL DATA MODEL
A conceptual data model identifies the highest-
level relationships between the different entities.
Features of conceptual data model include:
Includes the important entities and the
relationships among them.
No attribute is specified.
Comparing the physical data model with the logical data model, we see the
main differences between the two:
Entity names become table names.
Attributes become column names.
Data type for each column is specified. Data types can be different depending on the
actual database being used.
Chapter 3
DIFFERENCE BETWEEN CONCEPTUAL, LOGICAL
AND PHYSICAL DATA MODEL
Feature Conceptual Logical Physical
Entity Names ✓ ✓
Entity Relationships ✓ ✓
Attributes ✓
Primary Keys ✓ ✓
Foreign Keys ✓ ✓
Table Names ✓
Column Names ✓
Chapter 3
1
7
Chapter 3
1
8
A RELATION
Chapter 3
1
9
KEY FIELDS
Chapter 3
KEYS
Super Key − A set of attributes (one or more)
that collectively identifies an entity in an entity
set.
Candidate Key − A minimal super key is called
a candidate key. An entity set may have more
than one candidate key.
21
Chapter 3
Entity Sets, Attributes, Relationship Notation
Entity
Attribute
symbols
symbols
A special entity
that is also a Relationship
relationship symbols
Relationship
degrees specify
number of
entity types Relationship
involved cardinalities
specify how
many of each
entity type
22 is
allowed
Chapter 3
ATTRIBUTES
Attribute–property or characteristic of an entity or
relationship type
Classifications of attributes:
Required versus Optional Attributes
Simple versus Composite Attribute
Single-Valued versus Multivalued Attribute
Stored versus Derived Attributes
Identifier Attributes
23
Chapter 3
Figure 3-7 A composite attribute
An attribute
broken into
component parts
Multivalued
an employee can have
Derived
more than one skill
from date
employed24and
current date
Chapter 3
IDENTIFIERS (KEYS)
Identifier (Key)–An attribute (or
combination of attributes) that uniquely
identifies individual instances of an entity
type
Simple versus Composite Identifier
Candidate Identifier–an attribute that
could be a key…satisfies the requirements
for being an identifier
25
Chapter 3
Figure 3-9 Simple and composite identifier attributes
26
Chapter 3
CHARACTERISTICS OF IDENTIFIERS
27
Chapter 3
EXAMPLE
Classify the following Classifications of
attributes: attributes:
First Name Required versus Optional
Full Name Attributes
Years Employed Simple versus Composite
Attribute
Race
Single-Valued versus
Roll no
Multivalued Attribute
Hobbies
Stored versus Derived
Date Employed Attributes
Password Identifier Attributes
Today’s Date
Last Name
28
Chapter 3
SOLUTION
Classifications the following attributes:
First Name – Simple, Required
Full Name – Composite (FirstName. LastName)
[Years Employed] – Derived (DateEmployed, Today’s Date)
Race -- Simple
Roll no – Identifier
{Hobbies} – Multivalued, Optional
Date Employed -- Simple
Password – Simple, Required
Today’s Date – Simple(Can be composite if dd-mm-yyyy)
Last Name -- Simple
29
Chapter 3
Logical Data Model: Mapping a regular entity
(a) CUSTOMER
entity type with
simple
attributes
30
Chapter 3
Logical Data Model: Mapping a composite attribute
(a) CUSTOMER
entity type with
composite
attribute
31
Chapter 3
3
2 Logical Data Model: Mapping an entity with a multivalued attribute
(a)
33
Chapter 3
Figure 3-10 Relationship types and instances
a) Relationship type
b) Relationship
instances
34
Chapter 3
CARDINALITY OF RELATIONSHIPS
One-to-One
One-to-Many
Many-to-Many
35
Chapter 3
CARDINALITY CONSTRAINTS
36
Chapter 3
Figure 3-17 Examples of cardinality constraints
a) Mandatory cardinalities
Chapter 3
Figure 3-17 Examples of cardinality constraints (cont.)
Chapter 3
Figure 3-17 Examples of cardinality constraints (cont.)
a) Optional cardinalities
A person is is
married to at most
one other person,
or may not be
married at all
39
Chapter 3
Figure 3-21 Examples of multiple relationships
40
Chapter 3
Logical Data Model: Example of mapping a binary 1:1 relationship
a) In_charge relationship (1:1)
41
Chapter 3
Logical Data Model: Example of mapping a binary 1:1 relationship (cont.)
b) Resulting relations
Chapter 3
Logical Data Model: Example of mapping a 1:M relationship
a) Relationship between customers and orders
Chapter 3
DEGREE OF RELATIONSHIPS
Degree of a relationship is
the number of entity types
that participate in it
Unary Relationship
Binary Relationship
Ternary Relationship
44
Chapter 3
Degree of relationships – from Figure 3-2
Entities of
One entity two different
related to types related
another of to each other Entities of three
the same different types
entity type related to each 45
other
Chapter 3
Figure 3-12 Examples of relationships of different degrees
a) Unary relationships
46
Chapter 3
Logical Data Model: Mapping a unary 1:N relationship
(b) EMPLOYEE
relation with
recursive foreign
key
47
Chapter 3
4
8 Logical Data Model: Mapping a unary M:N relationship
(a) Bill-of-materials
relationships (M:N)
Chapter 3
Figure 3-12 Examples of relationships of different degrees (cont.)
b) Binary relationships
49
Chapter 3
Figure 3-12 Examples of relationships of different degrees (cont.)
c) Ternary relationship
A ternary relationship is a simultaneous relationship among the instances of three entity types. A typical
business situation that leads to a ternary relationship is shown in Figure. In this example, vendors can supply
various parts to warehouses. The relationship Supplies is used to record the specific parts that are supplied by
a given vendor to a particular warehouse. Thus there are three entity types: VENDOR, PART, and 50
WAREHOUSE
Chapter 3
Figure 5-14 Example of mapping a binary 1:1 relationship
a) In_charge relationship (1:1)
51
Chapter 3
ogical Data Model: Example of mapping a binary 1:1 relationship (con
b) Resulting relations
Chapter 3
Logical Data Model: Mapping a ternary relationship
53
Chapter 3
Logical Data Model: Mapping a ternary relationship (cont
55
Chapter 3
Identifying relationship
Chapter 3 56
Logical Data Model: Example of mapping a weak entity
Foreign key
Chapter 3
Example : Mapping E-R to Logical Data Model
Schema for four relations (Pine Valley Furniture Company)
Primary Key
Foreign Key
(implements 1:N relationship
between customer and order)
58
Class Activity :Draw E-R Diagram for the given scheema
Chapter 3
ASSOCIATIVE ENTITY (COMPOSITE
ENTITY / GERUND)
Chapter 3 59
To create a relationship, a "child" entity must inherit
the primary key of a "parent" entity. However, in a
many-to-many relationship, neither entity is the
"parent" or the "child"; the relationship is
"unresolved". In order to work, these databases
require an additional construct to "resolve" the
relationship (which is why associative entities are
also referred to as "resolving entities").
An associative entity can be thought of as both an
entity and a relationship since it encapsulates
properties from both. It is a relationship since it is
serving to join two or more entities together, but it is
also an entity since it may have its own properties.
The associative entity must have the primary keys of
both adjoining tables as identifiers, but may also
contain its own unique identifier and other 60
information
Chapter 3 about the relationship.
The following guidelines may be used when considering
the use of an associative entity:
All relationships for the associative entity should be many.
The associative entity could have meaning independent of
the other entities.
The associative entity should not have an additional
identity column. The primary key should be a composite of
the primary keys from the referenced entities. If the
association is temporal, the transaction time may also be
part of this composite key. If other entities will be
referencing the associative entity and the composite of the
referenced primary keys creates a large byte width for the
associative entity's primary key, an exception may be made
for this rule and an identity column may be added and used
as the primary key.
Chapter 3 61
Physical data model: of mapping an M:N relationship
a) Completes relationship (M:N)
Chapter 3
Physical data model: Example of mapping an M:N relationship (cont.)
63
Chapter 3
Physical data model: Example of mapping an associative entity
a) An associative entity
64
Chapter 3
Physical data model: Example of mapping an associative entity (cont.)
Chapter 3
Physical data model: Example of mapping an associative entity wi
an identifier
a) SHIPMENT associative entity
66
Chapter 3
Physical data model: Example of mapping an associative entity wi
an identifier (cont.)
b) Three resulting relations
Section C
67
Chapter 3
CASE STUDY (DRAW E-R DIAGRAM)
Major airlines companies that provide passenger services in Taiwan are: UniAir,
TransAsia Airways, Far Eastern Transport, Great China Airlines etc. Taiwan’s
Federal Aviation Administration (TFAA) keeps a database with lots of information
on all airlines. This information is made accessible to all airlines in Taiwan with the
intention of helping the Companies assess their Competitive position in the domestic
market. The information kept consists of:
Each airline has an identification number, name of the contact person and telephone
number.
For each aircraft identification number, capacity and model is recorded.
Each employee has an employee identification number, name, address, birthday, sex,
position with the company and qualification.
Each airline keeps information about their buy/sell transactions (for example, selling an
airplane ticket is a sell transaction, paying for maintenance is a buy transaction). Each
transaction has a transaction identification number, date, description and amount of
money paid/received. Also Each Airline must have one or more employees. As far as
aircraft is concerned, one aircraft can be assigned to more than one airline as per flight
schedule / Route and one Airline can have multiple aircraft assigned at a particular
time.
(Assumption: one Airline can have multiple aircraft assigned at a particular time as its
not for a single airport. However airport enity should not be included while designing
ER)
Chapter 3 68
SOLUTION HINT
Airline – Transaction 1 to M
Airline – Employee 1 to M
Airline – Aircraft M to M
Associative Entity (Route)
69
Chapter 3
PHYSICAL DATA MODELLING
70 Introduction to Terms: Implementation will be
covered in LAB
7
1
Chapter 3
7
2
DESIGNING FIELDS
Chapter 3
7
3
NUMBER–positive/negative number
DATE–actual date
74
Chapter 3
7
5
Chapter 3
7
6
BASIC DEFINITIONS
Physical Record: A group of fields stored in adjacent
memory locations and retrieved together as a unit
Page: The amount of data read or written in one I/O
operation
Blocking Factor: The number of physical records
per page
Chapter 3