You are on page 1of 412

Data Modeling and Relational

Database Design
Electronic Presentation

20000GC13
Production 1.3
August 2002
D37098

Copyright © Oracle Corporation, 2002. All rights reserved.

Author Copyright ” Oracle Corporation, 2002. All rights reserved.

This documentation contains proprietary information of Oracle International Corporation. It is
Patrice Daux provided under a license agreement containing restrictions on use and disclosure and is also
protected by copyright law. Reverse engineering of the software is prohibited. If this documentation is
Jeff Gallus
delivered to a U.S. Government Agency of the Department of Defense, then it is delivered with
Jan Speelpenning Restricted Rights and the following legend is applicable:

Restricted Rights Legend
Technical Contributors and
Reviewers Use, duplication or disclosure by the Government is subject to restrictions for commercial computer
software and shall be deemed to be Restricted Rights software under Federal law, as set forth in
Kate Heap subparagraph (c) (1) (ii) of DFARS 252.227-7013, Rights in Technical Data and Computer Software
Simmie Kastner (October 1988).
Joni Lounsberry This material or any portion of it may not be copied in any form or by any means without the express
Satyajit Ranganathan prior written permission of Oracle International Corporation. Any other copying is a violation of
Sunshine Salmon copyright law and may result in civil and/or criminal penalties.
Stijn Vanbrabant
If this documentation is delivered to a U.S. Government Agency not within the Department of
Gabriella Varga
Defense, then it is delivered with ’Restricted Rights,’ as defined in FAR 52.227-14, Rights in Data-
Publishers General, including Alternate III (June 1987).

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.

Copyright © Oracle Corporation, 2002. All rights reserved.

Introduction to Entities,
Attributes, and Relationships

Copyright © Oracle Corporation, 2002. All rights reserved.

Overview

Why conceptual modeling?
Introduction of the Key role players:
• Entities
• Attributes
• Relationships

1-2 Copyright © Oracle Corporation, 2002. All rights reserved.

Why Create a Conceptual Model?

• It describes exactly the information needs of the
business
• It facilitates discussion
• It helps to prevent mistakes, misunderstanding
• It forms important “ideal system” documentation
• It forms a sound basis for physical database
design
• It is a very good practice with many practitioners

1-3 Copyright © Oracle Corporation, 2002. All rights reserved.

Between Dream and Reality...

1-5 Copyright © Oracle Corporation, 2002. All rights reserved.

Entity Relationship Modeling
PRICE LEVEL
# CODE
* DESCRIPTION

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

• Has a robust syntax
acquired fro o WORK EXTENSION
the cancellor of responsible responsible o WORK PHONE
m o PHOTOGRAPH
of o STAFF REMARKS
for for

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

held by the type o

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

...although they may
requested authorized by of
against
the
BOOKING MEMBERSHIP PERIOD
* BOOK DATE requestor # START DATE
o EXPIRE DATE o ACTUAL FEE PAID
o NOTIFY DATE of
o RESERVE DATE
o STAFF REMARKS

look rather complex fulfilled as
approved by

RENTAL
* RENTAL DATE
o STAFF REMARKS
o COMPLETED
for

at first sight for
the rental for
composed of

part of

RENTAL ITEM
# LINE NO
* RENTAL PERIOD
* PRICE PAID
o RETURN DATE
o STAFF REMARKS

1-7 Copyright © Oracle Corporation, 2002. All rights reserved.

Goals of Entity Relationship Modeling

• Capture all required information
• Information appears only once
• Model no information that is derivable from other
information already modeled
• Information is in a predictable, logical place

1-8 Copyright © Oracle Corporation, 2002. All rights reserved.

2002. . All rights reserved. Database Types ER Model Hierarchical Network Relational 1-9 Copyright © Oracle Corporation.

2002. events • Entities have instances 1-10 Copyright © Oracle Corporation. . Entity • 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. All rights reserved.

5 x 35 mm copper nail PRODUCT TYPE nail EMPLOYMENT CONTRACT my previous contract JOB violinist SKILL LEVEL fluent TICKET RESERVATION tonight: Hamlet in the Royal PURCHASE the CD I bought yesterday ELECTION for parliament next fall PRINTER PREFERENCE … DOCUMENT VERSION . All rights reserved. Entities and Instances PERSON Mahatma Gandhi PRODUCT 2. 2002. 1-11 Copyright © Oracle Corporation. ...

. Entities and Sets An entity represents a set of instances that are of interest to a particular business. 2002. JOB manager cook waitress dish washer financial controller porter waiter piano player 1-12 Copyright © Oracle Corporation. All rights reserved.

. All rights reserved. 2002. Attribute • Also represents something of significance to the business • Is a single valued property detail of an entity • Is a specific piece of information that: – Describes – Quantifies – Qualifies – Classifies – Specifies an entity 1-13 Copyright © Oracle Corporation.

Age. … ORDER Order Date. Salary.. … EMPLOYMENT Start Date.. CONTRACT 1-14 Copyright © Oracle Corporation. CAR Model. Catalog Price. . TRANSACTION Amount. .. All rights reserved. Description. Transaction Date. Weight. 2002. Shoe Size. Ship Date. … JOB Title. Attribute Examples Entity Attribute EMPLOYEE Family Name. .. . Town of Residence... Email.

All rights reserved. Relationships • Also represent something of significance to the business • Express how entities are mutually related • Always exist between two entities (or one entity twice) • Always have two perspectives • Are named at both ends 1-15 Copyright © Oracle Corporation. . 2002.

2002. . All rights reserved. Relationship Examples EMPLOYEES have JOBS JOBS are held by EMPLOYEES PRODUCTS are classified by a PRODUCT TYPE PRODUCT TYPE is a classification for a PRODUCT PEOPLE make TICKET RESERVATIONS TICKET RESERVATIONS are made by PEOPLE 1-16 Copyright © Oracle Corporation.

Employees have Jobs JOB manager EMPLOYEE cook Shintaro waitress dish washer Jill financial controller Adam Ahmed porter waiter Maria piano player 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 1-17 Copyright © Oracle Corporation. All rights reserved. . 2002.

. 2002. Entity Representation in Diagram • Drawn as a “softbox” EMPLOYEE JOB ELECTION • Name singular • Name inside • Neither size. entities usually lead to tables. All rights reserved. 1-18 Copyright © Oracle Corporation. TICKET nor position RESERVATION ORDER has a special meaning JOB ASSIGNMENT During design.

Attributes in Diagrams Mandatory attribute. EMPLOYEE JOB Family Name Title * *o Description Address * o Birth Date o Shoe Size o Email During design. 1-20 Copyright © Oracle Corporation. that is. unknown or unimportant to know for some instances. known and available for every instance. that is. . 2002. All rights reserved. attributes lead to columns. Optional attribute.

Relationship in Diagrams An employee has exactly one job. 1-21 Copyright © Oracle Corporation. . 2002. All rights reserved. relationships lead to foreign keys. EMPLOYEE JOB has held by Jobs are held held by by one ormore one or more employees During design.

2002. All rights reserved. Diagrams Are To Communicate has JOB EMPLOYEE held by 1-22 Copyright © Oracle Corporation. .

Characteristics Of The Relationship Line mandatory: optional: 1-23 Copyright © Oracle Corporation. 2002. . All rights reserved.

All rights reserved. . Two Perspectives mandatory: optional: EMPLOYEE has JOB held by 1-24 Copyright © Oracle Corporation. 2002.

. One Way mandatory: optional: EMPLOYEE has JOB held by Every EMPLOYEE has exactly one JOB 1-25 Copyright © Oracle Corporation. All rights reserved. 2002.

All rights reserved. The Other Way mandatory: optional: EMPLOYEE has JOB held by A JOB may be held by one or more EMPLOYEES 1-26 Copyright © Oracle Corporation. 2002. .

Reading a Relationship End P split into Q part of 1-27 Copyright © Oracle Corporation. All rights reserved. . 2002.

. 2002. Reading a Relationship End P split into Q part of 1-28 Copyright © Oracle Corporation. All rights reserved.

Reading a Relationship End P split into Q part of must be exactly one Q “Each P may be split into ” one or more Qs 1-29 Copyright © Oracle Corporation. All rights reserved. 2002. .

. 2002. All rights reserved. Reading a Relationship End P split into Q part of “Each P may be split into one or more Qs” 1-30 Copyright © Oracle Corporation.

Reading a Relationship End P split into Q part of “Each P may be split into one or more Qs” 1-31 Copyright © Oracle Corporation. . All rights reserved. 2002.

2002. Reading a Relationship End P split into Q part of “Each P may be split into one or more Qs” must be exactly one P “Each Q may be part of ” one or more Ps 1-32 Copyright © Oracle Corporation. . All rights reserved.

Reading a Relationship End P split into Q part of “Each P may be split into one or more Qs” “Each Q must be part of exactly one P” 1-33 Copyright © Oracle Corporation. . 2002. All rights reserved.

Functions Drive Data • Business functions are always present. All rights reserved. – Explicit – Assumed • Business functions need data. • An entity. – The business need may arise in the near future. . or relationship may be modeled because: – It is used by a business function. 2002. attribute. 1-34 Copyright © Oracle Corporation.

2002. All rights reserved. . Weather Forecast January 26 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 1-35 Copyright © Oracle Corporation.

All rights reserved. 2002. . DK København (Copenhagen) IR UK NL Bremen Amsterda m Berli BE Bruxelle DE n (Brussels s ) LU München Paris (Munich) FR CH Bordeaux IT 1-36 Copyright © Oracle Corporation.

Weather Forecast. All rights reserved. a Solution CITY COUNTRY * Name located in * Name o Geographical o Geographical Position having Position subject of about FORECAST referring to WEATHER TYPE * Date * Icon o Minimum referred in * Description Temperature o Maximum referring to WIND DIRECTION Temperature * Icon o Wind Force referred in * Description 1-38 Copyright © Oracle Corporation. 2002. .

Graphical Elements of ER Diagram Entity Attribute ** ** o Relationship Subtype Unique identifier Arc Nontransferability #o # 1-39 Copyright © Oracle Corporation. 2002. All rights reserved. .

but not too much 1-40 Copyright © Oracle Corporation. 2002. Summary • ER Modeling models information conceptually • Based on functional business needs • “What”. not “How” • Diagrams provide easy means of communication • Detailed. All rights reserved. .

Practices • Instance or Entity • Guest • Reading • Hotel • Recipe 1-41 Copyright © Oracle Corporation. All rights reserved. . 2002.

Practice: Instance or Entity? Concept E/A/I? Example Instance or Entity PRESIDENT ELLA FITZGERALD DOG ANIMAL HEIGHT E CAR A CAR I CAR 1-42 Copyright © Oracle Corporation. All rights reserved. 2002. .

2002. . Practice: Guest Address Arrival Date GUEST Family Name HOTEL Room Number ROOM Floor Number Number of Beds Number of Parking Lots Price TV set available? 1-43 Copyright © Oracle Corporation. All rights reserved.

All rights reserved. Practice: Reading EMPLOYEE assigned to DEPARTMENT responsible for A Each EMPLOYEE may be assigned to one or more DEPARTMENTS Each DEPARTMENT must be responsible for one or more EMPLOYEES B Each EMPLOYEE must be assigned to one or more DEPARTMENTS Each DEPARTMENT may be responsible for one or more EMPLOYEES C Each EMPLOYEE must be assigned to exactly one DEPARTMENT Each DEPARTMENT may be responsible for exactly one EMPLOYEE 1-44 Copyright © Oracle Corporation. 2002. .

Practice: Read and Comment PERSON born in TOWN birthplace of living in home town of visitor of visited by mayor of with mayor 1-45 Copyright © Oracle Corporation. . All rights reserved. 2002.

. 2002. Practice: Hotel HOTEL * Address the lodging host of for ROOM * Room Number with in in guest in STAY of PERSON * Arrival Date * Name with 1-46 Copyright © Oracle Corporation. All rights reserved.

. Wash the red pepper. Ralph’s Raving Recipes 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. All rights reserved. page 127 1-47 Copyright © Oracle Corporation. remove the seeds and fry it for at least 15. pepper 9-12 slices of (old) bread Preparation Cut the onion into small pieces and fry together with the garlic. cut it in half. 2002.

All rights reserved. 2002. .1-48 Copyright © Oracle Corporation.

Entities and Attributes in Detail Copyright © Oracle Corporation. 2002. . All rights reserved.

Overview • Data compared to information • Entities and how to track them down • Attributes • Subtypes and supertypes 1-2 Copyright © Oracle Corporation. All rights reserved. . 2002.

All rights reserved. 2002. Data Compared to Information Data • Facts given from which other facts may be inferred • Raw material • Example: Telephone Directory Information • Knowledge. . intelligence • Example: Telephone number of florist 1-3 Copyright © Oracle Corporation.

coherent. 2002. such as paper and electronically-based • Warehouse A huge set of organized information 1-4 Copyright © Oracle Corporation. and mutually related groups • Modeling. All rights reserved. Conceptual Structuring data concepts into logical. usually in a variety of formats. . Physical Modeling the structure of the (future) physical database • Base A set of data. Data • Modeling.

2002. All rights reserved. Entities • Give the entity a unique name • Create a formal description of the entity • Add a few attributes. if possible • Be aware of homonyms • Check entity names and descriptions regularly • Avoid use of reserved words • Remove relationship name from entity name 1-6 Copyright © Oracle Corporation. .

Relationship Name in Entity Name GUEST HOTEL guest of host of PERSON ACCOMMODATION guest of host of 1-8 Copyright © Oracle Corporation. All rights reserved. 2002. .

All rights reserved. we do not know. such as the name. birth date. Some Background Information “ElectronicMail (EM) wants to provide an attractive and user. . 1-9 Copyright © Oracle Corporation. line of business. An EM user has a unique address of 30 characters at most and a password supplied by the person who set up the EM user. and a few more things. Who the person really is. country.friendly Web-based e-mail system. although we ask for some additional information. Important concepts are user and message. 2002.

Some Background Information Users must be able to send and receive mail messages. 2002. . that is sent and kept with the message. but not created with our software. Outbox. Every user has three folders to start with: Inbox. like a spreadsheet. All rights reserved. A message may have attached files. A mail message is usually a piece of straight text. and Wastebasket. Additional folders can be created by the user. Messages are kept in folders.” 1-10 Copyright © Oracle Corporation. An attachment is a file.

html Hypertext Signature xyz.doc Word document 1-11 Copyright © Oracle Corporation. All rights reserved. . giovanni_papini@yahoo.com a il Save Draft Preferences Cc: myself s em Save Template Get New Mail Bcc: p o o m Cancel Exit o c Message t DGYHUWLVHPHQW 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. 2002. (0 ORJR DGYHUWLVHPHQWDUHD s ge Compose Compose Template default s s a me Send Folders Subject: test Addresses To: bipi.

com jtiddlywink@em.com bipi n t sabine_papini @yahoo. (0 ORJR DGYHUWLVHPHQWDUHD Compose Addresses e s ss Folders Nicknames dr e Addresses Alias Email address a d Preferences apple ai n w. .suspender@last.com Exit t o e n DGYHUWLVHPHQW Group c re s friends f tc h obipi DUHD e joe sk giovanni_papini@yahoo.g. 2002.papini@em.m.j.com 1-12 Copyright © Oracle Corporation.com p. All rights reserved.appletree@cats.com i Get New Mail joe myself ma j.

a group of e- mail addresses. All rights reserved. • Users must be able to create templates for their messages. . for example. 1-13 Copyright © Oracle Corporation. The system should only keep one copy of the message sent (to save database space) plus information about whom the message was sent to. A template must be named and may contain everything a real message contains. A template may be used for new messages. 2002. Some Desired Functionality • “Users of ElectronicMail must be able to address messages to a mail list.

Some Desired Functionality • Users must be able to reply to a message. to hide the often complex addresses behind an easy-to-remember nickname. • Users must be able to create an alias for an e-mail address. 2002. All rights reserved. By replying the user creates a new message to which the old message is added. .” 1-14 Copyright © Oracle Corporation.

etc. Evolution of an Entity Definition • A message is a piece of text sent by a user. nor a subject. • A message is a note that is sent by an EM user or received by an EM user or both. A message does not necessarily contain text. nor a subject. All rights reserved. . A message does not necessarily contain text. • A message is a note that is sent by an EM user. A message does not necessarily contain text. • A message is a piece of text sent by an EM user. etc. 2002. 1-15 Copyright © Oracle Corporation. nor a subject. etc. • A message is a note that is received by an EM user.

A template must be named and may contain everything a real message contains. . The system should only keep one copy of the message sent (to save data base space) plus information about whom the message was sent to. 1-17 Copyright © Oracle Corporation. A template may be used for new messages. All rights reserved. a group of e- mail addresses. • Users must be able to create templates for their messages. for example. 2002. Business Functions • “Users of ElectronicMail must be able to address messages to a mail list.

. • Users must be able to create an alias for an e-mail address.” 1-18 Copyright © Oracle Corporation. All rights reserved. Business Functions • Users must be able to reply to a message. 2002. to hide the often complex addresses behind an easy-to-remember nickname. By replying the user creates a new message to which the old message is added.

An Attribute. 2002. not of relationship • Must be single valued • Has format. • Always answers “of what?” • Is the property of entity. ... All rights reserved. for example: – Character string – Number – Date – Picture – Sound • Is an elementary piece of data 1-19 Copyright © Oracle Corporation.

we do not know. Important concepts are user and message. Attributes • “ElectronicMail (EM) wants to provide an attractive and user friendly Web-based email system. COUNTRY. like the name. • An EM USER has a unique address of 30 characters at most and a password supplied by the PERSON who set up the EM user. and a few things more. Who the person really is. line of business. birth date. . All rights reserved. 1-20 Copyright © Oracle Corporation. Nouns. Entities. although we ask for some additional information. 2002.

. Additional folders can be created by the user. 2002. An ATTACHMENT is a file. Every user has three folders to start with: Inbox. that is sent and kept with the message. but not created with our software. Outbox and Wastebasket. All rights reserved. A message may have attached files. • Messages are kept in FOLDERS. like a spreadsheet. Attributes • Users must be able to send and receive mail MESSAGES.” 1-21 Copyright © Oracle Corporation. Nouns. Entities. A mail message is usually a piece of straight text.

Name text Text MESSAGE attachment ATTACHMENT .Text file File ATTACHMENT folder FOLDER .Name country COUNTRY . . EM Entities and Attributes Nouns Entities/Attributes/ Entities with their Instances Attributes user USER USER address Address .Filename inbox Inbox FOLDER outbox Outbox . All rights reserved.Name wastebasket Wastebasket 1-22 Copyright © Oracle Corporation.Password person PERSON PERSON name Name .Birth Date birth date Birth Date .Address password Password .Occupation occupation Occupation COUNTRY message MESSAGE . 2002.

GARMENT CURRENCY PRICE NAME LANGUAGE 1-23 Copyright © Oracle Corporation. Attribute and Entity GARMENT Name Price Attributes in one model can be entities in another. 2002. . All rights reserved.

. All rights reserved. Redundancy COMMODITY * Name * Price exclusive VAT * Price inclusive VAT * VAT % 1-24 Copyright © Oracle Corporation. 2002.

A Subtype . All rights reserved.. 2002. .. • Inherits all attributes of supertype • Inherits all relationships of supertype • Usually has its own attributes or relationships or business functions • Is drawn within supertype • Never exists alone ADDRESS • May have subtypes of its own USER • Is also known as “Subentity” LIST 1-25 Copyright © Oracle Corporation.

2002. All rights reserved. . Subtype: Example COMPOSITION o Subject o Cc o Bcc DRAFT o Text * Name MESSAGE TEMPLATE * Name 1-26 Copyright © Oracle Corporation.

2002. . and • Mutually exclusive: Every instance of the supertype is of one and only one subtype. Subtype: Rules Subtypes of the same entity must be: • Exhaustive: Every instance of a supertype is also instance of one of the subtypes. All rights reserved. Name subtypes A adequately: B C NON B OTHER A 1-27 Copyright © Oracle Corporation.

. Subtypes: Three Levels COMPOSITION OTHER o Subject COMPOSITION o Cc * Name o Bcc DRAFT o Text *DRAFT Name MESSAGE TEMPLATE TEMPLATE * Name 1-28 Copyright © Oracle Corporation. All rights reserved. 2002.

EMPLOYEE CURRENT OTHER EMPLOYEE EMPLOYEE .. All rights reserved. 2002.. ... More on Subtypes Subtypes always exist. but do not all make sense EMPLOYEE EMPLOYEE WITH OTHER SHOE SIZE > 45 EMPLOYEE 1-29 Copyright © Oracle Corporation.

events Attributes • Single-valued qualifiers of entities Subtypes • Inherit all attributes and relationships of supertype • May have their own attributes and relationships 1-30 Copyright © Oracle Corporation. intangible. 2002. Summary Entities • Nouns in texts • Tangible. . All rights reserved.

. All rights reserved. Practices • Books • Moonlight Coffees • Shops • Subtypes • Schedule • Address 1-31 Copyright © Oracle Corporation. 2002.

2002. Did you read that new book on Picasso? I did. All rights reserved. The hard cover edition is available now. 1-32 Copyright © Oracle Corporation. which is 16th century. If you like you can borrow my book. We have just published this book. 5. I have just finished writing a book. I use the modern English text as a basis and not the original. I ordered that book for my parents. 2. I have just started translating this book into Spanish. 6. 1. It's great! 4. . 3. It’s a novel about justice and power.

1-33 Copyright © Oracle Corporation. we have that book available. 7. 8. . 10. Mine is autographed. Yes. I want to write a book on entity relationship modeling when I retire. All rights reserved. You should find it in Art books. A second printing of the book War and Peace is very rare. 9. 2002. I think My name is Asher Lev is one of the best books ever written.

and various kinds of pastries. Products • All shops serve coffees. Moonlight Coffees Summary • Moonlight Coffees is a fast growing chain of high quality coffee shops with currently over 500 shops in 12 countries of the world. 2002. museums. Most shops sell nonfoods. entertainment and business areas. like postcards and sometimes even theater tickets. airports. such as major shopping. 1-34 Copyright © Oracle Corporation. Moonlight Coffees has some 9. soft drinks. . All rights reserved.000 employees. teas. railway stations. Shops are located at first-class locations.

Since January 1. Employees can participate in a stock option plan. the European Community countries must report in Euros. Moonlight uses an internal exchange rates list that is changed monthly. . ticker symbol MLTC. in local currency. Stock Moonlight Coffees is a public company. 2002. Moonlight Coffees Summary Financial Shop management reports sales figures on a daily basis to Headquarters. All rights reserved. 1-35 Copyright © Oracle Corporation. 1999. stock is traded at NASDAQ.

866.866. 2002. USA. 212. 405. JP.3603/4. 1-nov-97 184 JFK. New York. USA.3410. JFK Airport terminal 4. Museum.867.3766.3345. 12-oct-97 182 Hara. New York. Airport. 25-oct-97 183 Phillis. All rights reserved. 3581.Tokyo. 1-nov-97 1-36 Copyright © Oracle Corporation. JFK Airport terminal 2. Kita Shinagawa. 212. USA. ordered to date opened page 4 181 The Flight. Shopping Centre. Atlanta. Airport. Moonlight Coffees Shop List Shoplist. 25 Phillis Rd. .

New York. All rights reserved. 445 145 20. NL. Paris. JFK Airport terminal 1.345. 10 Mont Martre. London. FR.756. 203.866.87. Museum. 10-nov-97 186 The Queen. 25-nov-97 187 Wright Bros. Amsterdam. Museumplein 24. . 2-feb-98 1-37 Copyright © Oracle Corporation.9852. 212. 2002.75. 6-jan-98 188 La Lune. 76. Moonlight Coffees Shop List 185 VanGogh. USA. Entertainment. Airport. UK. Railway Station. 60 Victoria Street.

. All rights reserved. 2002. Subtypes DISABLED CAR PERSON STATION WAGON DEAF SEDAN BLIND OTHER DISABLED BUILDING HOUSE PERSON HOTEL DOG ROOM WITH BATH DOMESTIC ANIMAL OTHER ROOM MAMMAL 1-38 Copyright © Oracle Corporation.

. van Gogh.Oct 18 prepared by Janet Shift Mon Tue Wed Thu Fri Sat Sun Annet S 2 2 2 1 Annet B 1 1 1 Dennis 2 2 1 2 3 Jürgen 5 4 Kiri 3 4 4 Wil 1-39 Copyright © Oracle Corporation. Amsterdam Schedule Oct 12 . All rights reserved. 2002. Museumplein.

All rights reserved. . Practice: Address (1/2) Rheingasse 123 34 Oxford Road 53111 Bonn Reading Germany Berkshire RG1 8JS UK 1020 Maple Drive Kirkland WA 98234 USA 1-40 Copyright © Oracle Corporation. 2002.

Box 66708 c/o Mrs Smith Nairobi Maude Street Kenya Sandton Johannesburg 2144 South Africa 1-41 Copyright © Oracle Corporation. . 2002. Practice: Address (2/2) P.O. All rights reserved.

Relationships in Detail Copyright © Oracle Corporation. . All rights reserved. 2002.

Overview • Relationships • Ten different relationship types • Nontransferability • Relationships that seem to have attributes • Rules of Normalization 3-2 Copyright © Oracle Corporation. 2002. . All rights reserved.

. 2002. Establishing a Relationship • Determine the existence of a relationship • Choose a name for the relationship from both perspectives • Determine optionality • Determine degree • Determine nontransferability 3-3 Copyright © Oracle Corporation. All rights reserved.

Establishing the Relationship MESSAGE sending USER receiving replying 3-4 Copyright © Oracle Corporation. All rights reserved. . 2002.

Relationship Names sender USER MESSAGE sent by of sent to receiver reply of of replied to by 3-5 Copyright © Oracle Corporation. . 2002. All rights reserved.

Naming the Relationship receiving MESSAGE received by USER receiver of A MESSAGE is received by a USER A USER is receiver of a MESSAGE 3-6 Copyright © Oracle Corporation. All rights reserved. 2002. .

2002. All rights reserved. Optionality author USER MESSAGE written by of received by receiver reply of of replied to by 3-7 Copyright © Oracle Corporation. .

. 2002. Optionality No: Yes: MESSAGE received by USER receiver of • Must every MESSAGE be received by a USER? Yes • Must every USER be receiver of a MESSAGE? No 3-8 Copyright © Oracle Corporation. All rights reserved.

2002. . Mandatory 1: Mandatory m A split into B part of • Every A must be split into at least one B • Every B must be part of exactly one A 3-9 Copyright © Oracle Corporation. All rights reserved.

2002. . All rights reserved. Degree author MESSAGE USER written by of received by receiver reply of of containing replied to by with <5 ATTACHMENT 3-10 Copyright © Oracle Corporation.

All rights reserved. 2002. Degree One: One or more: MESSAGE received by USER receiver of • Can a MESSAGE be received by more than one USER? Yes • Can a USER be the receiver of more than one MESSAGE ? Yes 3-11 Copyright © Oracle Corporation. .

All rights reserved. Nontransferability FOLDER containing filed in author USER MESSAGE written by of received by receiver reply of of replied to by 3-12 Copyright © Oracle Corporation. . 2002.

2002. Relationship Types 1:m (a) (b) (c) (d) 3-13 Copyright © Oracle Corporation. All rights reserved. .

. All rights reserved. 2002. Relationship Types m:1 PRODUCT part of BUNDLE consists of 3-15 Copyright © Oracle Corporation.

All rights reserved. . 2002. Relationship Types m:m (e) (f) (g) 3-16 Copyright © Oracle Corporation.

2002. . All rights reserved. Relationship Types m:m USER part of LIST consists of 3-17 Copyright © Oracle Corporation.

Relationship Types 1:1 (h) ( i) (j) 3-18 Copyright © Oracle Corporation. . All rights reserved. 2002.

. 2002. All rights reserved. 1:1 Relationships Roles PERSON acting as PATIENT * Name * Blood Type role of acting as EMPLOYEE * Job role of 3-19 Copyright © Oracle Corporation.

. 2002. All rights reserved. 1:1 Relationships Process MESSAGE DRAFT basis for result of 3-20 Copyright © Oracle Corporation.

All rights reserved. 2002. . Redundant Relationships 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 3-21 Copyright © Oracle Corporation.

2002. . All rights reserved. Relationships and Attributes • An attribute can hide a relationship • Relationship can be “downgraded” to attribute ATTACHMENT TYPE * Name of with ATTACHMENT * Type ATTACHMENT * Content * Content 3-22 Copyright © Oracle Corporation.

Attribute Compared to Relationship • Easy model • Value control • Fewer tables • List of values • No join • Other relationships ATTACHMENT TYPE * Name of with ATTACHMENT * Type ATTACHMENT * Content * Content 3-23 Copyright © Oracle Corporation. . All rights reserved. 2002.

Attribute or Entity NAME EMPLOYEE JOB * Id SALARY BADGE GENDER NATIONALITY TEAM ADDRESS 3-24 Copyright © Oracle Corporation. All rights reserved. 2002. .

All rights reserved. Attribute Compared to Relationship • There is no such thing as a foreign key attribute • Usually. the attribute name should not contain an entity name FOLDER * Name containing placed in MESSAGE * Message Id * Text * Folder Name 3-25 Copyright © Oracle Corporation. . 2002.

All rights reserved. Relationship Compared to Attribute MESSAGE addressed to USER addressee of MESSAGE USER * Addressee MESSAGE addressed to USER o Addressee addressee of 3-26 Copyright © Oracle Corporation. . 2002.

2002. m:m Relationships May Hide Something CUSTOMER PRODUCT * Id buyer of * Code * Name * Name bought by 3-27 Copyright © Oracle Corporation. . All rights reserved.

All rights reserved. . ? CUSTOMER PRODUCT buyer of * Id * Code * Name bought by * Name Quantity ? CUSTOMER PRODUCT buyer of * Id * Code * Name * Name bought by Quantity 3-28 Copyright © Oracle Corporation.. Quantity Is Attribute of .. 2002.

All rights reserved. 2002. Attribute of Relationship ? CUSTOMER PRODUCT buyer of * Id * Code * Name * Name bought by Quantity 3-29 Copyright © Oracle Corporation. .

2002. All rights reserved. New Entity ORDER CUSTOMER * Id with * Name ORDER of PRODUCT with *Quantity Sold * Code * Name for CUSTOMERS PRODUCTS ORDERS Id Name Code Name Ctr_id Pdt_code Quantity_sold 1 Sanchez 1 Jeans 1 2 2 2 Lowitch 2 Shirt 1 3 2 3 Yomita 3 Tie 2 2 1 4 4 3 3-30 Copyright © Oracle Corporation. .

2002. . All rights reserved. Multiple PRODUCTS for an ORDER CUSTOMER * Id with * Name ORDER of * Id PRODUCT with * Date * Code * Name for Qu an t ?ity 3-31 Copyright © Oracle Corporation.

2002. Another New Entity: ORDER ITEM CUSTOMER * Id with ORDER * Name of HEADER * Id PRODUCT * Date * Code * Name with with for for ORDER ITEM *Quantity Sold 3-32 Copyright © Oracle Corporation. . All rights reserved.

Tables 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 3-33 Copyright © Oracle Corporation. 2002. All rights reserved. .

Resolving m:m Relationship • Create new intersection entity • Create two m:1 relationships. . All rights reserved. 2002. derive optionality • Remove m:m relationship A in A of A/B COMBINATION xxx yyy B B of in 3-34 Copyright © Oracle Corporation.

Resolving m:m Relationship • Create new intersection entity • Create two m:1 relationships. 2002. . All rights reserved. derive optionality • Remove m:m relationship with A of A/B COMBINATION xxx yyy B of with 3-36 Copyright © Oracle Corporation.

All rights reserved. Resolving m:1 Relationship external classified PERSON as CUSTOMER classification TYPE of internal 3-37 Copyright © Oracle Corporation. 2002. .

. Resolving m:1 Relationship external PERSON CUSTOMER TYPE with in for with CLASSIFICATION internal 3-38 Copyright © Oracle Corporation. All rights reserved. 2002.

2002. . All rights reserved. “A normalized entity-relationship data model automatically translates into a normalized relational database design” “Third normal form is the generally accepted goal for a database design that eliminated redundancy” 3-39 Copyright © Oracle Corporation. Normalization Rules Normal Form Rule Description First Normal Form All attributes are single valued. Second Normal Form (2NF) An attribute must be dependent upon entity’s entire unique identifier. Third Normal Form (3NF) No non-UID attribute can be dependent on another non-UID attribute.

. 2002. RECEIVED MESSAGE received by USER # Receive Date # Name o Subject receiver * Person Name o Text of 3-40 Copyright © Oracle Corporation. First Normal Form in Data Modeling USER # Name * Person Name * Message Receive Date o Message Subject o MessageText All attributes must be single-valued. All rights reserved.

Second Normal Form in Data Modeling An attribute must be dependent upon its entity’s entire unique identifier. RECEIVED including MESSAGE MESSAGE # Id # User Name included o Text * Receive Date in * Subject RECEIVED MESSAGE including MESSAGE # Id # User Name included o Text * Receive Date in * Subject 3-41 Copyright © Oracle Corporation. All rights reserved. . 2002.

Third Normal Form in Data Modeling USER # Name * Person Name * Password * Server Id * Server Name No non-UID attribute can be dependent upon another non-UID attribute. USER assigned MAIL # Name to SERVER * Person Name # Id * Password distribut * Name e mail to 3-42 Copyright © Oracle Corporation. . 2002. All rights reserved.

2002. All rights reserved. • Initially relationships often seem to be of type m:m. . Summary • Relationships express how entities are connected. • Relationships can be resolved into: – Two new relationships – One intersection entity • Third Normal form is generally accepted standard. • Finally relationships are most often of type m:1. 3-43 Copyright © Oracle Corporation.

. 2002. All rights reserved. Practices • Read the Relationship • Find a Context • Name the Intersection Entity • Receipt • Moonlight P&O • Price List • EMail • Holiday 3-44 Copyright © Oracle Corporation.

Practice: Read the Relationship ALU of BRY with PUR bazooned in YOK bazooned by KLO bilought in HAR glazoed with 3-45 Copyright © Oracle Corporation. . 2002. All rights reserved.

Find a Context (1) 3-46 Copyright © Oracle Corporation. All rights reserved. 2002. .

2002. Find a Context (2) 3-47 Copyright © Oracle Corporation. . All rights reserved.

2002. Find a Context (3) 3-48 Copyright © Oracle Corporation. . All rights reserved.

Find a Context (4) 3-49 Copyright © Oracle Corporation. All rights reserved. 2002. .

All rights reserved. . Practice: Name the Intersection Entity PRODUCT sold by DEPARTMENT STORE selling PERSON crewing SAILBOAT crewed by INTERPRETER fluent in LANGUAGE spoken by 3-50 Copyright © Oracle Corporation. 2002.

60 * 2 7.00 RETURN 1.30 ----------------------- Hope to serve you again @MOONLIGHT COFFEES 25 Phillis Rd. Atlanta 3-51 Copyright © Oracle Corporation.00 <TOTAL> 18. 4:35 pm ----------------------- CAPPUCC M 3.70 ======= CASH 20. All rights reserved.50 APPLE PIE 3. 2002. .70 tax 12% 2.20 CREAM .75 * 2 1. Practice: Receipt Served by: Dennis Till: 3 Dec 8.50 BLACKB MUF 4.50 <SUB> 16.

. There is only one country organization per country. Before that she had a full-time position. for example. except HQ itself. 2002. • All shops belong to one country organization (“the countries”). Practice: Moonlight P&O • All Moonlight Coffee employees work for a department such as “Global Pricing” or “HQ”. All countries and departments report to HQ. All rights reserved. Lynn has had an 80% assignment for Product Development since the 1st September. Jill. 3-52 Copyright © Oracle Corporation. Werner is a financial administrator working for Accounting and is located in Germany. All employees are at the payroll of one of our country organizations. • Employees can work part time. or for a shop. works as a shop manager in London.

20 tea of the day 2.20 3.90 3.10 3.90 2.25 2.25 .75 3-54 Copyright © Oracle Corporation. 25 Phillis Road.com Practice: Price List small medium large regular coffee 2.90 3.20 3.90 3.25 2.00 additional whipped cream .90 special coffee 3. 2002.50 .00 2.60 4.50 soft drinks 2.90 3.25 2.25 1.25 2.75 extra black tea 2.50 fruitcake 4.70 4.50 cake of the day 4.00 decaffeinated .moonlight.50 strawberry cheesecake 3.50 coffee of the day 2.60 4.50 .25 .20 Sales Tax included apple pie 3.90 herbal teas 2.90 3.00 decaffeinated .50 infusions 2.90 3.90 3.25 2.50 September 16 whole wheat oats muffin with almonds 3.50 cappuccino 2.50 3.50 3.20 café latte 2.60 3.60 4.40 espresso 2. .90 3.50 soda water 2.90 blackberry muffin 4.60 3. All rights reserved.75 extra milk 1.50 mineral water 2. Atlanta price list visit us at www.00 2.

2002. Practice: E-Mail FOLDER 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. All rights reserved. . TYPE 3-55 Copyright © Oracle Corporation.

All rights reserved. Eric and I hiked in France and we rented a car in the USA last year. . 2002. Practice: Holiday “Paul and I hiked in the USA.” COUNTRY TRANSPORT France Boots USA Boots USA Car 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 3-56 Copyright © Oracle Corporation.

. All rights reserved. 2002. Practice: Normalize an ER Model ENROLLMENT COURSE grade code course number teacher number for course name grade completed teacher number description with department course name code for department name assigned teacher name STUDENT #* student id last name first name 3-57 Copyright © Oracle Corporation.

. Constraints Copyright © Oracle Corporation. All rights reserved. 2002.

2002. All rights reserved. . Overview • Unique Identifiers • Arcs • Domains • Various other constraints 4-2 Copyright © Oracle Corporation.

. All rights reserved. 2002. Rembrandt 4-3 Copyright © Oracle Corporation.

All rights reserved.4-4 Copyright © Oracle Corporation. . 2002.

M. 02-FEB-1954 HIDE T. Papini. 24-SEP-1958 4-5 Copyright © Oracle Corporation. 2002. 11-JUN-1961 PAPINI G.T.J. Identification and Representation G. please? EMPLOYEES Name Initials Birthdate PAPINI G. All rights reserved. . 02-FEB-1945 BAKER S.

. Telephone number EMPLOYEE Employee number or Name. Unique Identifier Examples JOB Name COMPUTER IN NETWORK IP Address TELEPHONE Country code. All rights reserved. Initials. Birth Date MAIL LIST Name. Area code. 2002. Owner 4-6 Copyright © Oracle Corporation.

2002. Unique Identifier Indicates Unique Identifier CUSTOMER # Family Name ORDER o Initials by # Date # Address responsible o Telephone for Indicates Unique Identifier 4-7 Copyright © Oracle Corporation. . All rights reserved.

2002. . All rights reserved. Unique Identifiers USER # Name part of owner of contains owned by MAIL LIST # Name ROOM FLOOR HOTEL # No # No # Name 4-8 Copyright © Oracle Corporation.

2002. . Multiple Relationship UID 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 4-10 Copyright © Oracle Corporation. All rights reserved.

Well-defined Unique Identifiers 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 4-12 Copyright © Oracle Corporation. All rights reserved. . 2002.

Incorrect Unique Identifiers L F G K # L1 # G1 # F1 # K1 P R # P1 # R1 KL T o # T1 Q # Q1 G H # G1 4-13 Copyright © Oracle Corporation. . All rights reserved. 2002.

0. All rights reserved.093. Information-Bearing Codes 54. . 2002.81 Product Group In Production? Factory Sequence Number PRODUCT PRODUCT GROUP # Code # Code * In Production? * Sequence No FACTORY # Id 4-14 Copyright © Oracle Corporation.

2002. these are standard Conditions Std? conditions or customized conditions” 1 2 3 4 5 CONTRACT STANDARD basis for 6 CONDITION based consists in on of CUSTOMIZED CONDITION Arc in Indicates relationship part of in arc referring to referring to CONTRACT COMPONENT 4-15 Copyright © Oracle Corporation. Arcs Contract “A contract consists of contract components. . All rights reserved.

All rights reserved. 2002. . Exclusive Arc USER owner of owned by LIST is referred to container is referred of to contained referring to in referring to LIST ITEM 4-16 Copyright © Oracle Corporation.

Possible Arc Constructs 4-17 Copyright © Oracle Corporation. 2002. . All rights reserved.

Some Incorrect Arc Constructs • The arc “belongs” to one entity • Relationships in the arc must be of the same optionality • Arcs must contain at least two relationships An arc may be correct.. 4-18 Copyright © Oracle Corporation. but is quite difficult to implement . All rights reserved.. . 2002.

All rights reserved. . Some Incorrect Arc Constructs Number of Valid Relationships in Arc Per Entity Instance Minimum Maximum }n n n }n 1 1 }n 0 n }n 0 1 4-19 Copyright © Oracle Corporation. 2002.

Arc or Subtype 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 4-20 Copyright © Oracle Corporation. 2002. . All rights reserved.

Arc and Subtypes 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 4-21 Copyright © Oracle Corporation. All rights reserved. 2002. .

2002. . All rights reserved. Subtypes Hide Relationships in Arc • Every A • Every A must is either a B or a C be a B or be a C • Every B is an A • Every B must be an A • Every C is an A • Every C must be an A A A is B B is is C C is 4-22 Copyright © Oracle Corporation.

Value sets CODE TYPE # Id YESNO A * Name # Code * Max Length * Description B of Description GENDER # Code * Description CODE # Code WEEKDAY * Description # Code * Description 4-23 Copyright © Oracle Corporation. 2002. . All rights reserved.

. Other Constraints: Range Check EMPLOYEE JOB * Name * Title * Address * Minimum Salary between with * Maximum Salary of for referring to EMPLOYMENT * Start Date o End Date * Salary 4-24 Copyright © Oracle Corporation. 2002. All rights reserved.

All rights reserved. 2002. . Other Constraints: State Value Transition Possible Wid Mar Div to Sin DP Marital Status EMPLOYEE Transitions fro * Name * Address Single m * Current Marital Status Married Widowed Divorced Domestic Partnership 4-25 Copyright © Oracle Corporation.

2002. Conditional Relationship CONTRACT # Id * Standard Indicator STANDARD basis for CONDITION based consists on in of CUSTOMIZED CONDITION in part of referring to referring to CONTRACT COMPONENT 4-26 Copyright © Oracle Corporation. . All rights reserved.

All rights reserved. . 2002. Boundaries EXTERNAL unrelated entity # Id * Description * Value and possible implementation EXTERNALS Id Description Value 1 Value added tax % 15 2 Maximum available Space per Mail User in Mbyte 500 3 Maximum level of Nested Mail Folders 3 4 Maximum level of Nested Mail Lists 16 4-28 Copyright © Oracle Corporation.

All rights reserved. 2002. Summary • 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 4-29 Copyright © Oracle Corporation. .

All rights reserved. Practices • Identification Please • Identification • Moonlight UID • Tables • Modeling Constraints 4-30 Copyright © Oracle Corporation. 2002. .

All rights reserved. show 4-31 Copyright © Oracle Corporation. Practice: Identification Please • A city • A contact person for a customer • A train • A road • A financial transaction • An Academy Award (Oscar) • A painting • A T.V. . 2002.

2002. Practice: Identification 1 A B C # Xx * Yy # Zz 4-32 Copyright © Oracle Corporation. . All rights reserved.

. All rights reserved. Practice: Identification 2 A B C # Id # Code 4-33 Copyright © Oracle Corporation. 2002.

2002. Practice: Identification 3 A * Xx B C with D # Yy # Zz # Id of 4-34 Copyright © Oracle Corporation. . All rights reserved.

. All rights reserved. Practice: Identification 4 P Q # Id 4-35 Copyright © Oracle Corporation. 2002.

Practice: Identification 5

P
# Name

4-36 Copyright © Oracle Corporation, 2002. All rights reserved.

Practice: Identification 6

PERSON
FEMALE
MALE son of # Name
# Seqno mother of # Birth Date

partner in partner in

with husband with wife
MARRIAGE
# Start Date

4-37 Copyright © Oracle Corporation, 2002. All rights reserved.

Practice: Moonlight UID

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

4-38 Copyright © Oracle Corporation, 2002. All rights reserved.

Practice: Table 1

• “In a relational database system, data is stored in
tables. Tables of a database user must have a
unique name. A table must have at least one
column. A column has a unique name within the
table. A column must have a data type and may be
Not Null.
• Tables can have one primary key and any number
of unique keys. A key contains one or more
columns of the table. A column can be part of
more than one key.

4-39 Copyright © Oracle Corporation, 2002. All rights reserved.

Practice: Table 1

A table can have foreign keys. A foreign key always
connects one table with another. A foreign key
consists of one or more columns of the one table that
refers to key columns of the other table.
“The sequence of columns within the key and foreign
key is important.”

4-40 Copyright © Oracle Corporation, 2002. All rights reserved.

Practice: Table 2

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

4-41 Copyright © Oracle Corporation, 2002. All rights reserved.

Practice: Constraints 1

EMPLOYEE
# Name managed by

manager of

4-42 Copyright © Oracle Corporation, 2002. All rights reserved.

Practice: Constraints 2

owned
USER by LIST
owner of
# Name # Name

owned
owner of by NICKNAME
# Alias

4-43 Copyright © Oracle Corporation, 2002. All rights reserved.

Practice: Constraints 3 with subfolder USER # Name FOLDER within Name owner of owned by 4-44 Copyright © Oracle Corporation. All rights reserved. . 2002.

Modeling Change Copyright © Oracle Corporation. All rights reserved. 2002. .

Overview • Date and time • Modeling change over time • Prices change • Journaling 5-2 Copyright © Oracle Corporation. 2002. All rights reserved. .

. Change and Time • Every update means loss of information. • Time in your model makes the model more complex. • Users can work in advance. All rights reserved. 2002. • When do you model date/time as an entity? • What constraints do arise? • How do you handle journaling? 5-3 Copyright © Oracle Corporation. • There are often complex join conditions.

2002. Entity DAY DAY # Date * Public Holiday Indicator first day of starts on TASK ASSIGNMENT for TASK * Duration in Hours in # Id of EMPLOYEE # Name with 5-4 Copyright © Oracle Corporation. All rights reserved. .

Modeling Change EMPLOYEE COUNTRY # Id # Name of in for as ASSIGNMENT # Start Date o End Date 5-6 Copyright © Oracle Corporation. . 2002. All rights reserved.

2002. All rights reserved. Even a Country Has a Life Cycle COUNTRY # Name # Start Date EMPLOYEE * End Date # Id of in life cycle attributes for as ASSIGNMENT # Start Date o End Date 5-8 Copyright © Oracle Corporation. .

. Products and Prices PRODUCT # Id * Name with PRICE = of PRICED PRODUCT= HISTORICAL PRICE PRICE * Price in $ # Start date o End Date 5-10 Copyright © Oracle Corporation. 2002. All rights reserved.

2002. All rights reserved. What Price to Pay? 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 5-11 Copyright © Oracle Corporation. .

2002. All rights reserved. Price List Search 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 5-12 Copyright © Oracle Corporation. .

2002. . All rights reserved. Order for Priced Products 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 5-13 Copyright © Oracle Corporation.

. All rights reserved. 2002. Negotiated Prices 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 5-14 Copyright © Oracle Corporation.

All rights reserved. 2002. . Current Prices PRODUCT PRODUCT PRODUCT # Id # Id # Id * Name * Name * Name * Current Price * Current Price with with with old 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 5-16 Copyright © Oracle Corporation.

All rights reserved. . 2002. Journaling 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 5-17 Copyright © Oracle Corporation.

. Summary • Consider the need for keeping old values • Time in your model is complicated: – Implicit versions – References • Journaling 5-19 Copyright © Oracle Corporation. 2002. All rights reserved.

2002. All rights reserved. . Practices • Shift • Strawberry Wafer • Bundles • Product Structure 5-20 Copyright © Oracle Corporation.

Practice: Shift Museumplein. All rights reserved. March 21 Shift 1 2 3 4 5 Mon 6:30 11:30 16:00 20:30 - 11:30 16:00 20:30 23:00 7:00 11:30 16:00 20:30 - Tue 11:30 16:00 20:30 23:00 7:00 11:30 16:00 20:30 - Wed 11:30 16:00 20:30 23:00 7:00 11:30 16:00 20:30 - Thu 11:30 16:00 20:30 23:00 7:00 11:30 16:00 20:30 - Fri 11:30 16:00 20:30 24:00 8:00 11:30 15:00 18:00 21:00 Sat/Sun 11:30 15:00 18:00 21:00 24:00 5-21 Copyright © Oracle Corporation. . Amsterdam. 2002.

Practice: Strawberry Wafer • Prices are at the same level within a country. • Prices and availability for local specialties are determined by the individual shops. the famous Norwegian Vafler med Jordbær (a delicious wafer with fresh strawberries) is only available in summer. Its price depends on the current local market price of fresh strawberries. global products are re-established once a year. All rights reserved. 2002. . For example. Usually the prices for regular. 5-22 Copyright © Oracle Corporation. prices are determined by the Global Pricing Department.

. de Keyzer.moonlight. Antwerpen prijslijst bezoekt ons op ‘t Web: www. Keyzerlei 15. All rights reserved. 2002.com klein middel groot gewone koffie 60 90 120 cappuccino 90 110 140 Practice: Price list koffie verkeerd 75 100 130 speciale koffies 99 125 150 espresso 60 95 110 koffie van de dag 45 75 100 caffeine vrij 5 10 15 toeslag zwarte thees 60 100 120 vruchten thees 75 110 130 kruiden thees 80 120 140 dag thee 50 85 100 caffeine vrij 5 10 15 toeslag frisdranken 60 100 130 diverse sodas 60 100 130 mineraal water 75 120 140 appel taart 180 inclusief BTW 16 September brusselse wafel 150 portie chocolade bonbons 150 koekje van eigen deeg 120 portie slagroom 30 5-23 Copyright © Oracle Corporation.

plus a blackberry muffin. Practice: Bundles(1) A SweetTreat(tm) consists of a large soft drink plus cake of the day. 5-24 Copyright © Oracle Corporation. A DecafPunch(tm) consists of a regular decaffeinated coffee or a regular decaffeinated tea. A FamilyFeast(tm) consists of two BigBoxes(tm) plus two SweetTreats™ plus a small surprise. 2002. . A SuperSweetTreat(tm) consists of a SweetTreat(tm) plus whipped cream (on the cake). A BigBox(tm) consist of a large coffee of the day plus two cakes of the day. All rights reserved.

Practice: Bundles(2) PRODUCT GROUP # Name classification for classified as PRODUCT # Id * Name 5-25 Copyright © Oracle Corporation. . All rights reserved. 2002.

All rights reserved. 2002. . + Products + Drinks + Coffees Practice: Product Structure Regular Cappuccino Café Latte + Special Coffee Teas + Black Chinese Indian English + Infusions + Herbal Soft drinks Juices Orange Grape + Waters + Sodas + Dairy Products +Foods + Pastry + Candy Bars + Local Specialties +Non Foods Merchandise CDs + Stationary Other + Tickets + Art 5-26 Copyright © Oracle Corporation.

All rights reserved. 2002.Advanced Modeling Topics Copyright © Oracle Corporation. .

. 2002. Overview • Patterns • Drawing conventions • Generic modeling 6-2 Copyright © Oracle Corporation. All rights reserved.

. 2002. All rights reserved. Patterns • Similar structure • Similar rules and constraints? 6-3 Copyright © Oracle Corporation.

2002. Patterns: Master–Detail • Characteristic: consists of An instance of B only exists in the context of an A • Metaphor: Master – Detail A consists of part of B 6-5 Copyright © Oracle Corporation. . All rights reserved.

. Pattern: Basket X A Y Z • Characteristic: B container for various types of items • Items may be of different types • Metaphor: Shopping Basket A X consists of Y part of B Z 6-6 Copyright © Oracle Corporation. 2002. All rights reserved.

. All rights reserved. 2002. Patterns: Hierarchy • Characteristic: manager of / subordinate of • Additional constraints to guard hierarchical nature • Metaphor: Mother–Child A # Id 6-8 Copyright © Oracle Corporation.

All rights reserved. 2002. . Patterns: Chain • Characteristic: preceded by / followed by • Sequence is important • Metaphor: Elephants preceded by B BEAD # Id followed CHAIN by A BEAD # Seqno 6-10 Copyright © Oracle Corporation.

Patterns: Network • Characteristic: pairs Every A can be connected to every A (sometimes: to every other A) • Metaphor: Web Document with Hyperlinks A A A 6-11 Copyright © Oracle Corporation. . 2002. All rights reserved.

All rights reserved. . 2002.6-12 Copyright © Oracle Corporation.

Bill of Material product of PRODUCT COMPOSITION # Code with * Quantity Needed part in in PRODUCTS COMPOSITIONS Code Name Prod_code Part_code Quantity 914.01 604.53 AAAAAAAA 854.54 AAA 854.01 914. All rights reserved.54 914. .55 BBBBBBBB 854.18 1 914.19 1 914.76 915.54 914.54 2 914.56 B 914.56 1 DDDDD 934. 2002.01 604.55 1 CCCCCCC 914.12 3 6-13 Copyright © Oracle Corporation.

54 914. 2002. .54 604.01 914. All rights reserved.Example 854. Bill of Material .55 914.56 604.18 914.19 6-14 Copyright © Oracle Corporation.

. All rights reserved. 2002. Symmetric Relationship GROUP Group_id S # Id 1 S1 consists of 2 1 S2 2 S3 in 2 S4 S 3 S5 3 S6 6-15 Copyright © Oracle Corporation.

2002..) A P Q 6-16 Copyright © Oracle Corporation. All rights reserved. Patterns: Roles • Characteristic: is / is 1:m (or 1:1) relationships • Metaphor: Person–Many Hats (not necessarily concurrent.. .

. Roles PERSON ROLE TYPE roles ROLE PERSON PRESIDENT COUNTRY appointing appointed by MINISTER DEPARTMENT PARTY PARTY LEADER 6-17 Copyright © Oracle Corporation. 2002. All rights reserved.

All rights reserved. . 2002. Fan Trap • Characteristic: ring of m:m related entities • Metaphor: ABC Combination A B A B C AB AC BC C 6-18 Copyright © Oracle Corporation.

Fan Trap Resolved A B C A B C A B C AB BC ABC ABC ABC AB functions as BC functions as list of values list of values 6-19 Copyright © Oracle Corporation. All rights reserved. . 2002.

All rights reserved. many. Patterns: Data Warehouse • Characteristic: multidimensional. . many detail instances • Metaphor: star model Stars may be strangely shaped: • Snowflake model July B C A X D F E 6-20 Copyright © Oracle Corporation. 2002.

as long as you follow one of them 6-21 Copyright © Oracle Corporation. Drawing Conventions high volumes high volumes Not important which convention you choose. 2002. . All rights reserved.

All rights reserved. Use Conventions Sensibly But: Readability first 6-22 Copyright © Oracle Corporation. . 2002.

2002. . All rights reserved. Model Readability B A B A C E C D F E D • Takes space • Subject to taste F 6-23 Copyright © Oracle Corporation.

All rights reserved. .. 6-24 Copyright © Oracle Corporation. Generic Modeling MANUFACTURER MANUFACTURER ARTICLE * Name * Name TYPE FILM ARTICLE * AsaTRIPOD o Weight * Height LENS o Focal Distance CAMERA o Height * Focal BODY o Asa Number Distance * Weight o .. 2002.

2002.. All rights reserved. o Property5 o Property6 o Property7 MANUFACTURER o Property8 * Name 6-25 Copyright © Oracle Corporation.. . Generic Modeling ARTICLE TYPE ARTICLE * Definition Prop1 o Property1 o Definition Prop2 o Property2 o Definition Prop3 o Property3 o Definition Prop4 o Property4 .

2002. Generic Model ARTICLE TYPE ARTICLE PROPERTY ARTICLE PROPERTY VALUE o Value 6-26 Copyright © Oracle Corporation. All rights reserved. .

2002. All rights reserved. Generic having some kind of relationship with THING having some kind of relationship with 6-27 Copyright © Oracle Corporation. .

All rights reserved. More Generic THING ASSOCIATION 6-28 Copyright © Oracle Corporation. . 2002.

More Generic Plus THING TYPE ASSOCIATION TYPE THING ASSOCIATION 6-29 Copyright © Oracle Corporation. . 2002. All rights reserved.

Most Generic?

THING TYPE ASSOCIATION
TYPE

THING
ASSOCIATION
PROPERTY

THING PROPERTY VALUE

6-30 Copyright © Oracle Corporation, 2002. All rights reserved.

Best of Two Worlds

‘generic’
CUSTOMER

ARTICLE TYPE

ORDER HEADER

ARTICLE PROPERTY

ORDER ITEM

‘down to earth’
ARTICLE PROPERTY VALUE

6-31 Copyright © Oracle Corporation, 2002. All rights reserved.

Summary

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

6-32 Copyright © Oracle Corporation, 2002. All rights reserved.

Practices

• Patterns
• Data Warehouse
• Argos and Erats
• Synonym

6-33 Copyright © Oracle Corporation, 2002. All rights reserved.

Practice: Patterns

• Model of moves in a chess game
• Model of tenders (quotations)
• Model of recipes
• Model of all people involved in college: students,
teachers, parents, …
• Rentals in a video shop
• Model of phases in a process

6-34 Copyright © Oracle Corporation, 2002. All rights reserved.

Practice: Data Warehouse

• What is the sales volume in $ of coffee last month
compared with the coffee sales volume same
month last year?
• What is the sales volume in $ of coffee per head in
Japan compared with the average coffee sales
volume in the Moonlight countries around the
world?
• What is the growth of the sales volume in $ of
coffee in Sweden compared with the growth of
sales volume of all products in the same
geographical area? What is the growth in local
currency?

6-35 Copyright © Oracle Corporation, 2002. All rights reserved.

Practice: Data Warehouse

• What was the total sales volume in $ of coffee last
month, compared with the total coffee sales
volume in the same month last year, for the shops
that have been open for at least 18 months?
• What is the growth of the sales volume in $ of
nonfoods compared to that of foods?
• What is the best day of the week for total sales in
the various countries? How is that related to the
average? Is the best day of the week dependent
on the type of location?

6-36 Copyright © Oracle Corporation, 2002. All rights reserved.

Practice: Data Warehouse

• What products are most profitable per country?
Globally?
• Does the service level (#employees per 1000 items
sold) have influence on sales?

6-37 Copyright © Oracle Corporation, 2002. All rights reserved.

Erats mutually have rondels. or combinations of the two. Erats can have one or more ubins." 6-38 Copyright © Oracle Corporation. All rights reserved. Argos have names as well. 2002. A ubin always consists of one or more argos of the erat. Erats can have argos. There are only a few different types of rondels. one or more rondels of the erat. The name of an argo must be unique within the erat it belongs to. Practice: Argos and Erats "Erats have names that are unique. .

2002.exercise order . Practice: Synonym practice . .demand 6-39 Copyright © Oracle Corporation.arrangement command . All rights reserved.sequence order .command entity .being order .

. 2002. All rights reserved.Mapping the Entity Model Copyright © Oracle Corporation.

. Overview • Why use design modeling? • Introduction to the components: – Tables – Columns – Constraints • Basic Mapping • Complex mapping 7-2 Copyright © Oracle Corporation. All rights reserved. 2002.

. Why Create a Data Design Model? • Closer to the implementation solution • Facilitates discussion • Ideal model can be adapted to an RDBMS model • Sound basis for physical database design 7-3 Copyright © Oracle Corporation. 2002. All rights reserved.

OXFORD ST 03-03-66 10 rows 349 PAPINI 53. 2002. All rights reserved. . Presenting Tables Table: EMPLOYEES columns Id Name Address Birth_date Dpt_id 126 PAGE 12. HAYES AVE 10-08-77 20 785 GARRET 08-12-55 10 primary key unique key foreign key column column column EMPLOYEES (EPE) pk * Id Table diagram: EMPLOYEES uk1 * Name o Address foreign uk1 * Birth_date key fk * Dpt_id 7-4 Copyright © Oracle Corporation.

2002. Transformation Process Conceptual Model Relational Model 7-6 Copyright © Oracle Corporation. All rights reserved. .

Terminology Mapping ANALYSIS DESIGN ER Model Physical Design Entity Table Attribute Column Primary UID Primary Key Secondary UID Unique Key Relationship Foreign Key Business Constraints Check Constraints 7-7 Copyright © Oracle Corporation. 2002. All rights reserved. .

General Naming Topics

Decide on a convention for:
• Table names
• Special characters (%, *, #, -, space, …)
• Table short names
• Column names
• Primary and Unique Key Constraint names
• Foreign Key Constraint names
• Foreign Key Column names

7-8 Copyright © Oracle Corporation, 2002. All rights reserved.

Naming Restrictions with Oracle

• Table and column names:
– Must start with a letter
– May contain up to 30 alphanumeric characters
– Cannot contain space or some special characters
such as “!”
• Table names must be unique within a schema
• Column names must be unique within a table

7-11 Copyright © Oracle Corporation, 2002. All rights reserved.

Basic Mapping for Entities

1 - Entities

Table Name: EMPLOYEES
Short Name: EPE

EMPLOYEES (EPE)
EMPLOYEE

7-12 Copyright © Oracle Corporation, 2002. All rights reserved.

Basic Mapping for Attributes

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

7-13 Copyright © Oracle Corporation, 2002. All rights reserved.

Basic Mapping
for Unique Identifiers

1 - Entities
2 - Attributes
3 - Unique identifiers Table Name: EMPLOYEES
Short Name: EPE

Primary EMPLOYEES (EPE)
EMPLOYEE
UID # Id pk * Id
* Name uk1 * Name
o Address o Address
uk1 * Birth_date
* Birth Date
Secondary
UID

7-14 Copyright © Oracle Corporation, 2002. All rights reserved.

Rules for Relationships

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

7-16 Copyright © Oracle Corporation, 2002. All rights reserved.

Mapping 1:m Relationships

XS

fk o Y_id

XS

fk * Y_id

7-17 Copyright © Oracle Corporation, 2002. All rights reserved.

Mapping Barred and Nontransferable
Relationships

X Y
# Id
* C1 # Id
* C2

XS (X) YS (Y)

pk * Id fk = y_x_fk pk * Id
* C1 pk, fk * X_id
* C2

7-19 Copyright © Oracle Corporation, 2002. All rights reserved.

.pk * A_id fk. Mapping Cascade Barred Relationships A B C D # Id # Id # Id # Id * C1 * C2 * C3 * C4 AS (A) BS (B) CS (C) DS (D) pk * Id pk * Id pk * Id pk * Id * C1 * C2 * C3 * C4 fk. 2002.pk * B_a_id fk * C_b_id fk = b_a_fk fk * C_a_id fk = c_b_fk fk = d_c_fk 7-20 Copyright © Oracle Corporation. All rights reserved.pk * B_id fk * C_id fk.

All rights reserved. 2002. Mapping m:m Relationships 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 7-21 Copyright © Oracle Corporation.

Mapping 1:1 Relationships X Y # Id # Id * C1 * C2 YS (Y) XS (X) fk = y_x_fk pk * Id pk * Id * C2 * C1 fk. 2002. All rights reserved. .uk * X_id Choose which side for FK for other cardinalities 7-22 Copyright © Oracle Corporation.

2002. . Mapping Arcs Explicit implementation USER # Id LIST ITEM * Name 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 7-23 Copyright © Oracle Corporation. All rights reserved.

All rights reserved. . Mapping Subtypes Variety of implementation choices P K # Id # Id * Xxx Q A • Supertype o Yyy # Id • Subtype • Both Supertype R B and Subtype (“Arc”) * Zzz # Id L # Id 7-25 Copyright © Oracle Corporation. 2002.

Supertype Implementation 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 7-27 Copyright © Oracle Corporation. 2002. . All rights reserved.

. All rights reserved. 2002. Subtype Implementation 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 7-29 Copyright © Oracle Corporation.

Supertype and Subtype (Arc) Implementation PS (P) P K # Id pk * Id # Id * Xxx * Xxx fk1.uk o Q_id fk3 = A R_id p_a_fk Q 1 o o Yyy # Id fk2. 2002. All rights reserved. .uk * A_id 2 fk3 R B * Zzz # Id fk1 = fk2 = p_q_fk p_r_fk QS (Q) RS (R) L pk * Id pk * Id r_b_fk # Id o Yyy * Zzz fk * B_id 7-31 Copyright © Oracle Corporation.

2002. P Storage Implication Q R 1 table 2 tables 3 tables 7-33 Copyright © Oracle Corporation. All rights reserved. .

Storage Implication Supertype Implementation discriminator column cols cols cols P P Q R Q rows Q R rows R 7-34 Copyright © Oracle Corporation. . All rights reserved. 2002.

. 2002. Storage Implication Subtype Implementation cols cols cols cols P R P Q rows Q rows R 7-35 Copyright © Oracle Corporation. All rights reserved.

Storage Implication Supertype and Subtype (Arc) Implementation cols P fk cols fk cols rows Q Q R rows Q rows R rows R 7-36 Copyright © Oracle Corporation. . 2002. All rights reserved.

. 2002. Summary • Relational concepts • Naming rules convention • Basic mapping • Complex mapping 7-37 Copyright © Oracle Corporation. All rights reserved.

2002. . Attributes and Relationships • Mapping Supertype • Quality Check Subtype Implementation • Quality Check Supertype and Subtype (Arc) Implementation • Mapping Primary Keys and Columns 7-38 Copyright © Oracle Corporation. All rights reserved. Practice • Mapping basic Entities.

Practice: Mapping basic Entities. Attributes and Relationships EMPLOYEE assigned DEPARTMENT # Id to * First Name # Id * Last Name * Name * Date of Birth responsible * Location o Home Phone for EMPLOYEES ( ) DEPARTMENTS ( ) 7-39 Copyright © Oracle Corporation. All rights reserved. 2002. .

Practice: Mapping Supertype reporting to report of DEPARTMENT report # Id HQ COUNTRY of * Name * ORGANIZATION Address reporting # Tax Id Number * Head Count to OTHER DEPARTMENT DEPARTMENTS ( ) 7-40 Copyright © Oracle Corporation. All rights reserved. . 2002.

Partial ER model Moonlight COUNTRY # Code with PRODUCT GROUP with in # Name with SHOP with in # No PRODUCT * Name for * Address GLOBAL of PRICE LIST * City # Code LOCAL # Start Date o Size # Name * End Date with with in of GLOBAL PRICE * Amount 7-41 Copyright © Oracle Corporation. All rights reserved. . 2002.

2002. All rights reserved. . Practice: Quality Check Subtype Implementation lpt_shop_fk GLOBAL_PRODUCTS (GPT) LOCAL_PRODUCTS (LPT) pk * Code pk # Name o Size fk * Shop_no * Pgp_name fk * Pgp_name 7-42 Copyright © Oracle Corporation.

All rights reserved. Practice: Quality Check Arc Implementation PRODUCTS (PDT) fk1=pdt_pgp_name pk * Code fk2=pdt_gpt_code fk1 * Pgp_name fk2 * Gpt_code fk3=pdt_lpt_name fk3 * Lpt_name 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 7-43 Copyright © Oracle Corporation. 2002.

Practice: Mapping Primary Keys and Columns GLOBAL_PRICES ( ) 7-44 Copyright © Oracle Corporation. All rights reserved. 2002. .

2002. Denormalized Data Copyright © Oracle Corporation. . All rights reserved.

. All rights reserved. 2002. Overview • Denormalization • Benefits • Types of denormalization 8-2 Copyright © Oracle Corporation.

All rights reserved. Denormalization Overview Denormalization • Starts with a “normalized” model • Adds “redundancy” to the design • Reduces the “integrity” of the design • Application code added to compensate 8-3 Copyright © Oracle Corporation. 2002. .

2002. Denormalization Techniques • Storing Derivable Values • Pre-joining Tables • Hard-Coded Values • Keeping Details with Master • Repeating Single Detail with Master • Short-Circuit Keys 8-4 Copyright © Oracle Corporation. . All rights reserved.

Storing Derivable Values Before A B pk * Id pk. 2002. . A After pk * Id * X * Total_quantity 8-5 Copyright © Oracle Corporation. All rights reserved.fk * A_id * X pk * Sequence_No * Quantity Add a column to store derivable data in the “referenced” end of the foreign key.

All rights reserved. MESSAGES (MSE) After pk * Id * Subject * Text * Number_of_times_received 8-6 Copyright © Oracle Corporation. EMail Example of Storing Derivable Values Before REC_MESSAGES (RME) MESSAGES (MSE) USERS (USR) pk.fk * Usr_Id pk * Id pk * Id Subject pk. 2002. .fk * Mse_Id * * Per_name * Text Store derivable column in the ‘referenced’ end of the foreign key.

All rights reserved. Pre-Joining Tables Before B A pk pk * Id * Id fk * A_id * Col_a Add the non_key column to the table with the foreign key. 2002. B After pk * Id fk * A_id * A_col_a 8-7 Copyright © Oracle Corporation. .

fk * Mse_id pk.fk * Flr_id * Date_receive * d Fdr_Name 8-8 Copyright © Oracle Corporation. 2002. . EMail Example of Pre-Joining Tables Before FOLDERS (FDR) RECEIVED_MESSAGES (RME) pk.fk * Flr_id Name * Date_received Create a table with all the frequently queried columns.fk * Mse_id pk * Id * pk. RECEIVED_MESSAGES (RME) After pk. All rights reserved.

. Hard-Coded Values Before B A pk Id pk * Id * Type fk * A_i * d Remove the foreign key and hard code the allowable values and validation in the application. After B pk * Id * A_Type 8-9 Copyright © Oracle Corporation. All rights reserved. 2002.

2002. Email Example of Hard-Coded Values Before USERS (USR) BUSINESS_TYPES (BTE) pk * Id pk * Id fk * Bte_id Name * Per_name Hard code the allowable values and validation in the application. . After USERS (USR) pk * Id * Business_type * Per_name 8-10 Copyright © Oracle Corporation. All rights reserved.

fk * A_id pk * Id pk * Type * Amount Add the repeating detail columns to the master table. 2002. . All rights reserved. Keeping Details with Master Before B A pk. A After pk * Id * Amount_1 * Amount_2 * Amount_3 * Amount_4 * Amount_5 * Amount_6 8-11 Copyright © Oracle Corporation.

fk * Usr_Id pk * Id pk * Storage_type * Name * Allocated * Available Add the repeating detail columns to the master table. All rights reserved. EMail Example Keeping Detail with Master Before STORAGE_QUOTAS (SQA) USERS (USR) pk. USERS (USR) After pk * Id * Name * Message_Quota_Allocated * Message_Quota_Available * File_Quota_Allocated * File_Quota_Available 8-12 Copyright © Oracle Corporation. . 2002.

A After p * Id k * Current_price 8-13 Copyright © Oracle Corporation.fk * A_Id pk * Id pk Start_date * Price * Add a column to the master to store the most current details. 2002. . Repeating Current Detail with Master Before B A pk. All rights reserved.

2002. EMail Example of Repeating Single Detail with Master Before MESSAGES (MSE) ATTACHMENTS (ATT) pk * Id pk * Id * Subject pk. MESSAGES (MSE) After pk * Id * First_attachment_name * Subject * Text 8-14 Copyright © Oracle Corporation. All rights reserved. .fk * Mse_id * Text * Name Add a column to the master to store the most current details.

2002. . All rights reserved. A B C After pk Id pk * Id * pk * Id fk * A_id fk * B_id fk * A_id 8-15 Copyright © Oracle Corporation. Short-Circuit Keys Before B C A pk * Id pk * Id pk * Id fk A_id fk * B_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 8-16 Copyright © Oracle Corporation. All rights reserved. 2002. . EMail Example of Short-Circuit Keys Before RECEIVED_ USERS (USR) FOLDERS (FDR) MESSAGES (RME) pk * Id pk * Name pk * Id * Name fk * Usr_id fk * Fdr_name Create a new foreign key from the lowest detail to the highest master.

B After pk.fk * A_Id pk * Start_date o End_date 8-17 Copyright © Oracle Corporation. All rights reserved. . End Date Column Before B A pk.fk * A_id pk * Id pk * Start_date Add an end date column to speed up queries so that they can use a between operator. 2002.

.fk * Pdt_id pk * Id pk * Start_date * Name Price * Create an extra column derivable End_date column.fk * Pdt_id pk * Start_date * Price o End_date 8-18 Copyright © Oracle Corporation. After PRICES (PCE) pk. Example of End Date Column Before PRICES (PCE) PRODUCTS (PDT) pk. All rights reserved. 2002.

fk * A_id pk * Id pk * Start_date Add a column to represent the most current record in a long list of records. All rights reserved.fk * A_Id pk * Start_date o Current_indicator 8-19 Copyright © Oracle Corporation. After B pk. Current Indicator Column Before A B pk. 2002. .

. in a long list of records. Example of Current Indicator Column Before PRICES (PCE) PRODUCT (PDT) pk.fk * Pdt_id pk * Id pk * Start_date * Name Price * Add a column to represent the most current record. PRICES (PCE) After pk.fk * Pdt_id pk * Start_date * Price o Current_indicator 8-20 Copyright © Oracle Corporation. All rights reserved. 2002.

After A pk * Id fk * A_id * Level_no 8-21 Copyright © Oracle Corporation. 2002. Hierarchy Level Indicator Before A pk * Id fk * A_id Create a column to represent the hierarchy level of a record. All rights reserved. .

. All rights reserved. 2002. After FOLDERS (FDR) pk * Id fk * Fdr_id * Name * Level_no 8-22 Copyright © Oracle Corporation. Example of Hierarchy Level Indicator Before FOLDERS (FDR) pk * Id fk * Fdr_id * Name Create a column to represent the hierarchy level of a record.

All rights reserved. 2002. . Denormalization Summary 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 8-23 Copyright © Oracle Corporation.

Practices • Name that Denormalization • Triggers • Denormalize Price Lists • Global Naming 8-24 Copyright © Oracle Corporation. 2002. . All rights reserved.

. Practice: Name that Denormalization (1/3) SHIFTS (SFT) WEEKDAYS (WDY) pk * No pk * Code fk * Wdy_code * Name Start_time * * End_time * Wdy_name 8-25 Copyright © Oracle Corporation. All rights reserved. 2002.

2002. Practice: Name that Denormalization (2/3) PROD_GRPS (PGP) PRODUCTS (PDT) PROD_NAMES (PNE) pk * Name pk * Code pk * Name fk * Pgp_Name fk * Pdt_code fk * Pgp_name 8-26 Copyright © Oracle Corporation. All rights reserved. .

fk * Cty_code pk * Code pk Start_date * * Name o End_date * Current_price_ind 8-27 Copyright © Oracle Corporation. . 2002. Practice: Name that Denormalization (3/3) PRICE_LISTS (PLT) COUNTRIES (CTY) pk. All rights reserved.

2002. Practice: Triggers (1/6) ORDER_HEADERS (OHR) ORDER_ITEMS (OIM) pk * Ohr_id pk * Id pk * Seqno * Order_total * Item_total 8-28 Copyright © Oracle Corporation. . All rights reserved.

2002. Practice: Triggers (2/6) Table Trg Type Column Needed? What should it do? OHR Insert Delete Update Id Order_total OIM Insert Delete Update Ohr_id Item_total 8-29 Copyright © Oracle Corporation. . All rights reserved.

All rights reserved. 2002. Practice: Triggers (3/6) LOCATIONS (LCN) EMPLOYEES (EPE) pk * Id pk * Id fk * Lcn_id * Name * Address * Lcn_address 8-30 Copyright © Oracle Corporation. .

2002. All rights reserved. Practice: Triggers (4/6) Table Trg Type Column Needed? What should it do? LCN Insert Delete Update Address other cols EPE Insert Delete Update Lcn_id Lcn_address 8-31 Copyright © Oracle Corporation. .

. Practice: Triggers (5/6) PRODUCTS (PDT) PRICES (PCE) pk * Pdt_id pk * Id pk * Start_date * Name o End_date * Curr_price_ind 8-32 Copyright © Oracle Corporation. All rights reserved. 2002.

2002. All rights reserved. . Practice: Triggers (6/6) Table Trg Type Column Needed? What should it do? PDT Insert Delete PCE Insert Delete Update Pdt_id Start_date End_date Curr_price_Ind 8-33 Copyright © Oracle Corporation.

fk * Cty_code pk. PRICE_LISTS (PLT) GLOBAL_PRICES (GPE) pk * Start_date pk. .fk Plt_cty_code * Amount * 8-34 Copyright © Oracle Corporation. All rights reserved.fk * Plt_start_date pk. 2002. • Insert new price lists before their effective date. Practice: Denormalize Price Lists • Speed up performance for queries on Amount.

fk * Pdt_code o Size pk. * Name PRODUCT_NAMES (PNE) PRODUCTS (PDT) pk * Code pk. All rights reserved. . Practice: Global Naming LANGUAGES (LGE) Track a corporate pk * Code name for each product.fk Lge_code * Name * 8-35 Copyright © Oracle Corporation. 2002.

. 2002.Database Design Considerations Copyright © Oracle Corporation. All rights reserved.

Overview • Oracle specific Design Considerations • Data Integrity Issues • Performance Considerations • Storage Issues 9-2 Copyright © Oracle Corporation. . All rights reserved. 2002.

S. 2002. . All rights reserved. • Oracle specifics 9-3 Copyright © Oracle Corporation. Why Adapt Data Design? • User Expectations • Volumes Adapted • Hardware Physical • Network Initial design Design • O.

Oracle Data Types Depending on: • Domains • Storage issue • Performance • Use Select a data type for columns: • Character • Number • Date • Large Objects 9-4 Copyright © Oracle Corporation. All rights reserved. . 2002.

2002. Suggested Column Sequence • Primary key columns • Unique Key columns • Foreign key columns • Mandatory columns • Optional columns Large object columns always at the end 9-6 Copyright © Oracle Corporation. All rights reserved. .

All rights reserved. . Constraint and Index name 9-7 Copyright © Oracle Corporation. 2002.2) NOT NULL ). ALTER TABLE countries ADD CONSTRAINT cty_pk PRIMARY KEY (code). currency NUMBER (10. Primary Keys CREATE TABLE countries ( code NUMBER(6) NOT NULL . name VARCHAR2(25) NOT NULL .

. Primary Keys Choosing the Right Key • Simplicity • Ease of use • Performance • Size • Meaningless • Stability 9-9 Copyright © Oracle Corporation. 2002. All rights reserved.

fk1 * A_id 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 9-11 Copyright © Oracle Corporation.fk2 * B_id XS (X) u pk . Artificial Keys AS (A) BS (B) CS (C) pk * Id pk * Id pk * Id * C1 * C2 * C3 fk1 = d_a_fk fk2 = d_b_fk fk3 = d_c_fk DS (D) u pk . 2002. . All rights reserved.

9-13 Copyright © Oracle Corporation. 2002. Sequences 225 224 223 CREATE SEQUENCE sequence_name INCREMENT BY number START WITH number MINVALUE number MAXVALUE number CACHE number | NOCACHE CYCLE | NOCYCLE. All rights reserved. .

. All rights reserved. 2002. Foreign Key Behavior Delete Update Restrict Cascade Default Nullify Supported by Oracle through declaration 9-14 Copyright © Oracle Corporation.

2002. Indexes • Performance Name Phone b c ALBERT 2655 d ALFRED 3544 ef gh ij ALICE 7593 kl m ALLISON 3456 no pq ALVIN 8642 rs tu ALPHONSO 2841 vw xyz • Uniqueness 9-16 Copyright © Oracle Corporation. . All rights reserved.

5 abb .1.3. 1 0 0 .4.1.1.O.5 0 1 0 abb . All rights reserved. .1.5 bba . 2002..1.2.5 cba .4.3.5 1 0 0 abc ..1.Table aba X abc Y abb Z aba X abc Y abb Z bba Z bba X bbc X bbc Z 9-17 Copyright © Oracle Corporation.2.5 .5 0 0 1 bba .. 0 0 1 C1 C2 C1 C2 I.1.1.5 Reverse X Y Z aba .1.. Choosing Indexes B*tree Bitmap aba .1.

All rights reserved. . Which Columns to Index? • Primary key columns and Unique Key columns (Up to Version 6) • Foreign Key columns • When significant better performance can be observed in SELECT statements ! Avoid indexing: • Small tables • Columns frequently updated 9-19 Copyright © Oracle Corporation. 2002.

All rights reserved. When Can Indexes be Used? • When referenced in a Where clause or Order By • When the Where clause does not include some operators • When the optimizer decides • With hints in the SQL statement 9-21 Copyright © Oracle Corporation. . 2002.

2002. All rights reserved. . Partitioning Tables and Indexes CUSTOMERS Col1 Col2 Col3 Region CUSTOMERS_R1 Col1 Col2 Col3 Region CUSTOMERS_R2 Col1 Col2 Col3 Region 9-22 Copyright © Oracle Corporation.

2002. All rights reserved. Views • Restricting access • Presentation of data • Isolate applications from data structure • Save complex queries • Simplify user commands T1 T2 T3 T4 V1 V2 V3 V4 9-23 Copyright © Oracle Corporation. .

Reasons for Views • Advantages – Dynamic views – Present denormalized data from normalized tables – Simplify SQL statements • Disadvantages – May affect performances – Restricted DML in some cases 9-24 Copyright © Oracle Corporation. All rights reserved. 2002. .

All rights reserved. 2002. . Old Fashioned Design • Unique index • Views with “Check option” clause • Generic Arc implementation 9-25 Copyright © Oracle Corporation.

2002. * Table_name (X or Y) * Fk_id 9-26 Copyright © Oracle Corporation. All rights reserved... Generic Arc Implementation X A # Id # Id * Name * Name Y # Id * Name AS (A) . .

2002. Distributed Database Different physical databases appear as one logical database. . All rights reserved. 9-27 Copyright © Oracle Corporation.

All rights reserved. distributed. Benefits of Distributed Databases • Resilience • Reduced line traffic • Location transparency • Local autonomy • Easier growth path but • Increased. . complexity 9-28 Copyright © Oracle Corporation. 2002.

DATABASE Database Structure consists of part of TABLESPACE consists of resides in container part of of SEGMENT OTHER TABLE INDEX SEGMENT SEGMENT SEGMENT sliced in sliced in consists residence of located in part of part of of TABLE OR INDEX PARTITION part of DATA FILE EXTENT USED FREE consists resides in of part of residence of DATA BLOCK 9-29 Copyright © Oracle Corporation. 2002. All rights reserved. .

2002. Summary • Data Types • Primary. Foreign. All rights reserved. and Artificial Keys • Indexes • Partitioning • Views • Distributed design 9-31 Copyright © Oracle Corporation. .

. 2002. All rights reserved. Practices • Data Types • Artificial Keys • Product Pictures 9-32 Copyright © Oracle Corporation.

CURRENCY of COUNTRY Moonlight Pricing # Code # Code with in in with with PRODUCT GROUP in # Name with SHOP from to with # No EXCHANGE in * Name RATE PRODUCT * Address # Month of * City * Rate for GLOBAL LOCAL PRICELIST # Code # Name # Start Date o Size with * End Date with with with of LOCAL PRICE LANGUAGE in # Start Date # Code of o End Date of GLOBAL of * Amount PRICE in * Amount PRODUCT NAME * Name 9-33 Copyright © Oracle Corporation. 2002. . All rights reserved.

2) Pdt_type Number(1) 9-34 Copyright © Oracle Corporation. . 2002. Data Types (1) Table Column Suggested Your Choice Data Type Data Type COUNTRIES Code Varchar2(2) CURRENCIES Code Varchar2(3) EXCHANGE_RATES Month Date Rate Number(8.4) PRICE_LISTS Start_date Date End_date Date PRODUCT_GROUPS Name Char(8) PRODUCTS Code Char(10) Size Number(4. All rights reserved.

All rights reserved. . Data Types (2) Table Column Your Choice Data Type GLOBAL_PRICES Amount LOCAL_PRICES Start_date End_date Amount SHOPS Name Address City 9-35 Copyright © Oracle Corporation. 2002.

. All rights reserved. 2002. Solutions Copyright © Oracle Corporation.

SINGER. Gorbachev ELLA FITZGERALD I STAR. ... TYPE OF TRANSPORT E CAR Number of Wheels A CAR My current car I CAR A-2 Copyright © Oracle Corporation. Solution: Instance or Entity? Concept E/A/I? Example Instance or Entity PRESIDENT E Lincoln.. . 2002. Washington. PERSON DOG E Snoopy ANIMAL E Cat. . All rights reserved. BUILDING. Dog. HEIGHT A PERSON..

. Solution: Guest Address Arrival Date Family Name GUEST Room Number HOTEL Floor Number ROOM Number of Beds Number of Parking Lots Price TV set available? A-3 Copyright © Oracle Corporation. All rights reserved. 2002.

Solution: Reading EMPLOYEE assigned to DEPARTMENT responsible for A Each EMPLOYEE may be assigned to one or more DEPARTMENTS Each DEPARTMENT must be responsible for one or more EMPLOYEES B Each EMPLOYEE must be assigned to one or more DEPARTMENTS Each DEPARTMENT may be responsible for one or more EMPLOYEES C Each EMPLOYEE must be assigned to exactly one DEPARTMENT Each DEPARTMENT may be responsible for exactly one EMPLOYEE A-4 Copyright © Oracle Corporation. . 2002. All rights reserved.

2002. Practice: Read and Comment PERSON born in TOWN birthplace of living in home town of visitor of visited by mayor of governed by (as mayor) A-5 Copyright © Oracle Corporation. All rights reserved. .

2002. Solution: Hotel HOTEL * Address location for favored located in owned known by by by ROOM * Room Number location for owner aware in favor of of of taking place in STAY endured by PERSON * Arrival Date * Name enduring A-6 Copyright © Oracle Corporation. All rights reserved. .

Ralph’s Raving Recipes 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. 2002. cut it in half. Wash the red pepper. All rights reserved. pepper 9-12 slices of (old) bread preparation Cut the onion into small pieces and fry together with the garlic. remove the seeds and fry it for at least 15 page 127 A-7 Copyright © Oracle Corporation. .

pepper 9-12 slices of (old) bread preparation Cut the onion into small pieces and fry together with the garlic. . cut it in half. All rights reserved. Ralph’s Raving Recipes 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. 2002. Wash the red pepper. remove the seeds and fry it for at least 15 page 127 A-8 Copyright © Oracle Corporation.

All rights reserved. BOOK Solution: Recipe -Title a RECIPE must be classified in containing exactly one RECIPE GROUP published in A RECIPE GROUP may be RECIPE classification for one or more -Name RECIPES -Description -Vegetarian? -Number of People classified in RECIPE -Preparation Time -Preparation Ease GROUP classification -Preparation Text for -Name prepared used with in INGREDIENT a RECIPE must be prepared with -Name one or more INGREDIENTS -Quantity -Unit An INGREDIENT may be used in -Type exactly one RECIPE A-9 Copyright © Oracle Corporation. 2002. .

Solution: Books MANUSCRIPT LANGUAGE TRANSLATION TITLE EDITION PRINTING VERSION COPY A-10 Copyright © Oracle Corporation. All rights reserved. 2002. .

2002. Solution: Books MANUSCRIPT LANGUAGE TRANSLATION TITLE EDITION PRINTING VERSION COPY A-11 Copyright © Oracle Corporation. All rights reserved. .

. Solution: Moonlight 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 A-12 Copyright © Oracle Corporation. All rights reserved. 2002.

Solution: Shops SHOP in COUNTRY * Number * Code * Name of * Name * Location * City located o Telephone in LOCATION TYPE * Open Date * Description of or COUNTRY * Code * Name SHOP * Number of * Name in LOCATION located located o Telephone in LOCATION in TYPE * Open Date * Name * Description of of A-13 Copyright © Oracle Corporation. All rights reserved. 2002. .

2002. Solution: Subtypes DISABLED CAR PERSON STATION WAGON DEAF AND BLIND SEDAN OTHER DEAF. NOT BLIND CAR BLIND. . All rights reserved. NOT DEAF OTHER DISABLED BUILDING HOUSE OTHER HOTELROOM DOG pa ir ROOM WITH BATH DOMESTIC re n ANIMAL d e yo b OTHER ROOM MAMMAL A-14 Copyright © Oracle Corporation.

Solution: Schedule (1/2) SHOP * Name * Location * City with for SCHEDULE prepared by EMPLOYEE * Start Date * Family Name * End Date maker of * First Name with * Short Name withi n SCHEDULE for ENTRY * Weekday with * Shift Number A-15 Copyright © Oracle Corporation. . 2002. All rights reserved.

2002. All rights reserved. . Solution: Schedule (2/2) with within SCHEDULE for ENTRY * Monday Shift with * Tuesday Shift * Wednesday Shift * Thursday shift * Friday Shift * Saturday Shift * Sunday Shift A-16 Copyright © Oracle Corporation.

Solution: Address 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 A-17 Copyright © Oracle Corporation. . 2002. All rights reserved.

All rights reserved. . 2002. Solution: Read the Relationship Every ALU must be of ALU of BRY exactly one BRY with Every BRY may be with one or more ALUS Every PUR may be bazooned in PUR bazooned in YOK one or more YOKS Every YOK may be bazooned by bazooned by one or more PURS KLO bilought in Every KLO must be bilought in one or HAR more HARS glazoed with Every HAR may be glazoed with exactly one KLO A-19 Copyright © Oracle Corporation.

. 2002. All rights reserved. Solution: Find a Context birthplace of PERSON COUNTRY born in location of TOWN located in 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 A-20 Copyright © Oracle Corporation.

All rights reserved. 2002. . Solution: Name the Intersection Entity 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 A-21 Copyright © Oracle Corporation.

Solution: Receipt Served by: Dennis Till: 3 Dec 8.30 ----------------------- Hope to serve you again @MOONLIGHT COFFEES 25 Phillis Rd.20 CREAM . All rights reserved. 4:35 pm ----------------------- CAPPUCC M 3.50 APPLE PIE 3.00 RETURN 1.70 tax 12% 2.50 BLACKB MUF 4. Atlanta A-22 Copyright © Oracle Corporation.00 <TOTAL> 18.60 * 2 7.75 * 2 1.70 ======= CASH 20. 2002.50 <SUB> 16. .

. All rights reserved. 2002. COUNTRY * Name with in SHOP * Name o VAT% with in TILL PERSON * Number * First Name PRODUCT with with * Short Name at at * Price SALES HEADER in * Date & Time * Amount Cash referring with part of to SALES ITEM * Quantity A-23 Copyright © Oracle Corporation.

Werner is a financial administrator working for Accounting and is located in Germany … DEPARTMENT SHOP COUNTRY * Name * Name ORGANIZATION * City with with with works works for at payroll of for EMPLOYEE * Name * Job A-24 Copyright © Oracle Corporation. works as a shop manager in London. All rights reserved. All employees are at the payroll of one of our country organizations. . 2002. or for a shop. Jill. for example. Solution: Moonlight P&O (1) All Moonlight Coffee employees work for a department such as “Global Pricing” or “HQ”.

All rights reserved. except HQ EMPLOYEE itself … * Name * Job A-25 Copyright © Oracle Corporation. Solution: Moonlight P&O (2) reporting to report of DEPARTMENT report * Name HQ of OTHER reporting to DEPARTMENT COUNTRY ORGANIZATION … All shops belong with to one country with with organization (“the belongs to countries”). All on countries and works with payroll departments report for works for of to HQ. . 2002. There SHOP is only one country * Name organization per * City country.

Lynn has had an 80% at payroll belongs to assignment for of SHOP Product EMPLOYEE * Name Development * Name * City since the 1st with with September. to of to Before that she ASSIGNMENT had a full-time * Job position. Solution: Moonlight P&O (3) reporting to report of DEPARTMENT HQ Report of * Name reporting to OTHER COUNTRY … Employees DEPARTMENT ORGANIZATION can work part with with with time. 2002. All rights reserved. . * Start Date * Part Time % A-26 Copyright © Oracle Corporation.

2002. All rights reserved. . reporting to report of COUNTRY 4c DEPARTMENT HQ report ORGANIZATION * Name of 4b OTHER with DEPARTMENT EMPLOYEE with for for COUNTRY in COUNTRY PAYROLL ORGANIZATION * Name ENTRY of * Start Date with of 4d located belongs to in SHOP 4e: - * No * Name A-27 Copyright © Oracle Corporation. Solution: Moonlight P&O (4) 4a: .

. All rights reserved. 2002. Solution: Price List COUNTRY * Currency with coffees in teas PRODUCT SHOP foods GROUP * Name nonfoods with supplements * Address in * City PRODUCT with at * Short Name o Size PRICE LIST * Start Date with * End Date with in of PRICE * Amount A-29 Copyright © Oracle Corporation.

. 2002. Solution: EMail 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 A-30 Copyright © Oracle Corporation. All rights reserved.

2002. . All rights reserved. owner USER owner USER of of 5 owned 6 owned by by LIST LIST owner is referred to is referred owner of is referred to is to of owned referred to referring to owned referring to by referring to by referring to LIST ITEM LIST ITEM o External User USER owner of NICK NAME owned by o For External User 7 referred to for A-31 Copyright © Oracle Corporation.

2002. . All rights reserved. Solution: Holiday (1) “Paul and I hiked in the USA. COUNTRY TRANSPORT France Boots USA Boots USA Car 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 A-32 Copyright © Oracle Corporation. Eric and I hiked in France and we rented a car in the USA last year”.

All rights reserved. . Solution: Holiday (2) COUNTRY COMPANION TRANSPORT France Eric Boots France Eric Car USA Eric Boots USA Eric Car USA Paul Boots A-33 Copyright © Oracle Corporation. 2002.

2002. Solution: Holiday (3) COUNTRY COMPANION TRANSPORT France Eric Boots USA Paul Car COUNTRY COMPANION TRANSPORT HOLIDAY COUNTRY COMPANION TRANSPORT France Eric Boots USA Eric Car USA Paul Boots A-34 Copyright © Oracle Corporation. . All rights reserved.

. 2002. Practice: Normalize an ER Model: Solution for COURSE offered by DEPARTMENT ENROLLMENT #* course number #* department code completed course name the department name for with offerer of the taught by receiver of the assigned to receiver of assigned GRADE TEACHER #* grade code #* teacher number STUDENT grade description teacher name #* student id last name first name A-35 Copyright © Oracle Corporation. All rights reserved.

Solution: Identification 1
A B C
1 # Xx * Yy # Zz

A B
C # Id
2
# Code

A
* Xx
3 with
B C D
# Yy # Zz # Id
of

A-37 Copyright © Oracle Corporation, 2002. All rights reserved.

Solution: Identification 2
4 5
P Q P
# Id # Name

PERSON
MALE son of FEMALE
# Seqno
mother of # Name
# Birth Date
6 partner in partner in

with husband with wife
MARRIAGE
# Start Date

A-38 Copyright © Oracle Corporation, 2002. All rights reserved.

Solution: Moonlight UID
reporting to report of
DEPARTMENT HQ
# Name report
of
OTHER reporting to
COUNTRY
DEPARTMENT COUNTRY in # Code
with with ORGANIZATION
EMPLOYEE of
# Id with
with
with located
assigned in
for for SHOP to
of PAYROLL # No
ENTRY
# Start Date
with

to for to
ASSIGNMENT as JOB
# Start Date # Title
in

A-40 Copyright © Oracle Corporation, 2002. All rights reserved.

Solution: Table
USER

owner of owner of owner of
in in in
from with KEY
FOREIGN KEY TABLE
# Name # Name # Name
with
to PRIMARY
of
referenced with
with in UNIQUE
of
with
with
for in
from for
ASSOCIATION in COLUMN
# Name in USAGE
# Seqno # Seqno
in * Data Type of
to o Not Null

A-41 Copyright © Oracle Corporation, 2002. All rights reserved.

1 Solution: Constraints
EMPLOYEE
# Name OTHER managed
CEO EMPLOYEE by
2 ALIAS
manager # Name
of USER owned LIST
# Name by
owner of NICKNAME
3
with
subfolder USER
within
FOLDER # Name
# Name owner
of

owned
by

A-42 Copyright © Oracle Corporation, 2002. All rights reserved.

Solution: Shift
CALENDAR DAY
SHOP # Date
* Name * Public Holiday Indicator

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

A-43 Copyright © Oracle Corporation, 2002. All rights reserved.

Solution: Moonlight Pricing
COUNTRY
# Code
with with
PRODUCT GROUP in
# Name with
SHOP
with # No
in
* Name
PRODUCT of * Address
for GLOBAL LOCAL * City
PRICE LIST # Code # Name
# Start Date o Size with
* End Date
with with with of
LOCAL PRICE LANGUAGE
in of # Start Date # Code
GLOBAL PRICE of o End Date of
* Amount * Amount in
PRODUCT NAME
* Name

A-44 Copyright © Oracle Corporation, 2002. All rights reserved.

PRODUCT PRODUCT
1 2 GROUP
GROUP

BUNDLE PRODUCT PRODUCT
OTHER
BUNDLE
PRODUCT
with in
of referring with in
BUNDLE ITEM to of referring
* Quantity BUNDLE ITEM * to
Needed PRODUCT
Quantity Needed
GROUP

3
PRODUCT

ASSEMBLY ITEM
* Quantity Needed

A-45 Copyright © Oracle Corporation, 2002. All rights reserved.

2002. DP AND ….DecafPunch (DP) = {Coffee (C) or Tea (T)} and {Blackberry Muffin (BM)} Consider this as: PRODUCT AS1 = (C or T) GROUP DP = (AS1 and BM) # Name PRODUCTS PRODUCT Code And_or Pg_name # Code C . o And/Or Indicator T … AS1 OR ….. ASSEMBLY ITEM ASSEMBLY ITEMS * Quantity Needed Prod_code Using_code Quantity AS1 C 1 AS1 T 1 DP AS1 1 DP BM 1 A-46 Copyright © Oracle Corporation. All rights reserved.. .

. 2002. LEVEL1 fixed number of 1 levels with LEVEL2 PRODUCT CLASS # Name within LEVEL3 or generic: LEVEL4 2 + coffees + teas LEVEL5 + foods product + nonfoods + supplements PRODUCT + bundles A-47 Copyright © Oracle Corporation. All rights reserved.

teachers. All rights reserved. 2002. … • Rentals in a video shop M/D or Basket • Model of phases in a process Chain or Network A-48 Copyright © Oracle Corporation. Patterns • Model of moves in a chess game Chain or Network • Model of quotations M/D or Basket • Model of recipes Bill of Material • Model of all people involved in Roles college: students. . parents.

. teachers. … • Rentals in a video shop M/D or Basket • Model of phases in a process Chain or Network A-49 Copyright © Oracle Corporation. Patterns • Model of moves in a chess game Chain or Network • Model of quotations M/D or Basket • Model of recipes Bill of Material • Model of all people involved in Roles college: students. 2002. parents. All rights reserved.

All rights reserved. . 2002. Moonlight Data Warehouse YEAR # No with with in QUARTER with assigned in to with MONTH WEEK PRODUCT within # No # No CLASS with with with with in in of GEOGRAPHY DAY PRODUCT * Number of Inhabitants within # No # Id * Number of Employees with in wit of of h of SALES VOLUME * Quantity * Value in Local Currency * Value in $ A-50 Copyright © Oracle Corporation.

. Solution: Argos and Erats ERAT # Name unknown have have have have optionality belongs unknown of of to of degree RONDEL ARGO UBIN * Type # Name in in with with with with UBIN ITEM Constraint not shown: A ubin always consists of one or more argos of the erat. one or more.. All rights reserved. A-51 Copyright © Oracle Corporation.. 2002.

All rights reserved. Command 3 4 A vehicle with two wheels Demand 3 homonym 5 .. command .. . 2002.. actual doing . Arrangement 2 2 Regular arrangement . Bike 3 4 A-52 Copyright © Oracle Corporation. Order 2 3 Order...... Solution: Synonym 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.

All rights reserved. Attributes and Relationships DEPARTMENTS (DPT) EMPLOYEES (EPE) pk * Id pk * Id epe_dpt_fk fk * Name * Dpt_id o Location * Last Name * First Name o Home Phone A-53 Copyright © Oracle Corporation. . 2002. Solution: Mapping basic Entities.

All rights reserved. . 2002. Solution: Mapping Supertype dpt_dpt_fk DEPARTMENTS (DPT) pk * Id * Name * Dpt_type * Headcount o Address o fk Dpt_id_reporting_to A-54 Copyright © Oracle Corporation.

All rights reserved. . 2002. Solution: Mapping Supertype dpt_dpt_fk DEPARTMENTS (DPT) pk * Id * Name * Dpt_type * Headcount o Address o fk Dpt_id_reporting_to A-55 Copyright © Oracle Corporation.

. All rights reserved.fk * Shp_no fk * Pgp_name fk * Pgp_name A-56 Copyright © Oracle Corporation. Solution: Quality Check Subtype Implementation gpt_pgp_fk lpt_shp_fk GLOBAL_PRODUCTS (GPT) LOCAL_PRODUCTS (LPT) pk * Code pk * Name o Size pk. 2002.

uk2 o Lpt_shp_no GLOBAL_PRODUCTS (GPT) pk * Code o Size LOCAL_PRODUCTS (LPT) lpt_shp_fk fk3=pdt_lpt_fk pk * Name pk. Solution: Quality Check both Supertype and Subtype Implementation PRODUCTS (PDT) fk1=pdt_pgp_fk pk * Code fk2=pdt_gpt_fk fk1 * Pgp_name fk2. . All rights reserved. 2002. uk2 o Lpt_name fk3. fk * Shp_no A-57 Copyright © Oracle Corporation. uk1 o Gpt_code fk3.

. 2002. All rights reserved. fk1 * Plt_start_date fk2= gpe_gpt_fk pk. fk2 * Gpt_code * Amount A-58 Copyright © Oracle Corporation. Solution: Primary Keys and Columns GLOBAL_PRICES (GPE) fk1= gpe_plt_fk pk. fk1 * Plt_cty_code pk.

Practice: Triggers (1/6) ORDER_HEADERS (OHR) ORDER_ITEMS (OIM) pk * Ohr_id pk * Id pk * Seqno * Order_total * Item_total A-60 Copyright © Oracle Corporation. 2002. All rights reserved. .

All rights reserved. . Solution: Triggers (2/6) Table Trg Type Column Needed? What should it do? OHR Insert Y Order_total := 0 Delete N Update Id N Order_total Y prevent update OIM Insert Y recalculate Order_total Delete Y recalculate Order_total Update Ohr_id Y recalculate Order_total Item_total Y recalculate Order_total A-61 Copyright © Oracle Corporation. 2002.

. 2002. Practice: Triggers (3/6) LOCATIONS (LCN) EMPLOYEES (EPE) pk * Id pk * Id fk * Lcn_id * Name * Address * Lcn_address A-62 Copyright © Oracle Corporation. All rights reserved.

2002. Solution: Triggers (4/6) Table Trg Type Column Needed? What should it do? LCN Insert N Delete N Update Address Y Cascade to Employees other cols Y If pk updated than extended cascade EPE Insert Y Set correct Lcn_address Delete N Update Lcn_id Y Set correct Lcn_address Lcn_address Y Prevent update A-63 Copyright © Oracle Corporation. All rights reserved. .

Practice: Triggers (5/6) PRODUCTS (PDT) PRICES (PCE) pk * Pdt_id pk * Id pk * Start_date * Name o End_date * Curr_price_ind A-64 Copyright © Oracle Corporation. All rights reserved. . 2002.

2002. Solution: Triggers (6/6) Table Trg Type Column Needed? What should it do? PDT Insert N Delete N PCE Insert Y Prevent overlap in price periods Delete N Update Pdt_id Y Set Curr_price_ind to NULL Start_date Y Re-evaluate Curr_price_ind End_date Y Re-evaluate Curr_price_ind Curr_price_Ind Y Prevent update by user A-65 Copyright © Oracle Corporation. . All rights reserved.

. Solution: Denormalize Price Lists PRICE_LISTS (PLT) GLOBAL_PRICES (GPE) pk * Start_date pk. 2002. All rights reserved.fk * Plt_start_date pk.fk * Plt_cty_code k * End_date * Amount * Current_indicator A-66 Copyright © Oracle Corporation.f * Cty_code pk.

All rights reserved.fk Lge_code * Corporate_Name * Name * A-68 Copyright © Oracle Corporation. Solution: Denormalize Global Naming LANGUAGES (LGE) pk * Code * Name PRODUCTS (PDT) PRODUCT_NAMES (PNE) pk * Code pk. 2002.fk * Pdt_code o Size pk. .

Solution: Data Types (1) Table Column Suggested Your Choice Data Type Data Type? COUNTRIES Code Varchar2(2) Char(2) CURRENCIES Code Varchar2(3) Char(3) EXCHANGE_RATES Month Date Number(2) Rate Number(8.2) Char(1) Pdt_type Number(1) Char(3) A-69 Copyright © Oracle Corporation. All rights reserved. 2002.4) Number(12. .4) PRICE_LISTS Start_date Date Date End_date Date Date PRODUCT_GROUPS Name Char(8) Varchar2(15) PRODUCTS Code Char(10) Varchar2(15) Size Number(4.

2002.3) SHOPS Name Varchar2(50) Address Varchar2(50) City Varchar2(50) A-70 Copyright © Oracle Corporation. . All rights reserved. Solution: Data Types (2) Table Column Your Choice Data Type GLOBAL_PRICES Amount Number(15.3) LOCAL_PRICES Start_date Date End_date Date Amount Number(15.

2002. pk * Info_type varchar2(20) o Information CLOB BINARY_DOCUMENTS (BDT) pk. All rights reserved. .fk * Pdt_code varchar2(3) ……. Solution: Product Pictures PRODUCTS (PDT) TEXT_DOCUMENTS (TDT) pk * Code pk.fk * Pdt_code varchar2(3) pk * Info_type varchar2(20) o Information BLOB A-72 Copyright © Oracle Corporation.

All rights reserved. 2002. Normalization Copyright © Oracle Corporation. .

2002. All rights reserved. Overview • Table Normalization • Normal Forms of Tables B-2 Copyright © Oracle Corporation. .

Note: Third normal form is the generally-accepted goal for a database design that eliminates redundancy. B-4 Copyright © Oracle Corporation. and stability of design. columns and constraints. • To identify missing tables. . • To reduce redundant data in existing design. All rights reserved. Why Normalize? • An Entity Model is not always available as a starting point for design. • To increase integrity of data. 2002.

6001 IMAP08 5607 Jones 54660 12/01 Jogging Today? Can you. All rights reserved. 3786 IMAP05 5607 Jones 54101 05/07 Meeting Today There is.. 9988 EMEA01 7773 Walsh 54554 03/17 Stock Quote The latest 9988 EMEA01 0022 Patel 54101 05/07 Meeting Today There is... 3786 IMAP05 2301 Smith 54445 10/06 Next Assignment Your next. .. 6001 IMAP08 5607 Jones 54512 06/07 Lunch? Can you. ----.. 2201 EMEA09 B-5 Copyright © Oracle Corporation.. 2201 EMEA09 0022 Patel 54512 06/07 Lunch? Can we . ----. 2002. Recognize Unnormalized Data USER USER MSE REC_ SRVR SERVER _ID _NAME _ID DATE SUBJECT TEXT _ID _NAME ---. ------ 2301 Smith 54101 05/07 Meeting Today There is.. ----. --------------. ---.... ---------. 3786 IMAP05 2301 Smith 54098 07/12 Promotions I like to. 6001 IMAP08 7773 Walsh 54101 05/07 Meeting Today There is.

the whole key. 2002. . “Each non-primary key value MUST be dependent on the key. All rights reserved. Third Normal Form (3NF) The table must be in 2NF.” B-6 Copyright © Oracle Corporation. Second Normal Form (2NF) The table must be in 1NF. two-dimensional tables. Normalization Rules Normal Form Rule Description First Normal Form The table must express a set of (1NF) unordered. Every non-key column must be dependent on all parts of the primary key. The table cannot contain repeating groups. and nothing but the key. No non-key column may be functionally dependent on another non-key column.

.. . Converting to First Normal Form USER USER MSE REC_ SRVR SERVER _ID _NAME _ID DATE SUBJECT TEXT _ID _NAME ---..... All rights reserved........ 6001 IMAP08 5607 Jones 54660 12/01 Jogging Today? Can you.------------ ---... ----. ----. 2002. 2... 9988 EMEA01 7773 Walsh 54554 03/17 Stock Quote The latest... 9988 EMEA01 0022 Patel 54101 05/07 Meeting Today There is. 6001 IMAP08 5607 Jones 54101 05/07 Meeting Today There is. B-7 Copyright © Oracle Corporation. ------ 2301 Smith 54101 05/07 Meeting Today There is.... --------------. ----... 3786 IMAP05 2301 Smith 54445 10/06 Next Assignment Your next.. Remove repeating group from the base table. 3786 IMAP05 2301 Smith 54098 07/12 Promotions I like to. 9988 EMEA01 1... Create a new table with the PK of the base table and the repeating group... 9988 EMEA01 0022 Patel 54512 06/07 Lunch? Can we . 3786 IMAP05 5607 Jones 54512 06/07 Lunch? Can you.6001 IMAP08 7773 Walsh 54101 05/07 Meeting Today There is.

.----. 9988 EMEA01 USER USER SRVR SERVER _ID _NAME _ID _NAME USERS ---. 2002. All rights reserved.. ------ 2301 Smith 3786 IMAP05 5607 Jones 6001 IMAP08 7773 Walsh 9988 EMEA01 0022 Patel 9988 EMEA01 B-8 Copyright © Oracle Corporation.. ---.------------. .. 9988 EMEA01 0022 Patel 54101 05/07 Meeting Today There is.---------. 3786 IMAP05 5607 Jones 54512 06/07 Lunch? Can you.------ 2301 Smith 54101 05/07 Meeting Today There is.Single Record USERS USER USER MSE REC_ SRVR SERVER _ID _NAME _ID DATE SUBJECT TEXT _ID _NAME ---.---. ----. 6001 IMAP08 7773 Walsh 54101 05/07 Meeting Today There is. First Normal Form .----..----.

2002. ---------- (1NF) 2301 54101 05/07 Meeting Today There is. 2301 Smith 3786 IMAP05 5607 Jones 6001 IMAP08 USERS (1NF) 7773 Walsh 9988 EMEA01 0022 Patel 9988 EMEA01 B-9 Copyright © Oracle Corporation...----.. All rights reserved. 2301 54098 07/12 Promotions I like to. 54512 ------06/07 Lunch? Can we .Repeating Groups USER MSE REC_ RECEIVED_ _ID _ID DATE SUBJECT TEXT MESSAGES ---. 5607 54101 05/07 Meeting Today There is. 0022 ---.----. First Normal Form . 2301 54445 10/06 Next Assignment Your next..---... 7773 54101 05/07 Meeting Today There is.. USER USER 7773 SRVR 54554 SERVER03/17 Stock Quote The latest _ID _NAME 0022 _ID 54101 _NAME05/07 Meeting Today There is... 5607 54512 06/07 Lunch? Can you. ----. 5607 54660 12/01 Jogging Today? Can you..--------------. .

2. Determine which non-key columns are not dependent upon the table’s entire primary key. Converting to Second Normal Form 1. Create a second table with those columns and the columns from the PK that they are dependent upon. 3. 2002. Remove those columns from the base table. B-10 Copyright © Oracle Corporation. All rights reserved. .

All rights reserved. ------ 2301 Smith 3786 IMAP05 5607 Jones 6001 IMAP08 7773 Walsh 9988 EMEA01 0022 Patel 9988 EMEA01 Is the USERS table already in 2NF? B-11 Copyright © Oracle Corporation. 2002. . ---. ----. Tables Already in Second Normal Form USERS USER USER SRVR SERVER _ID _NAME _ID _NAME ---.

(2NF) 5607 54512 06/07 Lunch? Can you. 54554 Stock Quote The lates B-12 Copyright © Oracle Corporation.--------- (1NF) 2301 54101 05/07 Meeting Today There is.. 2301 54101 05/07 0022 54512 06/07 Lunch? Can we . 2002. 2301 54098 07/12 2301 54445 10/06 MESSAGES MSE 5607 54101 05/07 _ID SUBJECT TEXT 5607 54512 06/07 (2NF) ----..----. ----- 0022 54101 05/07 Meeting Today There is.. All rights reserved.-------------.-----------. 0022 54512 06/07 54660 Jogging Toda Can you.----. Convert to Second Normal Form RECEIVED_ USER MSE REC_ MESSAGES _ID _ID DATE SUBJECT TEXT ---..--------- 5607 54660 12/01 54101 Meeting Toda There is. 2301 54098 07/12 Promotions I like to RECEIVED_ 2301 54445 10/06 Next Assignment Your next MESSAGES 5607 54101 05/07 Meeting Today There is.. _ID _ID DATE7773 54101 05/07 Meeting Today There is. USER MSE REC_5607 54660 12/01 Jogging Today? Can you. .----. 7773 54101 05/07 54098 Promotions I like to 7773 54554 03/17 54445 Next Assignm Your next 0022 54101 05/07 54512 Lunch? Can you. 7773 54554 03/17 Stock Quote The lates ---.

2. Create a second table with those columns and the non-key columns that they are dependent upon. All rights reserved. Remove those columns from the base table. Converting to Third Normal Form Remove any columns that are dependent upon another non-key column: 1. . 2002. 3. B-13 Copyright © Oracle Corporation. Determine which columns are dependent upon another non-key column.

----. Tables Already in Third Normal Form No non-key column can be functionally dependent upon another non-key column.. 2002. _ID _ID DATE 54098 Promotions I like to ---. 5607 54101 05/07 54554 Stock Quote The lates 5607 54512 06/07 5607 54660 12/01 7773 54101 05/07 Are these two tables in third 7773 54554 03/17 0022 54101 05/07 normal form? Why? 0022 54512 06/07 B-14 Copyright © Oracle Corporation. 54445 Next Assignment Your 2301 54101 05/07 next 2301 54098 07/12 54512 Lunch? Can you.--------- USER MSE REC_ 54101 Meeting Today There is. RECEIVED_ MESSAGES MESSAGES (2NF) (2NF) ID SUBJECT TEXT ----. ----. 2301 54445 10/06 54660 Jogging Today? Can you. ..-------------. All rights reserved.

-----. 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 ---. All rights reserved. ----. . ---- USER USER SRVR SERVER 2301 Smith 3786 _ID _NAME _ID _NAME 5607 Jones 6001 ---. 2002. ----. Converting to Third Normal Form USERS SRVR ID NAME _ID USERS ---. ---. ------ 3786 IMAP05 6001 IMAP08 9988 EMEA01 B-15 Copyright © Oracle Corporation.

An entity relationship model transforms into normalized data design. Summary 1NF The table must express a set of unordered. Every non-key column must be dependent on all parts of the primary key. No non-key column may be functionally dependent on another non-key column. All rights reserved. 2NF The table must be in 1NF. B-16 Copyright © Oracle Corporation. two- dimensional tables. The table cannot contain repeating groups. . 3NF The table must be in 2NF. 2002.