![Page 1: © Copyright 2002, L. M. Linson, may be freely used with this notice Practical Database Design “Structuring Your Tables” by Larry Linson, presented to the](https://reader034.vdocument.in/reader034/viewer/2022042703/56649ee65503460f94bf5bb4/html5/thumbnails/1.jpg)
© Copyright 2002, L. M. Linson, may be freely used with this
notice
Practical Database Design
“Structuring Your Tables”
by Larry Linson,
presented to the
Microsoft Access SIG of the
North Texas PC User Group
January 12, 2002
![Page 2: © Copyright 2002, L. M. Linson, may be freely used with this notice Practical Database Design “Structuring Your Tables” by Larry Linson, presented to the](https://reader034.vdocument.in/reader034/viewer/2022042703/56649ee65503460f94bf5bb4/html5/thumbnails/2.jpg)
© Copyright 2002, L. M. Linson, may be freely used with this
notice
Purpose• Laying out or structuring tables
– in an Access (or other relational) database
• Without formal data modeling• Without becoming a relational
database expert• Accomplishing results with
– common sense– intuition
![Page 3: © Copyright 2002, L. M. Linson, may be freely used with this notice Practical Database Design “Structuring Your Tables” by Larry Linson, presented to the](https://reader034.vdocument.in/reader034/viewer/2022042703/56649ee65503460f94bf5bb4/html5/thumbnails/3.jpg)
© Copyright 2002, L. M. Linson, may be freely used with this
notice
“Relational”
• “Relation” = Table– Rows (“Tuples”)and
– Columns (“Attribute”)• Scalar means one value per …
• Not from “Relationships”– between Tables
![Page 4: © Copyright 2002, L. M. Linson, may be freely used with this notice Practical Database Design “Structuring Your Tables” by Larry Linson, presented to the](https://reader034.vdocument.in/reader034/viewer/2022042703/56649ee65503460f94bf5bb4/html5/thumbnails/4.jpg)
© Copyright 2002, L. M. Linson, may be freely used with this
notice
Heading of a Relation
• Label for each attribute Name : Domain
• Name identifies
• Domain = kind of data (not the data type)
![Page 5: © Copyright 2002, L. M. Linson, may be freely used with this notice Practical Database Design “Structuring Your Tables” by Larry Linson, presented to the](https://reader034.vdocument.in/reader034/viewer/2022042703/56649ee65503460f94bf5bb4/html5/thumbnails/5.jpg)
© Copyright 2002, L. M. Linson, may be freely used with this
notice
First Normal Form
• If domains are scalar– one item of information per
attribute
– some questionable, e.g., dates• clearly consist of parts• depends on problem space• do you need to use the parts?
![Page 6: © Copyright 2002, L. M. Linson, may be freely used with this notice Practical Database Design “Structuring Your Tables” by Larry Linson, presented to the](https://reader034.vdocument.in/reader034/viewer/2022042703/56649ee65503460f94bf5bb4/html5/thumbnails/6.jpg)
© Copyright 2002, L. M. Linson, may be freely used with this
notice
Second Normal Form• In First Normal Form and • If all attributes dependent on
the primary key– no “extraneous” information– Invoice
• Invoice Number• Supplier Name• Supplier Phone• Item• Price
![Page 7: © Copyright 2002, L. M. Linson, may be freely used with this notice Practical Database Design “Structuring Your Tables” by Larry Linson, presented to the](https://reader034.vdocument.in/reader034/viewer/2022042703/56649ee65503460f94bf5bb4/html5/thumbnails/7.jpg)
© Copyright 2002, L. M. Linson, may be freely used with this
notice
Third Normal Form . . .
• In Second Normal Form and • If all attributes are mutually
independent– violation example,
• If one Sales Rep per State
– Order• Order ID• Sales Rep• State• Customer ID
![Page 8: © Copyright 2002, L. M. Linson, may be freely used with this notice Practical Database Design “Structuring Your Tables” by Larry Linson, presented to the](https://reader034.vdocument.in/reader034/viewer/2022042703/56649ee65503460f94bf5bb4/html5/thumbnails/8.jpg)
© Copyright 2002, L. M. Linson, may be freely used with this
notice
Third Normal Form
• In practical terms,
• as far as we usually go, and
• sometimes useful to violate
continued from previous slide
![Page 9: © Copyright 2002, L. M. Linson, may be freely used with this notice Practical Database Design “Structuring Your Tables” by Larry Linson, presented to the](https://reader034.vdocument.in/reader034/viewer/2022042703/56649ee65503460f94bf5bb4/html5/thumbnails/9.jpg)
© Copyright 2002, L. M. Linson, may be freely used with this
notice
There must be only one authoritative source for any
item of information.
![Page 10: © Copyright 2002, L. M. Linson, may be freely used with this notice Practical Database Design “Structuring Your Tables” by Larry Linson, presented to the](https://reader034.vdocument.in/reader034/viewer/2022042703/56649ee65503460f94bf5bb4/html5/thumbnails/10.jpg)
© Copyright 2002, L. M. Linson, may be freely used with this
notice
![Page 11: © Copyright 2002, L. M. Linson, may be freely used with this notice Practical Database Design “Structuring Your Tables” by Larry Linson, presented to the](https://reader034.vdocument.in/reader034/viewer/2022042703/56649ee65503460f94bf5bb4/html5/thumbnails/11.jpg)
© Copyright 2002, L. M. Linson, may be freely used with this
notice
and it will force you into a
structured, usable file design
![Page 12: © Copyright 2002, L. M. Linson, may be freely used with this notice Practical Database Design “Structuring Your Tables” by Larry Linson, presented to the](https://reader034.vdocument.in/reader034/viewer/2022042703/56649ee65503460f94bf5bb4/html5/thumbnails/12.jpg)
© Copyright 2002, L. M. Linson, may be freely used with this
notice
Avoid: Redundancy …
• A BAD IDEA– Wastes resources
– Makes life harder
• because – You have to store multiple copies
– Which is correct?
![Page 13: © Copyright 2002, L. M. Linson, may be freely used with this notice Practical Database Design “Structuring Your Tables” by Larry Linson, presented to the](https://reader034.vdocument.in/reader034/viewer/2022042703/56649ee65503460f94bf5bb4/html5/thumbnails/13.jpg)
© Copyright 2002, L. M. Linson, may be freely used with this
notice
Avoid: Redundancy …• Even worse if
– in two or more tables
• because – not only how many records to
change
– but how many places to look for it
![Page 14: © Copyright 2002, L. M. Linson, may be freely used with this notice Practical Database Design “Structuring Your Tables” by Larry Linson, presented to the](https://reader034.vdocument.in/reader034/viewer/2022042703/56649ee65503460f94bf5bb4/html5/thumbnails/14.jpg)
© Copyright 2002, L. M. Linson, may be freely used with this
notice
Avoid: Composite Fields
• Concatenating is easy– [Title] &[First] & [Mid] & [Last] & [Suf]
• Extracting isn’t so easy– “Umm? How?” he pondered,
• scratching his head and staring
![Page 15: © Copyright 2002, L. M. Linson, may be freely used with this notice Practical Database Design “Structuring Your Tables” by Larry Linson, presented to the](https://reader034.vdocument.in/reader034/viewer/2022042703/56649ee65503460f94bf5bb4/html5/thumbnails/15.jpg)
© Copyright 2002, L. M. Linson, may be freely used with this
notice
Avoid: Repeated Fields
• One record w/ repeat– [Student] – [Period 1 Class]– [Period 2 Class]– . . . – [Period 6 Class]
• Which students study biology?
![Page 16: © Copyright 2002, L. M. Linson, may be freely used with this notice Practical Database Design “Structuring Your Tables” by Larry Linson, presented to the](https://reader034.vdocument.in/reader034/viewer/2022042703/56649ee65503460f94bf5bb4/html5/thumbnails/16.jpg)
© Copyright 2002, L. M. Linson, may be freely used with this
notice
Our Example . . .
• A friend, client, or employer says,
–“Our order-taking process is a little clumsy. I’d like you to create a database to smooth it out and make it quicker for the sales people.”
![Page 17: © Copyright 2002, L. M. Linson, may be freely used with this notice Practical Database Design “Structuring Your Tables” by Larry Linson, presented to the](https://reader034.vdocument.in/reader034/viewer/2022042703/56649ee65503460f94bf5bb4/html5/thumbnails/17.jpg)
© Copyright 2002, L. M. Linson, may be freely used with this
notice
Our Example . . .
• You ask,
–“What, exactly, do you want in that database?”
continued from previous slide
![Page 18: © Copyright 2002, L. M. Linson, may be freely used with this notice Practical Database Design “Structuring Your Tables” by Larry Linson, presented to the](https://reader034.vdocument.in/reader034/viewer/2022042703/56649ee65503460f94bf5bb4/html5/thumbnails/18.jpg)
© Copyright 2002, L. M. Linson, may be freely used with this
notice
Our Example
• Friend, client, employer responds,
–“Here’s one of our order forms. Too, I’d like to keep track of the product training courses our sales people have to take. Please make a prototype to suggest what I need.”
continued from previous slide
![Page 19: © Copyright 2002, L. M. Linson, may be freely used with this notice Practical Database Design “Structuring Your Tables” by Larry Linson, presented to the](https://reader034.vdocument.in/reader034/viewer/2022042703/56649ee65503460f94bf5bb4/html5/thumbnails/19.jpg)
© Copyright 2002, L. M. Linson, may be freely used with this
notice
An OrderCustomer Name and Number
Bill-To Address
Ship-To Address
Quantity, Product, Price, Extended Price
. . .
Order Number, Date
Ship Method & Date
Salesperson
Subtotal, Tax, Shipping, Total
![Page 20: © Copyright 2002, L. M. Linson, may be freely used with this notice Practical Database Design “Structuring Your Tables” by Larry Linson, presented to the](https://reader034.vdocument.in/reader034/viewer/2022042703/56649ee65503460f94bf5bb4/html5/thumbnails/20.jpg)
© Copyright 2002, L. M. Linson, may be freely used with this
notice
Better than we might expect
• Suggests the information
• Seems to group the information, too
• Natural and intuitive– Sales staff used to it– Likely refined over years
• Try using it to group the information– Then make tables for each group
![Page 21: © Copyright 2002, L. M. Linson, may be freely used with this notice Practical Database Design “Structuring Your Tables” by Larry Linson, presented to the](https://reader034.vdocument.in/reader034/viewer/2022042703/56649ee65503460f94bf5bb4/html5/thumbnails/21.jpg)
© Copyright 2002, L. M. Linson, may be freely used with this
notice
Not Just “Order Information”Customer Name and Number
Bill-To Address
Ship-To Address
Quantity, Product, Price, Extended Price
. . .
Order Number, Date
Ship Method & Date
Salesperson
Subtotal, Tax, Shipping, Total
![Page 22: © Copyright 2002, L. M. Linson, may be freely used with this notice Practical Database Design “Structuring Your Tables” by Larry Linson, presented to the](https://reader034.vdocument.in/reader034/viewer/2022042703/56649ee65503460f94bf5bb4/html5/thumbnails/22.jpg)
© Copyright 2002, L. M. Linson, may be freely used with this
notice
Some “Customer” InfoCustomer Name and Number
Bill-To Address
Ship-To Address
Quantity, Product, Price, Extended Price
. . .
Order Number, Date
Ship Method & Date
Salesperson
Subtotal, Tax, Shipping, Total
![Page 23: © Copyright 2002, L. M. Linson, may be freely used with this notice Practical Database Design “Structuring Your Tables” by Larry Linson, presented to the](https://reader034.vdocument.in/reader034/viewer/2022042703/56649ee65503460f94bf5bb4/html5/thumbnails/23.jpg)
© Copyright 2002, L. M. Linson, may be freely used with this
notice
Some “Salesperson” InfoCustomer Name and Number
Bill-To Address
Ship-To Address
Quantity, Product, Price, Extended Price
. . .
Order Number, Date
Ship Method & Date
Salesperson
Subtotal, Tax, Shipping, Total
![Page 24: © Copyright 2002, L. M. Linson, may be freely used with this notice Practical Database Design “Structuring Your Tables” by Larry Linson, presented to the](https://reader034.vdocument.in/reader034/viewer/2022042703/56649ee65503460f94bf5bb4/html5/thumbnails/24.jpg)
© Copyright 2002, L. M. Linson, may be freely used with this
notice
Repeated “Detail” InfoCustomer Name and Number
Bill-To Address
Ship-To Address
Quantity, Product, Price, Extended Price
. . .
Order Number, Date
Ship Method & Date
Salesperson
Subtotal, Tax, Shipping, Total
![Page 25: © Copyright 2002, L. M. Linson, may be freely used with this notice Practical Database Design “Structuring Your Tables” by Larry Linson, presented to the](https://reader034.vdocument.in/reader034/viewer/2022042703/56649ee65503460f94bf5bb4/html5/thumbnails/25.jpg)
© Copyright 2002, L. M. Linson, may be freely used with this
notice
Some Product InfoCustomer Name and Number
Bill-To Address
Ship-To Address
Quantity
. . .
Order Number, Date
Ship Method & Date
Salesperson
Subtotal, Tax, Shipping, Total
Extended PriceProduct, Price
![Page 26: © Copyright 2002, L. M. Linson, may be freely used with this notice Practical Database Design “Structuring Your Tables” by Larry Linson, presented to the](https://reader034.vdocument.in/reader034/viewer/2022042703/56649ee65503460f94bf5bb4/html5/thumbnails/26.jpg)
© Copyright 2002, L. M. Linson, may be freely used with this
notice
And the rest is “Order Info”Customer Name and Number
Bill-To Address
Ship-To Address
Quantity
. . .
Order Number, Date
Ship Method & Date
Salesperson
Subtotal, Tax, Shipping, Total
Extended PriceProduct, Price
![Page 27: © Copyright 2002, L. M. Linson, may be freely used with this notice Practical Database Design “Structuring Your Tables” by Larry Linson, presented to the](https://reader034.vdocument.in/reader034/viewer/2022042703/56649ee65503460f94bf5bb4/html5/thumbnails/27.jpg)
© Copyright 2002, L. M. Linson, may be freely used with this
notice
Grouping by Intuition
• Salespeople
• Customers
• Orders
• Order Details
• Products
![Page 28: © Copyright 2002, L. M. Linson, may be freely used with this notice Practical Database Design “Structuring Your Tables” by Larry Linson, presented to the](https://reader034.vdocument.in/reader034/viewer/2022042703/56649ee65503460f94bf5bb4/html5/thumbnails/28.jpg)
© Copyright 2002, L. M. Linson, may be freely used with this
notice
Adding the Training
• Salespeople
• Customers
• Orders
• Order Details
• Products
• Training
![Page 29: © Copyright 2002, L. M. Linson, may be freely used with this notice Practical Database Design “Structuring Your Tables” by Larry Linson, presented to the](https://reader034.vdocument.in/reader034/viewer/2022042703/56649ee65503460f94bf5bb4/html5/thumbnails/29.jpg)
© Copyright 2002, L. M. Linson, may be freely used with this
notice
Sales Database Information – The Intuitive Approach
• Salespeople sell products to customers• Customers purchase products• Orders record a customer purchase• Order Details show products, quantities• Products are what is sold, with price• Training (Product information) for
Salespeople
![Page 30: © Copyright 2002, L. M. Linson, may be freely used with this notice Practical Database Design “Structuring Your Tables” by Larry Linson, presented to the](https://reader034.vdocument.in/reader034/viewer/2022042703/56649ee65503460f94bf5bb4/html5/thumbnails/30.jpg)
© Copyright 2002, L. M. Linson, may be freely used with this
notice
Try Laying Out Tables
Customers
Products
Order Details
Orders
Salespeople
Training
![Page 31: © Copyright 2002, L. M. Linson, may be freely used with this notice Practical Database Design “Structuring Your Tables” by Larry Linson, presented to the](https://reader034.vdocument.in/reader034/viewer/2022042703/56649ee65503460f94bf5bb4/html5/thumbnails/31.jpg)
© Copyright 2002, L. M. Linson, may be freely used with this
notice
Rearrange by Relationship
Customers
Products
Orders
Salespeople
Training
(use real-world relationships)
There’s a customer for every order
There’s a salesperson for every order
Order Details
![Page 32: © Copyright 2002, L. M. Linson, may be freely used with this notice Practical Database Design “Structuring Your Tables” by Larry Linson, presented to the](https://reader034.vdocument.in/reader034/viewer/2022042703/56649ee65503460f94bf5bb4/html5/thumbnails/32.jpg)
© Copyright 2002, L. M. Linson, may be freely used with this
notice
Continue Rearranging
Customers
Products
Orders
Salespeople
Training
A customer can have many orders
A salesperson can have many orders
Order Details
![Page 33: © Copyright 2002, L. M. Linson, may be freely used with this notice Practical Database Design “Structuring Your Tables” by Larry Linson, presented to the](https://reader034.vdocument.in/reader034/viewer/2022042703/56649ee65503460f94bf5bb4/html5/thumbnails/33.jpg)
© Copyright 2002, L. M. Linson, may be freely used with this
notice
Continue Rearranging
Customers
Products
Order Details
Orders
Salespeople
Training
An order can have many order details
![Page 34: © Copyright 2002, L. M. Linson, may be freely used with this notice Practical Database Design “Structuring Your Tables” by Larry Linson, presented to the](https://reader034.vdocument.in/reader034/viewer/2022042703/56649ee65503460f94bf5bb4/html5/thumbnails/34.jpg)
© Copyright 2002, L. M. Linson, may be freely used with this
notice
Continue Rearranging
Customers
Products
Order Details
Orders
Salespeople
Training
A product can be in many order details
![Page 35: © Copyright 2002, L. M. Linson, may be freely used with this notice Practical Database Design “Structuring Your Tables” by Larry Linson, presented to the](https://reader034.vdocument.in/reader034/viewer/2022042703/56649ee65503460f94bf5bb4/html5/thumbnails/35.jpg)
© Copyright 2002, L. M. Linson, may be freely used with this
notice
Continue Rearranging
Customers
Products
Order Details
Orders
Salespeople
Training
A salesperson can take many training classes
![Page 36: © Copyright 2002, L. M. Linson, may be freely used with this notice Practical Database Design “Structuring Your Tables” by Larry Linson, presented to the](https://reader034.vdocument.in/reader034/viewer/2022042703/56649ee65503460f94bf5bb4/html5/thumbnails/36.jpg)
© Copyright 2002, L. M. Linson, may be freely used with this
notice
Did We Forget Something?
Customers
Products
Order Details
Orders
Salespeople
Training
Many salespeople can be in a training class
Maybe! Depends on what we may need to do.
![Page 37: © Copyright 2002, L. M. Linson, may be freely used with this notice Practical Database Design “Structuring Your Tables” by Larry Linson, presented to the](https://reader034.vdocument.in/reader034/viewer/2022042703/56649ee65503460f94bf5bb4/html5/thumbnails/37.jpg)
© Copyright 2002, L. M. Linson, may be freely used with this
notice
Did We Forget Something?
Customers
Products
Order Details
Orders
Salespeople
Training
Many salespeople can have taken a training class or many can be in a session of a class.
No, let’s revise that statement:
![Page 38: © Copyright 2002, L. M. Linson, may be freely used with this notice Practical Database Design “Structuring Your Tables” by Larry Linson, presented to the](https://reader034.vdocument.in/reader034/viewer/2022042703/56649ee65503460f94bf5bb4/html5/thumbnails/38.jpg)
© Copyright 2002, L. M. Linson, may be freely used with this
notice
Did We Forget Something?
Customers
Products
Order Details
Orders
Salespeople
Training
Many salespeople can have taken a training class or many can be in a session of a class.
If the first, then we have a many-to-many
![Page 39: © Copyright 2002, L. M. Linson, may be freely used with this notice Practical Database Design “Structuring Your Tables” by Larry Linson, presented to the](https://reader034.vdocument.in/reader034/viewer/2022042703/56649ee65503460f94bf5bb4/html5/thumbnails/39.jpg)
© Copyright 2002, L. M. Linson, may be freely used with this
notice
Did We Forget Something?
Customers
Products
Order Details
Orders
Salespeople
Training
If we have a many-to-many, to implement we need a junction or intersection table
Junction
![Page 40: © Copyright 2002, L. M. Linson, may be freely used with this notice Practical Database Design “Structuring Your Tables” by Larry Linson, presented to the](https://reader034.vdocument.in/reader034/viewer/2022042703/56649ee65503460f94bf5bb4/html5/thumbnails/40.jpg)
© Copyright 2002, L. M. Linson, may be freely used with this
notice
Did We Forget Something?
Customers
Products
Order Details
Orders
Salespeople
Training
Many salespeople can have taken a training class or many can be in a session of a class.If our data model requires the second, then
we need another table for sessions.
![Page 41: © Copyright 2002, L. M. Linson, may be freely used with this notice Practical Database Design “Structuring Your Tables” by Larry Linson, presented to the](https://reader034.vdocument.in/reader034/viewer/2022042703/56649ee65503460f94bf5bb4/html5/thumbnails/41.jpg)
© Copyright 2002, L. M. Linson, may be freely used with this
notice
How Many Levels
• Take to as many levels of detail– as you need to represent what you need to
“model”
• A database is merely a model– of the real world– detailed enough to satisfy the needs
• and deal with the business “issue”– we don’t have “problems” any more, only “issues”– or, perhaps, “opportunities”
![Page 42: © Copyright 2002, L. M. Linson, may be freely used with this notice Practical Database Design “Structuring Your Tables” by Larry Linson, presented to the](https://reader034.vdocument.in/reader034/viewer/2022042703/56649ee65503460f94bf5bb4/html5/thumbnails/42.jpg)
© Copyright 2002, L. M. Linson, may be freely used with this
notice
How Many Levels?
• Einstein is supposed to have said, “As simple as possible, but no simpler.”
• Too simple, and you don’t satisfy the purpose
• Not simple enough, it will be “cumber-some” and you have to work too hard to satisfy the purpose
![Page 43: © Copyright 2002, L. M. Linson, may be freely used with this notice Practical Database Design “Structuring Your Tables” by Larry Linson, presented to the](https://reader034.vdocument.in/reader034/viewer/2022042703/56649ee65503460f94bf5bb4/html5/thumbnails/43.jpg)
© Copyright 2002, L. M. Linson, may be freely used with this
notice
What did he say
• Look at what is needed
• You are “modeling” the real world
• Base on “real world” activity, data
• Organize for what you need
• Look for natural groupings
• Look for natural relationships
• Review with the user
![Page 44: © Copyright 2002, L. M. Linson, may be freely used with this notice Practical Database Design “Structuring Your Tables” by Larry Linson, presented to the](https://reader034.vdocument.in/reader034/viewer/2022042703/56649ee65503460f94bf5bb4/html5/thumbnails/44.jpg)
© Copyright 2002, L. M. Linson, may be freely used with this
notice
• Thank you for your kind attention
• Please, gently wake your neighbor before leaving
• Come again when you can
![Page 45: © Copyright 2002, L. M. Linson, may be freely used with this notice Practical Database Design “Structuring Your Tables” by Larry Linson, presented to the](https://reader034.vdocument.in/reader034/viewer/2022042703/56649ee65503460f94bf5bb4/html5/thumbnails/45.jpg)
© Copyright 2002, L. M. Linson, may be freely used with this
notice
Practical Database Design
“Structuring Your Tables”
The End