Escolar Documentos
Profissional Documentos
Cultura Documentos
23
Observations about DATA b c
1 a
a database
• Permanent storage of data is also referred
yz to as persistent data 8 9
x 7
2 3 Why do we need database design? b c
1 a
yz 8 9
x 7
Analysis to Design
(Logical model to Physical model)
Design
Student Major (Physical)
iD note:
name code majorCode
majorCode name is a
synonym for
code
Example of Duplicate Data
(notice the redundancy in the data values)
789-12-3456 IDS-180 A
789-12-3456 IDS-250 A
Foreign Key
Hierarchical Components of Persistent Data
Bits 01110001 Bytes A, B, ... Z, 0,1...9, #, &, $, etc...
Attributes
Template
First Name Middle Initial Last Name Social Security Number State
Ronald J Norman 559-65-8213 CA
First Name Middle Initial Last Name Social Security Number State
Social
Security First Middle Last
Number Name Initial Name Zipcode Telephone etc.......
123-45-6789 Jim R Thomas 91942 464-3782 etc...
321-54-6638 Mary J Wilson 92020 571-2190 etc...
559-38-8921 Minder Chang 91938 291-8374 etc...
Transaction Table -
holds the business activity for the information system
Foreign Key
• Avoid anomalies
Sample Data
ROWID ID NAME COURSE GRADE MAJOR
1 020 Jim IDS301 A IDS
2 020 Jim IDS180 B IDS
3 025 Joe CS137 A CS
4 196 Mary IDS301 A IDS
5 196 Mary IDS480 B IDS
6 196 Mary FIN323 B IDS
Deletion Anomalies
• Deletion anomalies: When a value for one
attribute is unexpectedly removed when a
value for another attribute is deleted.
• E.g. deleting row 3 results in the ‘loss’ of the
CS major
Update Anomalies
• Update anomalies: In order to effect a
change to a single attribute, changes to
multiple rows of a table must be made.
customerNumber
customerName
customerAddress
customerCity
customerState
customerZipcode
orderTotal (derived)
orderTax (derived)
orderDelivery (derived)
orderGrandTotal (derived)
services
SalesOrder and ProductsOrdered Classes with Objects in First N.F.
SalesOrder 1.
orderNumber (primary key) Remove Attributes
orderDate that can have
multiple values
customerNumber 1,7
customerName
customerAddress
customerCity
customerState
customerZipcode
orderTotal (derived)
orderTax (derived)
orderDelivery (derived)
1
orderGrandTotal (derived)
services ProductsOrdered
orderNumber (primary key)
productNumber (primary key)
productName
productColor
productUnitPrice
productQuantity
productTotalPrice (derived)
services
Order Number ABC Incorporated Order Date
34820 SALES ORDER FORM 12/02/97
6
7
ProductsOrdered
orderNumber (primary key) 34820 34820 34820 34820 34820
productNumber (primary key) IC-PENT PS-220 KB-102 MO-675 HD-550
Intel Pentium CPU etc... etc... etc... etc...
productName
Bn Sl Tn Tn Sl
productColor 75 325
675 150 65
productUnitPrice 1 1 1 2 1
productQuantity 675 150 75 130 325
productTotalPrice (derived)
34820
34820 HD-550
ProductsOrdered 34820 MO-675 etc...
34820 KB-102 etc... Sl
orderNumber (primary key) 34820 PS-220 etc... Tn 325
productNumber (primary key) IC-PENT etc... Tn 65 1
productName Intel Pentium CPU Sl 75 2 325
productColor Bn 150 1 130
productUnitPrice 675 1 75
productQuantity 1 150
productTotalPrice (derived) 675
services
(continued)
34823
34823 HD-550
34822 IC-80486 etc...
34821 KB-102
34821 Intel 80486 Sl
PS-220 102-key
IC-80486 CPU 325
220 V. Power Keyboard
Intel 80486 CPU Bn 3
Supply Tn
Bn 325 975
Sl 75
325 2
150 4
10 650
3 300
3,250 450
Sales Order Data Structure
SalesOrder
orderNumber (primary key) in Second Normal Form
orderDate
customerNumber 2.
customerName Remove non-key
customerAddress
1,7
attributes that
customerCity
customerState are not fully,
customerZipcode functionally
dependent on all
orderTotal (derived)
orderTax (derived) attributes in the
orderDelivery (derived) primary key
orderGrandTotal (derived) (partial
services dependency)
1
ProductsOrdered
Product
productNumber (primary key) orderNumber (primary key)
0,m productNumber (primary key)
productName
productColor 1 productUnitPrice
productUnitPrice productQuantity
productTotalPrice (derived)
services
services
SalesOrder Sample Objects For Second
orderNumber (primary key)
orderDate
Normal Form Sales Order
customerNumber
customerName
customerAddress 1,m
customerCity
customerState
customerZipcode
orderTotal (derived)
orderTax (derived) 1
orderDelivery (derived) etc.....
orderGrandTotal (derived)
services ProductsOrdered
orderNumber (primary key) 34820
productNumber (primary key) IC-PENT
productUnitPrice 675
productQuantity 1
productTotalPrice (derived) 675
Product
productNumber (primary key) IC-80486 PS-220 KB-102 MO-675 HD-550
productName Intel Pentium CPU 220 V. Power Supply 102-key Keyboard Mouse - Serial 550 MB HD
productColor Bn Sl Tn Tn Sl
productUnitPrice 675 150 75 65 325
services
SalesOrder Customer
customerNumber (primary key)
orderNumber (primary key) 1
orderDate customerName
0,m customerAddress
customerNumber customerCity
1,m customerState
orderTotal (derived) customerZipcode
orderTax (derived)
orderDelivery (derived) services
orderGrandTotal (derived)
services
3.
Remove attributes
that are uniquely
identified by another
non-key attribute 1
(transitive
dependency) ProductsOrdered
Product orderNumber (primary key)
productNumber (primary key) 0,m productNumber (primary key)
productName productUnitPrice
productColor 1 productQuantity
productUnitPrice productTotalPrice (derived)
services services
ABC
primary keys AD A B B C
primary key
= dependency = dependency
Normalization Example
Course Registration Record
sophisticated.
Object-Oriented Data Model
• Object identity
The Object-Oriented Database
Management System Manifesto Rules
The system must:
1. Support complex objects
2. Support object identity
3. Allow objects to be encapsulated
4. Support types or classes
5. Support inheritance
6. Avoid premature binding
7. Be computationally complete
8. Be extensible
long strings
4. Complex objects
1. New problem solving approach
5. Version control
2. Lack of a common data model
6. Schema evolution with a strong theoretical foundation
7. Equivalent objects 3. Limited success stories
8. Long transactions
9. User Benefits