Phase 2 & Database Design: MSTU 5031
Phase 2 & Database Design: MSTU 5031
&
Database Design
MSTU 5031
Phase 2
• Defining requirements
• Analyzing requirements
• Exploring alternatives
Defining Requirements
• Inputs
• Outputs
• Processes
• Timing
• User Controls
Amazon.com
• Inputs
– Index page
• Search string
• Clicking on links
• Outputs (nouns)
– Search results
– Web page
• Processes (verbs)
– Search database for search string
– Retrieve web page
• Timing
• User controls
Online Book Publishing Store
• Publishing company with 3 subsidiary lines
• The database stores information that editors,
administrators and executives might want about
books, their authors, their editors, and the
company’s financial arrangements.
• The database can produce many kinds of reports
summarizing current sales, comparing different
book lines, discovering which editors work with
which authors, etc…
Steps
1. Investigate
2. List all entities and all possible attributes
3. Entity-Relationship diagrams
4. Ensure each entity has attribute(s) you can use to
uniquely identify any row in a future table.
5. Consider relationship between entities
6. Analyze according to normalization guidelines
7. SQL
8. Reevaluate
What is database design?
• The process of deciding what the database
will look like.
• Database design involves choosing
– The tables
– Columns for each table
– How the table and columns interact with each
other
• Iterative process
Characteristics of Good &
Design
• Good design… • Bad design…
– Makes your interactions – Foster misunderstandings
with the database easier to of query results
understand – Increase the risk of
– Guarantees the consistency introducing inconsistencies
of the database in the data.
– Paves the way for the – Force redundant data entry
highest performance your – Make life difficult if you
system can deliver. need to change the structure
of the tables you’ve built
and filled with data
Logical Structure
• Database design is concerned with the
logical structure of a database.
• Independent of what the user eventually
sees.
• Independent of the physical structure and
storage of the database.
Approach to Database Design
• Design aids
– Questions
– Business Rules
– Entity-relationship modeling
– Normalization
– Data dictionary/definitions
Questions & Business Rules
• Which authors live in • An author may have
California? written more than one
• Which business book book
costs more than $9.95? • A book may have been
• How much do we owe a collaborative project
the author of Life of more than one
Without Fear? author
Data Entities & Relationships
• Entity relationship modeling
– The things - entities about which information
will be store in the database system
– The properties of these things
– The relationships among them
Normalization
• Protecting your data integrity by avoiding
duplicate data.
• The normalization guidelines are most
useful when you’ve identified which
columns go in which table.
Normalization
• Set of design standards called normal forms
• Five normal forms are widely accepted
• Making your tables match these standards is
normalization
• Form progresses in order from first through
fifth
• Each form implies that the requirements of
the previous form have been met
Why Normalize?
• Normalization guidelines involves splitting tables into
tow or more tables with fewer columns, designating
primary-foreign key relationships into new smaller
tables that can be reconnected with the join operation.
• This help reduce data redundancy within tables
• Intentional duplication is not the same as redundancy
• The maintenance of intentional duplication
(consistency) between primary and foreign keys is a
major point of referential integrity.
Entities & Attributes
• Entities
• Attributes
Entities
• Authors
• Books
• Editors
• Subsidiary publishing houses
Properties or Attributes of Each
Entity
• Book
– Book’s name
– Book’s price
– Book’s publication date
• Author
– Author’s name
– Author’s address
– Author’s telephone number
• Editor
– Editor’s name
– Editor’s address
– Editor’s telephone number
• Publisher
– Publisher's name
– Publisher’s address
Preliminary Sketch
Titles Authors Editors Publishers
• Entity
– Attribute name
– Null? (required field, primary key, foreign key)
– Field size
– Data type (varchar, date, )
– Instance