Professional Documents
Culture Documents
Database Design
Electronic Presentation
20000GC13
Production 1.3
August 2002
D37098
Christine Markusic The information in this document is subject to change without notice. If you find any problems in the
documentation, please report them in writing to Education Products, Oracle Corporation, 500 Oracle
Parkway, Box, Redwood Shores, CA 94065. Oracle International Corporation does not warrant that
this document is error-free.
Oracle is a registered trademark and Oracle, SQL*Plus, SQL*Net, Oracle Developer, Oracle8i,
Oracle9i, Oracle9i Designer and PL/SQL are trademarks or registered trademarks of Oracle
Corporation.
All other products or company names are used for identification purposes only and may be
trademarks of their respective owners.
defined by applied to
part of
ORGANIZATION
o EMAIL
* NAME
• Models business,
o POSTAL CODE
at o
o
REGION
STREET
o TOWN parent organization o
o TELEPHONE NUMBER
TITLE MOVIE o CONTACT NAME
# PRODUCT CODE* CATEGORY o CONTACT EXTENSION
* TITLE o AGE RATING
o DESCRIPTION * DURATION the
* MONOCHROME GAME
not implementation
o AUDIO * CATEGORY
o PREVIEW SUPPLIER
* MEDIUM
o MINIMUM MEMOR # SUPPLIER CODE
o EMAIL
available * APPROVED
for * REFERENCE
PRICE HISTORY
the source of
# EFFECTIVE DATE reviewed inavailable as on
* PRICE
* DEFAULT DAYS
* OVERDUE RATE
• Is a well-established
OTHER ORGANIZATION
PUBLICATION
# REFERENCE
* TITLE
CATALOG the holder o
# REFERENCE
technique
o VOLUME o CATALOG DAT
o ISSUE o DESCRIPTION CUSTOMER
o PUBLISH DATE
managed by o EMAIL
* DESIGNATION
EMPLOYEE the manager o * FIRST NAME
the source of the source of * POSITION
* LAST NAME
o OTHER INITIALS
* LAST NAME * STREET
o FIRST NAME * TOWN
o OTHER INITIALS * POSTAL CODE
o EMAIL * REGION
o HOME PHONE
COPY
* ACQUIRE DATE
* PURCHASE COST
* SHELF CODE
the holder of
o CONDITION
o CUSTOMER REMARKS
responsible for
• Results in easy-to-read
MEMBERSHIP TYPE
...
# CODE
* DESCRIPTION
rented on reserved on * DISCOUNT PERCENTAGE
o STANDARD FEE
diagrams… REVIEW
in
# SEQUENCE
* ARTICLE
in
of
MEMBERSHIP
# NUMBER
held by
o TERMINATION REASON
of
o TERMINATION DATE
* HOT
o AUTHOR
approved by
o URL
renewed fo used fo
the reservation for r r
cancelled by
for
RENTAL
* RENTAL DATE
o STAFF REMARKS
o COMPLETED
for
part of
RENTAL ITEM
# LINE NO
* RENTAL PERIOD
* PRICE PAID
o RETURN DATE
o STAFF REMARKS
ER Model
Hierarchical Network
Relational
• An Entity is:
– “Something” of significance to the business about
which data must be known
– A name for the things that you can list
– Usually a noun
• Examples: objects, events
• Entities have instances
JOB
manager
cook
waitress
dish washer
financial controller
porter
waiter
piano player
Entity Attribute
EMPLOYEE Family Name, Age, Shoe Size,
Town of Residence, Email, ...
CAR Model, Weight, Catalog Price, …
ORDER Order Date, Ship Date, …
JOB Title, Description, ...
TRANSACTION Amount, Transaction Date, …
EMPLOYMENT Start Date, Salary, ...
CONTRACT
Numerical observation:
• All EMPLOYEES have a JOB
• No EMPLOYEE has more than one JOB
• Not all JOBS are held by an EMPLOYEE
• Some JOBS are held by more than one EMPLOYEE
ELECTION
• Name singular
• Name inside
• Neither size,
TICKET
nor position RESERVATION
ORDER
has a special
meaning JOB ASSIGNMENT
EMPLOYEE JOB
has
held by
has
JOB
EMPLOYEE
held by
mandatory: optional:
mandatory: optional:
held by
mandatory: optional:
held by
mandatory: optional:
held by
P split into Q
part of
P split into Q
part of
P split into Q
part of
P split into Q
part of
København 1/-5 3
Bremen 0/-3 4
Berlin 3/-1 3
München 5/-3 3
****
Amsterdam 8/3 4
Bruxelles 4/0 2
Paris 4/1 3
Bordeaux 7/2 3
FR
CH
Bordeaux IT
CITY COUNTRY
* Name located in * Name
o Geographical o Geographical
Position having Position
subject
of
about
Entity
Attribute ** **
o
Relationship
Subtype
Unique identifier
Arc
Nontransferability
#o #
• Instance or Entity
• Guest
• Reading
• Hotel
• Recipe
Address
Arrival Date
GUEST Family Name
HOTEL Room Number
ROOM Floor Number
Number of Beds
Number of Parking Lots
Price
TV set available?
living in
home town of
visitor of
visited by
mayor of
with mayor
HOTEL
* Address
with
in in guest in
STAY of PERSON
* Arrival Date * Name
with
Soups
Açorda alentejana
bread soup from Portugal
vegetarian For 4 persons:
15 min
1 onion
easy 4 cloves of garlic
1 red pepper
1 liter of vegetable broth
4 tablespoons of olive oil
4 fresh eggs
1 handful of parsley or
coriander
salt, pepper
9-12 slices of (old) bread
Preparation
Cut the onion into small pieces and fry
together with the garlic. Wash the red
pepper, cut it in half, remove the seeds and
fry it for at least 15.
page 127
Data
• Facts given from which other facts may be
inferred
• Raw material
• Example: Telephone Directory
Information
• Knowledge, intelligence
• Example: Telephone number of florist
• Modeling, Conceptual
Structuring data concepts into logical, coherent,
and mutually related groups
• Modeling, Physical
Modeling the structure of the (future) physical
database
• Base
A set of data, usually in a variety of formats, such
as paper and electronically-based
• Warehouse
A huge set of organized information
GUEST HOTEL
guest of
host of
PERSON ACCOMMODATION
guest of
host of
this is a test
text:
e n
and a text as well
c re
tralalalala
f s pompidom
oKeep
DUHD
h
tc Copy
ke
s
Attachments: Type:
Add
abc.html Hypertext
Signature
xyz.doc Word document
Group
c re
s
friends
f
tc h obipi
DUHD
e joe
sk giovanni_papini@yahoo.com
p.g.m.papini@em.com
GARMENT
Name
Price
GARMENT
COMMODITY
* Name
* Price exclusive VAT
* Price inclusive VAT
* VAT %
COMPOSITION
o Subject
o Cc
o Bcc DRAFT
o Text * Name
MESSAGE TEMPLATE
* Name
COMPOSITION OTHER
o Subject COMPOSITION
o Cc * Name
o Bcc DRAFT
o Text *DRAFT
Name
MESSAGE TEMPLATE
TEMPLATE
* Name
EMPLOYEE
CURRENT OTHER
EMPLOYEE EMPLOYEE
Entities
• Nouns in texts
• Tangible, intangible, events
Attributes
• Single-valued qualifiers of entities
Subtypes
• Inherit all attributes and relationships of supertype
• May have their own attributes and relationships
• Books
• Moonlight Coffees
• Shops
• Subtypes
• Schedule
• Address
Financial
Shop management reports sales figures on a daily
basis to Headquarters, in local currency. Moonlight
uses an internal exchange rates list that is changed
monthly. Since January 1, 1999, the European
Community countries must report in Euros.
Stock
Moonlight Coffees is a public company; stock is
traded at NASDAQ, ticker symbol MLTC. Employees
can participate in a stock option plan.
OTHER
DISABLED BUILDING HOUSE
PERSON
HOTEL DOG
ROOM WITH BATH DOMESTIC
ANIMAL
OTHER ROOM MAMMAL
• Relationships
• Ten different relationship types
• Nontransferability
• Relationships that seem to have attributes
• Rules of Normalization
receiving
replying
sender USER
MESSAGE sent by of
sent to
receiver
reply of of
replied
to by
receiving
receiver of
author USER
MESSAGE
written by of
received by
receiver
reply of of
replied
to by
No: Yes:
receiver of
A split into B
part of
author
MESSAGE USER
written by of
received by
receiver
reply of of
containing replied
to by
with <5
ATTACHMENT
receiver of
FOLDER
containing
filed in
author USER
MESSAGE written by of
received by
receiver
reply of of
replied
to by
(a)
(b)
(c)
(d)
PRODUCT
part
of BUNDLE
consists
of
(e)
(f)
(g)
USER
part
of LIST
consists
of
(h)
( i)
(j)
acting as EMPLOYEE
* Job
role of
MESSAGE
DRAFT
basis for
result of
COUNTRY COUNTRY
location of location of birth
of of located of
located
in in
TOWN TOWN
hometown hometown
of living living of living born
in in in in
PERSON PERSON
ATTACHMENT TYPE
* Name
of
with
ATTACHMENT
* Type ATTACHMENT
* Content * Content
ATTACHMENT TYPE
* Name
of
with
ATTACHMENT
* Type ATTACHMENT
* Content * Content
GENDER NATIONALITY
TEAM ADDRESS
containing
placed in
MESSAGE
* Message Id
* Text
* Folder Name
MESSAGE USER
* Addressee
CUSTOMER PRODUCT
* Id buyer of * Code
* Name * Name
bought by
?
CUSTOMER PRODUCT
buyer of
* Id * Code
* Name * Name
bought by
Quantity
CUSTOMER PRODUCT
buyer of
* Id * Code
* Name * Name
bought by
Quantity
CUSTOMER
* Id with
* Name ORDER
of
PRODUCT with *Quantity Sold
* Code
* Name for
CUSTOMER
* Id with
* Name ORDER
of
* Id
PRODUCT with * Date
* Code
* Name for
Qu
an t
?ity
CUSTOMER
* Id with
ORDER
* Name
of HEADER
* Id
PRODUCT * Date
* Code
* Name
with
with
for for
ORDER ITEM
*Quantity Sold
CUSTOMERS
Id Name ORDER_HEADERS
1 Sanchez Id Ctr_id Date_ordered
Lowitch 1 1 25-MAY-1999
2 Yomita 25-MAY-1999
2 2 25-MAY-1999
ORDER_ITEMS PRODUCTS
Ohd_id Pdt_code Quantity_sold Code Name
1 2 2 1 Jeans
2 2 Shirt
2 2 1 3 Tie
4
A in
A
of A/B COMBINATION
xxx
yyy
B B of
in
with
A
of A/B COMBINATION
xxx
yyy
B of
with
external
classified
PERSON as
CUSTOMER
classification
TYPE
of
internal
external
PERSON CUSTOMER
TYPE
with in
for with
CLASSIFICATION
internal
USER
# Name
* Person Name
* Message Receive Date
o Message Subject
o MessageText
RECEIVED
MESSAGE received by USER
# Receive Date # Name
o Subject receiver * Person Name
o Text of
RECEIVED MESSAGE
including
MESSAGE # Id
# User Name included o Text
* Receive Date in * Subject
ALU of BRY
with
bazooned by
glazoed with
crewed by
spoken by
containing
placed in
USER
COMPOSITION written by author
of
part
MESSAGE received by LIST
of
receiver consist
OTHER of s of
COMPOSITION
reply of
containing replied
to by
with <5
ATTACHMENT ATT. TYPE
RT
CO TRANSPORT
COUNTRY
O
Fr U
Ca ot SP
US an NT
US A ce RY
Bo AN
Bo r s
A
TR
CO
s
Er M
ot
COMPANION
N
Er ic PA
O
Pa ic NI
NI
O
E r ic P A
ul N
Er M
CO
P a ic
ul
STUDENT
#* student id
last name
first name
• Unique Identifiers
• Arcs
• Domains
• Various other constraints
G. Papini, please?
EMPLOYEES
Name Initials Birthdate
PAPINI G. 02-FEB-1954
HIDE T.M. 11-JUN-1961
PAPINI G. 02-FEB-1945
BAKER S.J.T. 24-SEP-1958
JOB Name
COMPUTER IN NETWORK IP Address
TELEPHONE Country code,
Area code,
Telephone number
EMPLOYEE Employee number or
Name,
Initials,
Birth Date
MAIL LIST Name,
Owner
part of owner
of
contains owned by
MAIL LIST
# Name
USER USER
# Name # Name
owner is owner
part of of
of referred to
contains owned by owned by
LIST LIST
# Name # Name
contains
referring
contained
to
in
LIST ITEM
Z Q P
# Z1 # Q1 # P1
o Z2
o Z3 Y
# Z4 # Y1 K
# Y2
L
# L1
X
# X1 M
# M1
XY R T S
# R1 # T1
L F G
K # L1 # G1
# F1
# K1
P R
# P1 # R1
KL
T
o # T1 Q
# Q1
G H
# G1
54.0.093.81
Product Group
In Production?
Factory
Sequence Number
USER owner
of
owned
by
LIST
is referred to container is referred
of to
contained
referring to in referring to
LIST ITEM
}n n n
}n 1 1
}n 0 n
}n 0 1
USER ADDRESS
owner owner
of USER of
owned owned
by by
LIST LIST
is referred is referred contains
to contains to
referring referring is referred
to to to
in referring to in
LIST ITEM LIST ITEM
A A
1 2
R
Q P Q
P
A C
A C B
A C B
B
3 4 5
R R
Q Q
P Q P P
A A
is B
B is
is C
C
is
EMPLOYEE JOB
* Name * Title
* Address * Minimum Salary between
with * Maximum Salary
of
for referring to
EMPLOYMENT
* Start Date
o End Date
* Salary
Possible
Wid
Mar
Div
to
Sin
DP
Marital Status
EMPLOYEE
Transitions fro
* Name
* Address Single m
* Current Marital Status Married
Widowed
Divorced
Domestic Partnership
CONTRACT
# Id
* Standard Indicator STANDARD basis for
CONDITION based
consists on
in
of CUSTOMIZED
CONDITION
in
part of
referring to referring to
CONTRACT COMPONENT
EXTERNAL
unrelated entity # Id
* Description
* Value
• Identification
– Can be a real problem in the real world
– Models cannot overcome this
• Entities must have at least one Unique Identifier
• Unique Identifiers consist of attributes or
relationships or both
• Arcs
• Many types of constraint are not represented
in ER model
• Identification Please
• Identification
• Moonlight UID
• Tables
• Modeling Constraints
• A city
• A contact person for a customer
• A train
• A road
• A financial transaction
• An Academy Award (Oscar)
• A painting
• A T.V. show
A B C
# Xx * Yy # Zz
A B
C # Id
# Code
A
* Xx
B C with D
# Yy # Zz # Id
of
P Q
# Id
P
# Name
PERSON
FEMALE
MALE son of # Name
# Seqno mother of # Birth Date
partner in partner in
reporting to report of
DEPARTMENT report
HQ
of
OTHER reporting to
DEPARTMENT COUNTRY in COUNTRY
ORGANIZATION
with of
with with with
EMPLOYEE belongs to in
with SHOP
of for for
PAYROLL with
ENTRY
to for to
ASSIGNMENT as JOB
in
from with
FOREIGN KEY TABLE KEY
# Name # Name # Name
with
to PRIMARY
referenced of
with in with UNIQUE
with
for in
from in COLUMN for
ASSOCIATION in USAGE
# Seqno # Name
in * Data Type of # Seqno
to o Not Null
EMPLOYEE
# Name managed by
manager of
owned
USER by LIST
owner of
# Name # Name
owned
owner of by NICKNAME
# Alias
with
subfolder USER
# Name
FOLDER within
Name owner
of
owned
by
DAY
# Date
* Public Holiday Indicator
first day of
starts on
of EMPLOYEE
# Name
with
EMPLOYEE COUNTRY
# Id # Name
of in
for as
ASSIGNMENT
# Start Date
o End Date
COUNTRY
# Name
# Start Date
EMPLOYEE * End Date
# Id
of in
life cycle
attributes
for as
ASSIGNMENT
# Start Date
o End Date
PRODUCT
# Id
* Name
with
PRICE =
of PRICED PRODUCT=
HISTORICAL PRICE
PRICE
* Price in $
# Start date
o End Date
ORDER HEADER
PRODUCT referred # Id
# Id by * Order Date
* Name
en
with
e
with
tw
be
of
of
ORDER ITEM
PRICE
* Quantity Ordered
* Price in $
referring
# Start date
o End Date
to
between
PRICE LIST
# Id ORDER HEADER
* Start Date PRODUCT # Id
o End Date # Id * Order Date
* Name referred with
with with by
on of
of
ORDER ITEM
PRICED PRODUCT
* Quantity
* Price in $ referring Ordered
to
PRICE LIST
# Id ORDER HEADER
* Start Date PRODUCT # Id
o End Date # Id * Order Date
* Name
with
with with
on of
of
referred by ORDER ITEM
PRICED PRODUCT
* Quantity
* Price in $
referring Ordered
to
PRICE LIST
# Id ORDER HEADER
* Start Date PRODUCT # Id
o End Date # Id * Order Date
* Name
referred by with
with with
on of
of
ORDER ITEM
PRICED PRODUCT
* Quantity Ordered
* Price in $ referring * Negotiated Price
to
of of of
PRICE PRICE PRICE
* Price in $ * Price in $ * Price in $
# Start Date # Start Date # Start date
* End Date o End Date o End Date
o Current Indicator
by
PAYMENT to
by o Date Paid
PAYMENT * Amount in $
to
*Date Paid
*Amount in $ with
of
AMOUNT
MODIFICATION
* Old Amount in $
* Modified by
* Date Modification
• Shift
• Strawberry Wafer
• Bundles
• Product Structure
PRODUCT GROUP
# Name
classification
for
classified
as
PRODUCT
# Id
* Name
• Patterns
• Drawing conventions
• Generic modeling
• Similar structure
• Similar rules and constraints?
• Characteristic: consists of
An instance of B only exists in the context of an A
• Metaphor: Master – Detail
A
consists
of
part of
B
consists
of Y
part of
B Z
A
# Id
BEAD
# Seqno
• Characteristic: pairs
Every A can be connected to every A
(sometimes: to every other A)
• Metaphor: Web Document with Hyperlinks
A
A
A
product of
PRODUCT COMPOSITION
# Code with * Quantity Needed
part in
in
PRODUCTS COMPOSITIONS
Code Name Prod_code Part_code Quantity
914.53 AAAAAAAA 854.01 604.18 1
914.54 AAA 854.01 604.19 1
914.55 BBBBBBBB 854.01 914.54 2
914.56 B 914.54 914.55 1
CCCCCCC 914.54 914.56 1
DDDDD 934.76 915.12 3
914.54 914.54
604.18 914.55
914.56
604.19
GROUP Group_id S
# Id 1 S1
consists of 2 1 S2
2 S3
in 2 S4
S 3 S5
3 S6
A P
roles ROLE
appointing
appointed
by
MINISTER DEPARTMENT
PARTY PARTY
LEADER
A B
A B
C
AB
AC BC
A B C A B C A B C
AB BC
AB functions as BC functions as
list of values list of values
A X D
F E
high volumes
high volumes
But:
Readability first
B A B
A
C
E C
D
F E
D
• Takes space
• Subject to taste
F
FILM ARTICLE
* AsaTRIPOD o Weight
* Height
LENS o Focal Distance
CAMERA o Height
* Focal
BODY o Asa Number
Distance
* Weight o ...
ARTICLE TYPE
ARTICLE
* Definition Prop1
o Property1
o Definition Prop2
o Property2
o Definition Prop3
o Property3
o Definition Prop4
o Property4
...
o Property5
o Property6
o Property7
MANUFACTURER
o Property8
* Name
ARTICLE TYPE
ARTICLE PROPERTY
THING
having some kind of
relationship with
THING
ASSOCIATION
THING
TYPE ASSOCIATION
TYPE
THING
ASSOCIATION
THING
ASSOCIATION
PROPERTY
‘generic’
CUSTOMER
ARTICLE TYPE
ORDER HEADER
ARTICLE PROPERTY
ORDER ITEM
‘down to earth’
ARTICLE PROPERTY VALUE
Patterns
• Show similarities
• Invent your wheel only once
Generic models
• Reduce the number of entities dramatically
• Are more complex to implement
• Are very flexible
• Are usually the best choice in unstable situations
• Patterns
• Data Warehouse
• Argos and Erats
• Synonym
practice - exercise
order - command
entity - being
order - sequence
order - arrangement
command - demand
columns
EMPLOYEES (EPE)
pk * Id
Table diagram: EMPLOYEES
uk1 * Name
o Address foreign
uk1 * Birth_date key
fk * Dpt_id
Relational Model
ANALYSIS DESIGN
Entity Table
Attribute Column
1 - Entities
EMPLOYEES (EPE)
EMPLOYEE
1 - Entities
2 - Attributes
Table Name: EMPLOYEES
Short Name: EPE
EMPLOYEES (EPE)
EMPLOYEE
# Id * Id
* Name * Name
o Address o Address
* Birth Date * Birth_date
1 - Entities
2 - Attributes
3 - Unique identifiers Table Name: EMPLOYEES
Short Name: EPE
EMPLOYEE
# Id DEPARTMENT
* Name # Id
o Address * Name
* Birth Date
fk2 =
epe_epe_fk
EMPLOYEES (EPE)
pk * Id
* Name
DEPARTMENTS (DPT)
fk1 * Dpt_id pk * Id
fk2 o Epe_id fk1 = epe_dpt_fk uk * Name
XS
fk o Y_id
XS
fk * Y_id
X Y
# Id
* C1 # Id
* C2
XS (X) YS (Y)
pk * Id fk = y_x_fk pk * Id
* C1 pk, fk * X_id
* C2
A B C D
# Id # Id # Id # Id
* C1 * C2 * C3 * C4
X Y
# Id # Id
* C1 * C2
XS YS
pk * Id pk * Id
* C1 X_YS * C2
pk,fk1 * X_id
pk,fk2 * Y_id
fk1 = xy_x_fk fk2 = xy_y_fk
X Y
# Id # Id
* C1 * C2
YS (Y)
XS (X)
fk = y_x_fk pk * Id
pk * Id * C2
* C1 fk,uk * X_id
ALIAS
# Id
fk1 = lim_x_fk
USERS (USR)
LIST_ITEMS (LIM)
fk2 = lim_usr_fk pk * Id
pk,fk1 * X_id * Name
fk2 o Usr_id
fk3 o Als_id ALIASES (ALS)
fk3 = lim_als_fk pk * Id
+ check constraint
P K
# Id # Id
* Xxx
Q
A • Supertype
o Yyy # Id • Subtype
• Both Supertype
R B and Subtype (“Arc”)
* Zzz # Id
L
# Id
P K
# Id # Id
* Xxx
A PS (P)
Q
o Yyy # Id
pk * Id
* Xxx
R B o Yyy
* Zzz # Id o Zzz
fk1 * A_id
• Mandatory fk2 o B_id
discriminator * P_type
L
# Id column
• Additional
constraints
P K QS (Q)
# Id # Id pk * Id q_a_fk
* Xxx * Xxx
A o Yyy
Q fk * A_id
o Yyy # Id
R B
* Zzz # Id RS (R)
fk1=r_a_fk
pk * Id
* Xxx
* Zzz fk2=r_b_fk
L
fk1 * A_id
# Id fk2 * B_id
QS (Q) RS (R)
L pk * Id pk * Id r_b_fk
# Id o Yyy * Zzz
fk * B_id
1 table
2 tables
3 tables
Q
rows Q
R
rows R
rows Q
rows R
fk cols fk cols
rows Q Q R
rows Q
rows R rows R
• Relational concepts
• Naming rules convention
• Basic mapping
• Complex mapping
EMPLOYEE
assigned DEPARTMENT
# Id to
* First Name # Id
* Last Name * Name
* Date of Birth responsible * Location
o Home Phone for
EMPLOYEES ( ) DEPARTMENTS ( )
reporting to report of
DEPARTMENT report
# Id HQ COUNTRY
of
* Name * ORGANIZATION
Address reporting # Tax Id Number
* Head Count to
OTHER DEPARTMENT
DEPARTMENTS ( )
in of
GLOBAL
PRICE
* Amount
lpt_shop_fk
GLOBAL_PRODUCTS (GPT)
gpt_pgp_fk
pk * Code
o Size
LOCAL_PRODUCTS (LPT)
fk1=shp_lpt_fk
pk * Name
pk, fk1 o Shp_no fk2=pgp_lpt_fk
fk1 * Pgp_name
GLOBAL_PRICES ( )
• Denormalization
• Benefits
• Types of denormalization
Denormalization
• Starts with a “normalized” model
• Adds “redundancy” to the design
• Reduces the “integrity” of the design
• Application code added to compensate
A
After pk * Id
* X
* Total_quantity
MESSAGES (MSE)
After pk * Id
* Subject
* Text
* Number_of_times_received
Add the non_key column to the table with the foreign key.
B
After
pk * Id
fk * A_id
* A_col_a
RECEIVED_MESSAGES (RME)
After pk,fk * Mse_id
pk,fk * Flr_id
* Date_receive
* d Fdr_Name
Remove the foreign key and hard code the allowable values and
validation in the application.
After B
pk * Id
* A_Type
After pk * Id
* Amount_1
* Amount_2
* Amount_3
* Amount_4
* Amount_5
* Amount_6
USERS (USR)
After pk * Id
* Name
* Message_Quota_Allocated
* Message_Quota_Available
* File_Quota_Allocated
* File_Quota_Available
*
Add a column to the master to store the most current details.
A
After
p * Id
k * Current_price
MESSAGES (MSE)
After
pk * Id
* First_attachment_name
* Subject
* Text
A B C
After pk Id
pk * Id * pk * Id
fk * A_id fk * B_id
fk * A_id
Create a new foreign key from the lowest detail to the highest
master.
After
RECEIVED_
FOLDERS (FDR) MESSAGES (RME)
USERS (USR)
pk * Name pk * Id
pk * Id fk * Usr_id fk * Fdr_name
uk * Name fk * Usr_name
A B
pk,fk * A_id
pk * Id pk * Start_date
After B
pk,fk * A_Id
pk * Start_date
o Current_indicator
After A
pk * Id
fk * A_id
* Level_no
Denormalization Techniques
• Storing Derivable Information
– End Date Column
– Current Indicator
– Hierarchy Level Indicator
• Pre-Joining Tables
• Hard-Coded Values
• Keeping Detail with Master
• Repeating Single Detail with Master
• Short-Circuit Keys
SHIFTS (SFT)
WEEKDAYS (WDY)
pk * No
pk * Code fk * Wdy_code
* Name Start_time
*
* End_time
* Wdy_name
PRICE_LISTS (PLT)
COUNTRIES (CTY)
pk,fk * Cty_code
pk * Code pk Start_date
*
* Name o End_date
* Current_price_ind
* Order_total * Item_total
* Curr_price_ind
LANGUAGES (LGE)
Track a corporate
pk * Code
name for each product.
* Name
PRODUCT_NAMES (PNE)
PRODUCTS (PDT)
pk * Code pk,fk * Pdt_code
o Size pk,fk Lge_code
* Name
*
• User Expectations
• Volumes
Adapted
• Hardware
Physical
• Network Initial design
Design
• O.S.
• Oracle specifics
Depending on:
• Domains
• Storage issue
• Performance
• Use
Select a data type for columns:
• Character
• Number
• Date
• Large Objects
u
pk ,fk1 * A_id
u
pk ,fk2 * B_id
XS (X) u
pk ,fk3 * C_id
pk Id * C4
* pk * Id
fk1 * D_a_id fk = x_d_fk
fk1
fk ** D_b_id
D_id
fk1 * D_c_id
o C5
225
224
223
Delete Update
Restrict
Cascade
Default Nullify
ALFRED 3544 ef
gh
ij
ALICE 7593 kl
m
ALLISON 3456
no
pq
ALVIN 8642
rs
tu
ALPHONSO 2841 vw
xyz
• Uniqueness
Bitmap
C1 C2 C1 C2
I.O.Table
aba X abc Y
abb Z aba X
abc Y abb Z
bba Z bba X
bbc X bbc Z
! Avoid indexing:
• Small tables
• Columns frequently updated
CUSTOMERS
Col1 Col2 Col3 Region
CUSTOMERS_R1
Col1 Col2 Col3 Region
CUSTOMERS_R2
Col1 Col2 Col3 Region
• Restricting access
• Presentation of data
• Isolate applications from data structure
• Save complex queries
• Simplify user commands
T1 T2 T3 T4
V1 V2 V3 V4
• Advantages
– Dynamic views
– Present denormalized data from normalized tables
– Simplify SQL statements
• Disadvantages
– May affect performances
– Restricted DML in some cases
• Unique index
• Views with “Check option” clause
• Generic Arc implementation
X
A # Id
# Id * Name
* Name
Y
# Id
* Name
AS (A)
...
* Table_name (X or Y)
* Fk_id
• Resilience
• Reduced line traffic
• Location transparency
• Local autonomy
• Easier growth path
but
• Increased, distributed, complexity
• Data Types
• Primary, Foreign, and Artificial Keys
• Indexes
• Partitioning
• Views
• Distributed design
• Data Types
• Artificial Keys
• Product Pictures
Address
Arrival Date
Family Name
GUEST Room Number
HOTEL Floor Number
ROOM Number of Beds
Number of Parking Lots
Price
TV set available?
living in
home town of
visitor of
visited by
mayor of
governed by
(as mayor)
HOTEL
* Address
Soups
Açorda alentejana
bread soup from Portugal
vegetarian for 4 persons:
15 min 1 onion
easy 4 cloves of garlic
1 red pepper
1 liter of vegetable broth
4 tablespoons of olive oil
4 fresh eggs
1 handful of parsley or coriander
salt, pepper
9-12 slices of (old) bread
preparation Cut the onion into small pieces and fry together
with the garlic. Wash the red pepper, cut it in
half, remove the seeds and fry it for at least 15
page 127
Soups
Açorda alentejana
bread soup from Portugal
vegetarian for 4 persons:
15 min 1 onion
easy 4 cloves of garlic
1 red pepper
1 liter of vegetable broth
4 tablespoons of olive oil
4 fresh eggs
1 handful of parsley or coriander
salt, pepper
9-12 slices of (old) bread
preparation Cut the onion into small pieces and fry together
with the garlic. Wash the red pepper, cut it in
half, remove the seeds and fry it for at least 15
page 127
MANUSCRIPT LANGUAGE
TRANSLATION
TITLE
EDITION
PRINTING
VERSION
COPY
MANUSCRIPT LANGUAGE
TRANSLATION
TITLE
EDITION
PRINTING
VERSION
COPY
COUNTRY PRODUCT
COUNTRY COMMUNITY PRODUCT GROUP
CURRENCY PRICE
DEPARTMENT SALE
DRINK SHOP
EMPLOYEE STOCK OPTION
EXCHANGE RATE STOCK PRICE
FOOD TICKER SYMBOL
JOB
LOCATION TYPE
PASTRY
or
COUNTRY
* Code
* Name
SHOP
* Number of
* Name in LOCATION
located located
o Telephone in LOCATION in TYPE
* Open Date * Name * Description
of of
HOTELROOM DOG
pa ir
ROOM WITH BATH DOMESTIC re
n
ANIMAL d
e yo
b
OTHER ROOM MAMMAL
with
within
SCHEDULE for
ENTRY
* Monday Shift with
* Tuesday Shift
* Wednesday Shift
* Thursday shift
* Friday Shift
* Saturday Shift
* Sunday Shift
PERSON
Address text line1
1 Address text line2 COUNTRY
Address text line3
Address text line4
PERSON
Street or “PO Box” Indicator ADDRESS
Street TYPE
2
House Number
City
Post Code
COUNTRY
Province or State
PERSON PERSON
MALE
FEMALE mother of MALE FEMALE child
son of of
mother of
most popular
movie star in COUNTRY
PERSON
with most popular
born in movie star
birthplace of
PRODUCT DEPARTMENT
STORE
in
with
of at
SALE
* Date
PERSON SAILBOAT
in INTERPRETER LANGUAGE
with
of at
with
CREW with
MEMBERSHIP of in
* Role FLUENCY
* Score
works works
for at payroll of
for
EMPLOYEE
* Name
* Job
with
for for COUNTRY in COUNTRY
PAYROLL ORGANIZATION * Name
ENTRY of
* Start Date with of
4d
located
belongs to in
SHOP
4e: -
* No
* Name
containing
USER owner of NICK
1 NAME within FOLDER
owned by
2
referred
to
for
USER
4
forwarded owner owner
with
containing of owned
of
owned
3 COMPOSITION
is by by
within LIST
forward FOLDER
of
RT
CO TRANSPORT
Fr U COUNTRY
O
Ca ot SP
US an NT
US A ce RY
Bo AN
Bo r s
A
TR
CO
s
Er M
ot
COMPANION
N
Er ic PA
O
Pa ic NI
NI
O
E r ic P A
ul N
Er M
CO
P a ic
ul
HOLIDAY
A B
C # Id
2
# Code
A
* Xx
3 with
B C D
# Yy # Zz # Id
of
PERSON
MALE son of FEMALE
# Seqno
mother of # Name
# Birth Date
6 partner in partner in
to for to
ASSIGNMENT as JOB
# Start Date # Title
in
owned
by
with of starting
on starting on
WEEKDAY
# Code SHIFT
* Name SCHEDULE
with or
with on
on on
SHIFT
SHIFT SCHEDULE
# No * Start Date
* Start Time with
* End Time
3
PRODUCT
ASSEMBLY ITEM
* Quantity Needed
PRODUCTS
PRODUCT Code And_or Pg_name
# Code C ..
o And/Or Indicator T …
AS1 OR ….
DP AND …..
ASSEMBLY ITEM
ASSEMBLY ITEMS
* Quantity Needed
Prod_code Using_code Quantity
AS1 C 1
AS1 T 1
DP AS1 1
DP BM 1
LEVEL4
2 + coffees
+ teas
LEVEL5 + foods
product + nonfoods
+ supplements
PRODUCT + bundles
MEANING
# Id
* Description synonym
shared by
with WORDS
WORD Word Mng_i
# Word Practice d
Exercise 1
MEANINGS Order 1
Id Description Sequence 2
1 Action, actual doing ... Arrangement 2
2 Regular arrangement ... Order 2
3 Order, command ... Command 3
4 A vehicle with two wheels Demand 3 homonym
5 ... Bike 3
4
dpt_dpt_fk
DEPARTMENTS (DPT)
pk * Id
* Name
* Dpt_type
* Headcount
o
Address
o
fk Dpt_id_reporting_to
dpt_dpt_fk
DEPARTMENTS (DPT)
pk * Id
* Name
* Dpt_type
* Headcount
o
Address
o
fk Dpt_id_reporting_to
gpt_pgp_fk lpt_shp_fk
* Order_total * Item_total
* Curr_price_ind
LANGUAGES (LGE)
pk * Code
* Name
BINARY_DOCUMENTS (BDT)
• Table Normalization
• Normal Forms of Tables
7773 Walsh 54101 05/07 Meeting Today There is.. 9988 EMEA01
0022 Patel 54101 05/07 Meeting Today There is.. 9988 EMEA01
USERS
USER USER SRVR SERVER
_ID _NAME _ID _NAME
---- ----- ---- ------
2301 Smith 3786 IMAP05
5607 Jones 6001 IMAP08
7773 Walsh 9988 EMEA01
0022 Patel 9988 EMEA01
Is the USERS table already in 2NF?
USERS
SRVR
ID NAME _ID
USERS ---- ----- ----
USER USER SRVR SERVER 2301 Smith 3786
_ID _NAME _ID _NAME 5607 Jones 6001
---- ----- ---- ------ 7773 Walsh 9988
2301 Smith 3786 IMAP05 0022 Patel 9988
5607 Jones 6001 IMAP08
7773 Walsh 9988 EMEA01
0022 Patel 9988 EMEA01
MAIL_ ID NAME
SERVER ---- ------
3786 IMAP05
6001 IMAP08
9988 EMEA01