the relational database model cst272. return creating the unnormalized table n list the fields n...

79
The Relational Database Model CST272

Upload: daniel-skinner

Post on 25-Dec-2015

216 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: The Relational Database Model CST272. Return Creating the Unnormalized Table n List the fields n Select a primary key – The field (or concatenation of

The Relational Database Model

CST272

Page 2: The Relational Database Model CST272. Return Creating the Unnormalized Table n List the fields n Select a primary key – The field (or concatenation of

Return

Page 3: The Relational Database Model CST272. Return Creating the Unnormalized Table n List the fields n Select a primary key – The field (or concatenation of

Creating the Unnormalized Table

List the fields Select a primary key

– The field (or concatenation of two or more fields) that uniquely identifies each record

Purchase Order Report

Page 4: The Relational Database Model CST272. Return Creating the Unnormalized Table n List the fields n Select a primary key – The field (or concatenation of

Purchase Order (PO number, PO date, Vendor number, Vendor name, Address, City, State, ZIP code, Product number, Product, Unit price, Quantity, Extension, Subtotal, Tax, Shipping, Discount, PO total)

Unnormalized Table

Purchase Order Report

Page 5: The Relational Database Model CST272. Return Creating the Unnormalized Table n List the fields n Select a primary key – The field (or concatenation of

The Unnormalized Purchase Order Table

POnumber

POdate …

Productnumber Product … Subtotal …

10001 1/1/97 … 101103201

PencilsPensPaper

… 38.15 …

Purchase Order Report Return

Page 6: The Relational Database Model CST272. Return Creating the Unnormalized Table n List the fields n Select a primary key – The field (or concatenation of

To Convert from Unnormalized to 1NF Identify, list and remove repeating groups Modify Primary key (concatenated fields) Important: In 1NF there always will still

be just one table

Page 7: The Relational Database Model CST272. Return Creating the Unnormalized Table n List the fields n Select a primary key – The field (or concatenation of

Purchase Order (PO number, PO date, Vendor number, Vendor name, Address, City, State, ZIP code, Product number, Product, Unit price, Quantity, Subtotal, Tax, Shipping, Discount, PO total)

Repeating Groups

The Unnormalized Purchase Order TablePurchase Order Report

Page 8: The Relational Database Model CST272. Return Creating the Unnormalized Table n List the fields n Select a primary key – The field (or concatenation of

The Payables Table in 1NF

POnumber

POdate …

Productnumber Product … Subtotal …

10001 1/1/97 … 101 Pencils … 38.15 …10001 1/1/97 … 103 Pens … 38.15 …10001 1/1/97 … 201 Paper … 38.15 …

ReturnPurchase Order Report

Page 9: The Relational Database Model CST272. Return Creating the Unnormalized Table n List the fields n Select a primary key – The field (or concatenation of

Payables (PO number, PO date, Vendor number, Vendor name, Address, City, State, ZIP code, Product number, Product, Unit price, Quantity, Subtotal, Tax, Shipping, Discount, PO total)

1NF (First Normal Form)

Purchase Order Report The Payables Table in 1NF

Page 10: The Relational Database Model CST272. Return Creating the Unnormalized Table n List the fields n Select a primary key – The field (or concatenation of

To Convert from 1NF to 2NF

Identify the determinants– A listing of every possible combination of

elements (fields) that make up the 1NF primary key

Identify the functional dependencies– Which non-key fields rely on which

determinants to determine their value For the new 2NF tables, the determinants

are the primary keys

Page 11: The Relational Database Model CST272. Return Creating the Unnormalized Table n List the fields n Select a primary key – The field (or concatenation of

Payables (PO number, PO date, Vendor number, Vendor name, Address, City, State, ZIP code, Product number, Product, Unit price, Quantity, Subtotal, Tax, Shipping, Discount, PO total)

Determinants

PO number

Product number PO number, Product number

Functional Dependencies

Page 12: The Relational Database Model CST272. Return Creating the Unnormalized Table n List the fields n Select a primary key – The field (or concatenation of

Payables (PO number, PO date, Vendor number, Vendor name, Address, City, State, ZIP code, Product number, Product, Unit price, Quantity, Subtotal, Tax, Shipping, Discount, PO total)

Determinants

PO number PO date

Product number PO number, Product number

Functional Dependencies

Page 13: The Relational Database Model CST272. Return Creating the Unnormalized Table n List the fields n Select a primary key – The field (or concatenation of

Payables (PO number, PO date, Vendor number, Vendor name, Address, City, State, ZIP code, Product number, Product, Unit price, Quantity, Subtotal, Tax, Shipping, Discount, PO total)

Determinants

PO number PO date, Vendor number

Product number PO number, Product number

Functional Dependencies

Page 14: The Relational Database Model CST272. Return Creating the Unnormalized Table n List the fields n Select a primary key – The field (or concatenation of

Payables (PO number, PO date, Vendor number, Vendor name, Address, City, State, ZIP code, Product number, Product, Unit price, Quantity, Subtotal, Tax, Shipping, Discount, PO total)

Determinants

PO number PO date, Vendor number, Vendor name

Product number PO number, Product number

Functional Dependencies

Page 15: The Relational Database Model CST272. Return Creating the Unnormalized Table n List the fields n Select a primary key – The field (or concatenation of

Payables (PO number, PO date, Vendor number, Vendor name, Address, City, State, ZIP code, Product number, Product, Unit price, Quantity, Subtotal, Tax, Shipping, Discount, PO total)

Determinants

PO number PO date, Vendor number, Vendor name, Address

Product number PO number, Product number

Functional Dependencies

Page 16: The Relational Database Model CST272. Return Creating the Unnormalized Table n List the fields n Select a primary key – The field (or concatenation of

Payables (PO number, PO date, Vendor number, Vendor name, Address, City, State, ZIP code, Product number, Product, Unit price, Quantity, Subtotal, Tax, Shipping, Discount, PO total)

Determinants

PO number PO date, Vendor number, Vendor name, Address, City

Product number PO number, Product number

Functional Dependencies

Page 17: The Relational Database Model CST272. Return Creating the Unnormalized Table n List the fields n Select a primary key – The field (or concatenation of

Payables (PO number, PO date, Vendor number, Vendor name, Address, City, State, ZIP code, Product number, Product, Unit price, Quantity, Subtotal, Tax, Shipping, Discount, PO total)

Determinants

PO number PO date, Vendor number, Vendor name, Address, City, State

Product number PO number, Product number

Functional Dependencies

Page 18: The Relational Database Model CST272. Return Creating the Unnormalized Table n List the fields n Select a primary key – The field (or concatenation of

Payables (PO number, PO date, Vendor number, Vendor name, Address, City, State, ZIP code, Product number, Product, Unit price, Quantity, Subtotal, Tax, Shipping, Discount, PO total)

Determinants

PO number PO date, Vendor number, Vendor name, Address, City, State, ZIP code

Product number PO number, Product number

Functional Dependencies

Page 19: The Relational Database Model CST272. Return Creating the Unnormalized Table n List the fields n Select a primary key – The field (or concatenation of

Payables (PO number, PO date, Vendor number, Vendor name, Address, City, State, ZIP code, Product number, Product, Unit price, Quantity, Subtotal, Tax, Shipping, Discount, PO total)

Determinants

PO number PO date, Vendor number, Vendor name, Address, City, State, ZIP code

Product number Product

PO number, Product number

Functional Dependencies

Page 20: The Relational Database Model CST272. Return Creating the Unnormalized Table n List the fields n Select a primary key – The field (or concatenation of

Payables (PO number, PO date, Vendor number, Vendor name, Address, City, State, ZIP code, Product number, Product, Unit price, Quantity, Subtotal, Tax, Shipping, Discount, PO total)

Determinants

PO number PO date, Vendor number, Vendor name, Address, City, State, ZIP code

Product number Product

PO number, Product number Unit price

Functional Dependencies

Page 21: The Relational Database Model CST272. Return Creating the Unnormalized Table n List the fields n Select a primary key – The field (or concatenation of

Payables (PO number, PO date, Vendor number, Vendor name, Address, City, State, ZIP code, Product number, Product, Unit price, Quantity, Subtotal, Tax, Shipping, Discount, PO total)

Determinants

PO number PO date, Vendor number, Vendor name, Address, City, State, ZIP code

Product number Product

PO number, Product number Unit price, Quantity

Functional Dependencies

Page 22: The Relational Database Model CST272. Return Creating the Unnormalized Table n List the fields n Select a primary key – The field (or concatenation of

Payables (PO number, PO date, Vendor number, Vendor name, Address, City, State, ZIP code, Product number, Product, Unit price, Quantity, Subtotal, Tax, Shipping, Discount, PO total)

Determinants

PO number PO date, Vendor number, Vendor name, Address, City, State, ZIP code, Subtotal

Product number Product

PO number, Product number Unit price, Quantity

Functional Dependencies

Page 23: The Relational Database Model CST272. Return Creating the Unnormalized Table n List the fields n Select a primary key – The field (or concatenation of

Payables (PO number, PO date, Vendor number, Vendor name, Address, City, State, ZIP code, Product number, Product, Unit price, Quantity, Subtotal, Tax, Shipping, Discount, PO total)

Determinants

PO number PO date, Vendor number, Vendor name, Address, City, State, ZIP code, Subtotal, Tax

Product number Product

PO number, Product number Unit price, Quantity

Functional Dependencies

Page 24: The Relational Database Model CST272. Return Creating the Unnormalized Table n List the fields n Select a primary key – The field (or concatenation of

Payables (PO number, PO date, Vendor number, Vendor name, Address, City, State, ZIP code, Product number, Product, Unit price, Quantity, Subtotal, Tax, Shipping, Discount, PO total)

Determinants

PO number PO date, Vendor number, Vendor name, Address, City, State, ZIP code, Subtotal, Tax, Shipping

Product number Product

PO number, Product number Unit price, Quantity

Functional Dependencies

Page 25: The Relational Database Model CST272. Return Creating the Unnormalized Table n List the fields n Select a primary key – The field (or concatenation of

Payables (PO number, PO date, Vendor number, Vendor name, Address, City, State, ZIP code, Product number, Product, Unit price, Quantity, Subtotal, Tax, Shipping, Discount, PO total)

Determinants

PO number PO date, Vendor number, Vendor name, Address, City, State, ZIP code, Subtotal, Tax, Shipping, Discount

Product number Product

PO number, Product number Unit price, Quantity

Functional Dependencies

Page 26: The Relational Database Model CST272. Return Creating the Unnormalized Table n List the fields n Select a primary key – The field (or concatenation of

Payables (PO number, PO date, Vendor number, Vendor name, Address, City, State, ZIP code, Product number, Product, Unit price, Quantity, Subtotal, Tax, Shipping, Discount, PO total)

Determinants

PO number PO date, Vendor number, Vendor name, Address, City, State, ZIP code, Subtotal, Tax, Shipping, Discount, PO total

Product number Product

PO number, Product number Unit price, Quantity

Functional Dependencies

Page 27: The Relational Database Model CST272. Return Creating the Unnormalized Table n List the fields n Select a primary key – The field (or concatenation of

Purchase Order (PO number, PO date, Vendor number, Vendor name, Address, City, State, ZIP code, Subtotal, Tax, Shipping, Discount, PO total)

Payables (PO number, Product number, Unit price, Quantity)

Product (Product number, Product)

2NF (Second Normal Form)

Purchase Order Report

Page 28: The Relational Database Model CST272. Return Creating the Unnormalized Table n List the fields n Select a primary key – The field (or concatenation of

To Convert from 2NF to 3NF

Within the existing 2NF tables, identify the non-key determinants– Any non-key fields that could be a primary key

for other fields in one of the 2NF tables Identify those functional dependencies Create new table(s) from the determinant(s)

and functional dependency(cies) Do not remove the non-key determinant(s)

from original table(s)

Page 29: The Relational Database Model CST272. Return Creating the Unnormalized Table n List the fields n Select a primary key – The field (or concatenation of

Purchase Order (PO number, PO date, Vendor number, Vendor name, Address, City, State, ZIP code, Subtotal, Tax, Shipping, Discount, PO total)

Payables (PO number, Product number, Unit price, Quantity)

Product (Product number, Product)

Non-key Determinants

Page 30: The Relational Database Model CST272. Return Creating the Unnormalized Table n List the fields n Select a primary key – The field (or concatenation of

Purchase Order (PO number, PO date, Vendor number, Vendor name, Address, City, State, ZIP code, Subtotal, Tax, Shipping, Discount, PO total)

Payables (PO number, Product number, Unit price, Quantity)

Product (Product number, Product)

Vendor number

Non-key Determinants

Page 31: The Relational Database Model CST272. Return Creating the Unnormalized Table n List the fields n Select a primary key – The field (or concatenation of

Purchase Order (PO number, PO date, Vendor number, Vendor name, Address, City, State, ZIP code, Subtotal, Tax, Shipping, Discount, PO total)

Payables (PO number, Product number, Unit price, Quantity)

Product (Product number, Product)

Vendor number Vendor name

Non-key Determinants

Page 32: The Relational Database Model CST272. Return Creating the Unnormalized Table n List the fields n Select a primary key – The field (or concatenation of

Purchase Order (PO number, PO date, Vendor number, Vendor name, Address, City, State, ZIP code, Subtotal, Tax, Shipping, Discount, PO total)

Payables (PO number, Product number, Unit price, Quantity)

Product (Product number, Product)

Vendor number Vendor name, Address

Non-key Determinants

Page 33: The Relational Database Model CST272. Return Creating the Unnormalized Table n List the fields n Select a primary key – The field (or concatenation of

Purchase Order (PO number, PO date, Vendor number, Vendor name, Address, City, State, ZIP code, Subtotal, Tax, Shipping, Discount, PO total)

Payables (PO number, Product number, Unit price, Quantity)

Product (Product number, Product)

Vendor number Vendor name, Address, City

Non-key Determinants

Page 34: The Relational Database Model CST272. Return Creating the Unnormalized Table n List the fields n Select a primary key – The field (or concatenation of

Purchase Order (PO number, PO date, Vendor number, Vendor name, Address, City, State, ZIP code, Subtotal, Tax, Shipping, Discount, PO total)

Payables (PO number, Product number, Unit price, Quantity)

Product (Product number, Product)

Vendor number Vendor name, Address, City, State

Non-key Determinants

Page 35: The Relational Database Model CST272. Return Creating the Unnormalized Table n List the fields n Select a primary key – The field (or concatenation of

Purchase Order (PO number, PO date, Vendor number, Vendor name, Address, City, State, ZIP code, Subtotal, Tax, Shipping, Discount, PO total)

Payables (PO number, Product number, Unit price, Quantity)

Product (Product number, Product)

Vendor number Vendor name, Address, City, State, ZIP code

Non-key Determinants

Page 36: The Relational Database Model CST272. Return Creating the Unnormalized Table n List the fields n Select a primary key – The field (or concatenation of

Vendor (Vendor number, Vendor name, Address, City, State, ZIP code)

Purchase Order (PO number, Vendor number, Subtotal, Tax, Shipping, PO total, PO date)

Payables (PO number, Product number, Unit price, Quantity)

Product (Product number, Product)

3NF (Third Normal Form)

Page 37: The Relational Database Model CST272. Return Creating the Unnormalized Table n List the fields n Select a primary key – The field (or concatenation of

Finalize the Tables in Database Design Language Present the 3NF tables with all keys:

– Primary keys—that field which uniquely identifies (differentiates) a record from all other records in the table

– Alternate (secondary) keys—a field that could have been the primary key but is not; DBMS must enforce that values of field are unique for every record

– Foreign keys—a field that links to field values in another table; a foreign key value must match the primary key of one of the records in table to which it joins, or be null

Page 38: The Relational Database Model CST272. Return Creating the Unnormalized Table n List the fields n Select a primary key – The field (or concatenation of

Vendor (Vendor number, Vendor name, Address, City, State, ZIP code)

Purchase Order (PO number, Vendor number, Subtotal, Tax, Shipping, PO total, PO date)FK Vendor number Vendor

Payables (PO number, Product number, Unit price, Quantity)FK PO number Purchase OrderFK Product number Product

Product (Product number, Product)

DBDL (Database Design Language)

Page 39: The Relational Database Model CST272. Return Creating the Unnormalized Table n List the fields n Select a primary key – The field (or concatenation of
Page 40: The Relational Database Model CST272. Return Creating the Unnormalized Table n List the fields n Select a primary key – The field (or concatenation of

Vendor (Vendor number, Vendor name, Contact, Telephone)

Unnormalized—Contact Listing

Page 41: The Relational Database Model CST272. Return Creating the Unnormalized Table n List the fields n Select a primary key – The field (or concatenation of

Vendor (Vendor number, Vendor name, Contact, Telephone)

DBDL—Contact Listing

Page 42: The Relational Database Model CST272. Return Creating the Unnormalized Table n List the fields n Select a primary key – The field (or concatenation of

Merge the Tables

If you have two tables with the identical primary key, they generally should be merged into a single table

The results of each new normalization should be merged into the existing tables from previous normalizations

Page 43: The Relational Database Model CST272. Return Creating the Unnormalized Table n List the fields n Select a primary key – The field (or concatenation of

Vendor (Vendor number, Vendor name, Address, City, State, ZIP code, Contact, Telephone)

Purchase Order (PO number, Vendor number, Subtotal, Tax, Shipping, PO total, PO date)FK Vendor number Vendor

Payables (PO number, Product number, Unit price, Quantity)FK PO number Purchase OrderFK Product number Product

Product (Product number, Product)

DBDL—The Merged Tables

Page 44: The Relational Database Model CST272. Return Creating the Unnormalized Table n List the fields n Select a primary key – The field (or concatenation of

Vendor (Vendor number, Vendor name, Address, City, State, ZIP code, Contact, Telephone, Fax, Term days, Term percent, Date last order)

Purchase Order (PO number, Vendor number, Subtotal, Tax, Shipping, PO total, PO date, Bill date, Discount date, Due date)FK Vendor number Vendor

Payables (PO number, Product number, Unit price, Quantity, Back ordered?)FK PO number Purchase OrderFK Product number Product

Product (Product number, Product)

DBDL—The Final Tables

Page 45: The Relational Database Model CST272. Return Creating the Unnormalized Table n List the fields n Select a primary key – The field (or concatenation of

Mini Quiz

Normalize a “Student Transcript”using the model given from the “Payables” database

Student Transcript

Student ID: 345 Advisor ID: 56

Student Name: Sally Henson Advisor name: Ralph Pollard

Credits completed: 32 Advisor office: H203

Class standing: Freshman Advisor phone: 851-6590

Course number Grade

CS33 A

EG13 B+

1. Unnormalized table2. Repeating groups (list)3. 1NF4. Determinants and functional dependencies5. 2NF6. Non-key determinants and functional dependencies7. 3NF in DBDL (with all keys)

Return

Page 46: The Relational Database Model CST272. Return Creating the Unnormalized Table n List the fields n Select a primary key – The field (or concatenation of

The Unnormalized Table

Student (StudentID, StudentLast, StudentFirst, AdvisorID, AdvisorLast, AdvisorFirst, AdvisorOffice, AdvisorPhone, CreditsCompleted, ClassStanding, CourseNumber, Grade)– CreditsCompleted is the total credits currently completed

by the student– ClassStanding is Freshman, Sophomore, etc.– CourseNumber is each course (of more than one) that the

student has taken or is taking

Student Transcript

Page 47: The Relational Database Model CST272. Return Creating the Unnormalized Table n List the fields n Select a primary key – The field (or concatenation of

Convert from Unnormalized to 1NF

Identify, list and remove repeating groups Modify the unnormalized table by including

an additional field to create a concatenated primary key

Student Transcript

Page 48: The Relational Database Model CST272. Return Creating the Unnormalized Table n List the fields n Select a primary key – The field (or concatenation of

Repeating Groups

CourseNumber, Grade

Student Transcript

Page 49: The Relational Database Model CST272. Return Creating the Unnormalized Table n List the fields n Select a primary key – The field (or concatenation of

1NF

Student Grade (StudentID, StudentLast, StudentFirst, AdvisorID, AdvisorLast, AdvisorFirst, AdvisorOffice, AdvisorPhone, CreditsCompleted, ClassStanding, CourseNumber, Grade)

Student Transcript Return

Page 50: The Relational Database Model CST272. Return Creating the Unnormalized Table n List the fields n Select a primary key – The field (or concatenation of

Convert from 1NF to 2NF

Identify the determinants List the functional dependencies for each

determinant Create the new tables—one for each

determinant and the fields functionally dependent upon it

Page 51: The Relational Database Model CST272. Return Creating the Unnormalized Table n List the fields n Select a primary key – The field (or concatenation of

Determinants

StudentID CourseNumber StudentID, CourseNumber

1NF

Page 52: The Relational Database Model CST272. Return Creating the Unnormalized Table n List the fields n Select a primary key – The field (or concatenation of

Determinants and Functional Dependencies StudentID StudentLast, StudentFirst, AdvisorID,

AdvisorLast, AdvisorFirst, AdvisorOffice, AdvisorPhone, CreditsCompleted, ClassStanding

CourseNumber StudentID, CourseNumber Course Grade

1NF Return

Page 53: The Relational Database Model CST272. Return Creating the Unnormalized Table n List the fields n Select a primary key – The field (or concatenation of

2NF

Student (StudentID, StudentLast, StudentFirst, AdvisorID, AdvisorLast, AdvisorFirst, AdvisorOffice, AdvisorPhone, CreditsCompleted, ClassStanding

Course (CourseNumber) Student Course (StudentID, CourseNumber,

Grade)

Determinants Return

Page 54: The Relational Database Model CST272. Return Creating the Unnormalized Table n List the fields n Select a primary key – The field (or concatenation of

Convert from 2NF to 3NF

Identify any non-key determinants List the functional dependencies for each

non-key determinant Create any new tables—one for each non-

key determinant and the fields functionally dependent upon it

Page 55: The Relational Database Model CST272. Return Creating the Unnormalized Table n List the fields n Select a primary key – The field (or concatenation of

Non-key Determinants

AdvisorID

2NF

Page 56: The Relational Database Model CST272. Return Creating the Unnormalized Table n List the fields n Select a primary key – The field (or concatenation of

Non-key Determinants

AdvisorID AdvisorLast, AdvisorFirst, AdvisorOffice, AdvisorPhone

2NF Return

Page 57: The Relational Database Model CST272. Return Creating the Unnormalized Table n List the fields n Select a primary key – The field (or concatenation of

3NF

Student (StudentID, StudentLast, StudentFirst, AdvisorID, CreditsCompleted, ClassStanding

Advisor (AdvisorID, AdvisorLast, AdvisorFirst, AdvisorOffice, AdvisorPhone)

Course (CourseNumber) Student Course (StudentID, CourseNumber,

Grade)

ReturnNon-key Determinants

Page 58: The Relational Database Model CST272. Return Creating the Unnormalized Table n List the fields n Select a primary key – The field (or concatenation of

Finalize All Tables in DBDL

Identify all keys, both primary keys and foreign keys

Page 59: The Relational Database Model CST272. Return Creating the Unnormalized Table n List the fields n Select a primary key – The field (or concatenation of

DBDL

Student (StudentID, StudentLast, StudentFirst, AdvisorID, CreditsCompleted, ClassStanding

FK AdvisorID Advisor Advisor (AdvisorID, AdvisorLast, AdvisorFirst,

AdvisorOffice, AdvisorPhone Course (CourseNumber) Student Course (StudentID, CourseNumber,

Grade)

FK StudentID Student

FK CourseNumber Course3NF

Page 60: The Relational Database Model CST272. Return Creating the Unnormalized Table n List the fields n Select a primary key – The field (or concatenation of
Page 61: The Relational Database Model CST272. Return Creating the Unnormalized Table n List the fields n Select a primary key – The field (or concatenation of

Field Name Data Type SizeVendor number Text 5Vendor name Text 25Address Text 30City Text 15State Text 2ZIP code Text 10Telephone Text 14Contact Text 25Fax Text 14Term days Number IntegerTerm percent Number SingleDate last order Date/Time

The Vendor Table

Page 62: The Relational Database Model CST272. Return Creating the Unnormalized Table n List the fields n Select a primary key – The field (or concatenation of

Field Name Data Type SizeProduct number Text 3Product Text 20

The Product Table

Page 63: The Relational Database Model CST272. Return Creating the Unnormalized Table n List the fields n Select a primary key – The field (or concatenation of

Field Name Data Type SizePO number Text 5Vendor number Text 5Subtotal CurrencyTax CurrencyShipping CurrencyDiscount CurrencyPO total CurrencyPO date Date/TimeBill date Date/TimeDiscount date Date/TimeDue date Date/Time

The Purchase Order Table

Page 64: The Relational Database Model CST272. Return Creating the Unnormalized Table n List the fields n Select a primary key – The field (or concatenation of

Field Name Data Type SizePO number Text 5Product number Text 3Unit price CurrencyQuantity Number IntegerBack ordered? Yes/No

The Payables Table

Page 65: The Relational Database Model CST272. Return Creating the Unnormalized Table n List the fields n Select a primary key – The field (or concatenation of
Page 66: The Relational Database Model CST272. Return Creating the Unnormalized Table n List the fields n Select a primary key – The field (or concatenation of
Page 67: The Relational Database Model CST272. Return Creating the Unnormalized Table n List the fields n Select a primary key – The field (or concatenation of
Page 68: The Relational Database Model CST272. Return Creating the Unnormalized Table n List the fields n Select a primary key – The field (or concatenation of

Vendor Vendor ZIPnumber name Address City State code

20001 ACME UTILITIES 149 DIVISION STREET HICKSVILLE NY 1180120002 UNITED PETROLEUM 111 STATE STREET BRENTWOOD NY 1171720004 IBM 5601 NEW HIGHWAY POUGHKEEPSIE NY 12601

Term Term Date lastTelephone Contact Fax days percent order

(516) 938-0100 HOWARD (516) 938-0110 30 15 8/31/2004(516) 722-6929 ROCHELLE (800) 555-UPUP 0 0 10/15/2004(914) 261-6000 WILL (914) 261-6001 0 0 11/1/2004

The Vendor Data

Page 69: The Relational Database Model CST272. Return Creating the Unnormalized Table n List the fields n Select a primary key – The field (or concatenation of

Productnumber Product

101 PENCILS103 PENS110 MAGIC MARKERS201 PAPER301 PAPER WEIGHT501 RUBBER BANDS650 486 COMPUTER701 PENTIUM COMPUTER702 PENTIUM II COMPUTER900 DESK AND CHAIR

The Product Data

Page 70: The Relational Database Model CST272. Return Creating the Unnormalized Table n List the fields n Select a primary key – The field (or concatenation of

PO Vendor POnumber number Subtotal Tax Shipping Discount Total

10001 20001 38.15 3.24 3.00 0.01 44.3810002 20002 20.00 0.00 2.00 0.02 21.9810003 20001 551.75 0.00 3.00 0.03 554.7210004 20001 0.00 0.00 10.00 0.00 10.00

PO Bill Discount DueDate Date Date Date7/1/2004 7/30/2004 9/29/2004 11/30/2004

7/31/2004 9/10/2004 10/9/2004 10/9/200410/22/2004 11/5/200411/24/2004 11/24/2004

The Purchase Order Data

Page 71: The Relational Database Model CST272. Return Creating the Unnormalized Table n List the fields n Select a primary key – The field (or concatenation of

PO Product Unit Backnumber number price Quantity ordered?

10001 101 0.79 10 No10001 103 1.25 5 No10001 201 2.00 12 No10002 501 20.00 1 No10003 301 17.25 3 Yes10003 900 250.00 2 Yes

The Payables Data Use the mouse to click and placea in the field meaning "Yes"

or turn off meaning "No"

Use the mouse to click and placea in the field meaning "Yes"

or turn off meaning "No"

Page 72: The Relational Database Model CST272. Return Creating the Unnormalized Table n List the fields n Select a primary key – The field (or concatenation of
Page 73: The Relational Database Model CST272. Return Creating the Unnormalized Table n List the fields n Select a primary key – The field (or concatenation of

List the supplier company, supplier stock number and item name for all products in the inventory data base?

(Linked on common field between tables)

select Item, [Supplier stock number], [Company name]from Inventory, Supplierwhere Inventory.[Supplier code] = Supplier.[Supplier code];

Joining Two Tables Together

Page 74: The Relational Database Model CST272. Return Creating the Unnormalized Table n List the fields n Select a primary key – The field (or concatenation of

select Item, [Supplier stock number], [Company name] from Inventory, Supplier where Inventory.[Supplier code] = Supplier.[Supplier code];

Stock Item Supplier Supp09001 IBM PS/2 Model 30001 00610002 Using Wordstar 40003 00410050 80 Column IBM 90000 009

Supp Company name004 Acme Publishing006 Data Supplier009 CBS Record Sys

Page 75: The Relational Database Model CST272. Return Creating the Unnormalized Table n List the fields n Select a primary key – The field (or concatenation of

Item Supplier Supp Supp Company nameIBM PS/2 Model 30001 006 004 Acme PublishingUsing Wordstar 40003 004 004 Acme Publishing80 Column IBM 90000 009 004 Acme PublishingIBM PS/2 Model 30001 006 006 Data SuppliersUsing Wordstar 40003 004 006 Data Suppliers80 Column IBM 90000 009 006 Data SuppliersIBM PS/2 Model 30001 006 009 CBS Record SysUsing Wordstar 40003 004 009 CBS Record Sys80 Column IBM 90000 009 009 CBS Record Sys

select Item, [Supplier stock number], [Company name] from Inventory, Supplier ...;

Stock Item Supplier Supp09001 IBM PS/2 Model 30001 00610002 Using Wordstar 40003 00410050 80 Column IBM 90000 009

Supp Company name004 Acme Publishing006 Data Supplier009 CBS Record Sys

Page 76: The Relational Database Model CST272. Return Creating the Unnormalized Table n List the fields n Select a primary key – The field (or concatenation of

select Item, [Supplier stock number], [Company name] from Inventory, Supplier where Inventory.[Supplier code] = Supplier.[Supplier code];

Stock Item Supplier Supp09001 IBM PS/2 Model 30001 00610002 Using Wordstar 40003 00410050 80 Column IBM 90000 009

Supp Company name004 Acme Publishing006 Data Supplier009 CBS Record Sys

Item Supplier Supp Supp Company nameIBM PS/2 Model 30001 006 004 Acme PublishingUsing Wordstar 40003 004 004 Acme Publishing80 Column IBM 90000 009 004 Acme PublishingIBM PS/2 Model 30001 006 006 Data SuppliersUsing Wordstar 40003 004 006 Data Suppliers80 Column IBM 90000 009 006 Data SuppliersIBM PS/2 Model 30001 006 009 CBS Record SysUsing Wordstar 40003 004 009 CBS Record Sys80 Column IBM 90000 009 009 CBS Record Sys

Page 77: The Relational Database Model CST272. Return Creating the Unnormalized Table n List the fields n Select a primary key – The field (or concatenation of

select Item, [Supplier stock number], [Company name] from Inventory, Supplier where Inventory.[Supplier code] = Supplier.[Supplier code];

Item Supplier Supp Supp Company nameIBM PS/2 Model 30001 006 004 Acme PublishingUsing Wordstar 40003 004 004 Acme Publishing80 Column IBM 90000 009 004 Acme PublishingIBM PS/2 Model 30001 006 006 Data SuppliersUsing Wordstar 40003 004 006 Data Suppliers80 Column IBM 90000 009 006 Data SuppliersIBM PS/2 Model 30001 006 009 CBS Record SysUsing Wordstar 40003 004 009 CBS Record Sys80 Column IBM 90000 009 009 CBS Record Sys

Stock Item Supplier Supp09001 IBM PS/2 Model 30001 00610002 Using Wordstar 40003 00410050 80 Column IBM 90000 009

Supp Company name004 Acme Publishing006 Data Supplier009 CBS Record Sys

Page 78: The Relational Database Model CST272. Return Creating the Unnormalized Table n List the fields n Select a primary key – The field (or concatenation of

Stock Item Supplier Supp09001 IBM PS/2 Model 30001 00610002 Using Wordstar 40003 00410050 80 Column IBM 90000 009

Supp Company name004 Acme Publishing006 Data Supplier009 CBS Record Sys

select Item, [Supplier stock number], [Company name] from Inventory, Supplier where Inventory.[Supplier code] = Supplier.[Supplier code];

Item Supplier Supp Supp Company nameUsing Wordstar 40003 004 004 Acme PublishingIBM PS/2 Model 30001 006 006 Data Suppliers80 Column IBM 90000 009 009 CBS Record Sys

Page 79: The Relational Database Model CST272. Return Creating the Unnormalized Table n List the fields n Select a primary key – The field (or concatenation of

select Item, [Supplier stock number], [Company name] from Inventory, Supplier where Inventory.[Supplier code] = Supplier.[Supplier code];

Item Supplier Company nameUsing Wordstar 40003 Acme PublishingIBM PS/2 Model 30001 Data Suppliers80 Column IBM 90000 CBS Record Sys

Stock Item Supplier Supp09001 IBM PS/2 Model 30001 00610002 Using Wordstar 40003 00410050 80 Column IBM 90000 009

Supp Company name004 Acme Publishing006 Data Supplier009 CBS Record Sys