1
5. Database Design
Lingma AchesonDepartment of Computer and Information Science
IUPUI
CSCI N207 Data Analysis Using Spreadsheets
2
What Design is About
• You are hired by a small business, and are asked to build a database system. How would you proceed?
• There is no data to start with .• Process:
– Collect requirements• Interview potential users• Collect sample forms, reports, description of activities• Understand business rules and the nature of data
3
What Design is About
– Design the database• Sketch out the design• Document the design• Envision the future system• Create prototypes (small sample database)• Get feedbacks from the users
– Implement the database
4
Data Normalization
• Must know before starting the design!• Different levels of normalization determines
how good your table design is.• Relational model revisit:
5
First Normal Form (1NF)
E.g., Create tables to describe the students, advisors and registration information as below:
StudentNo Advisor AdvRoom Class1 Class2 Class3
1022 Jones 412 101-07 143-01 159-02
4123 Smith 216 201-01 101-07 214-01
6
First Normal Form (1NF)• First Normal Form: No repeating fields
Table: REGISTRATION
StudentNo Advisor AdvRoom ClassNo
1022 Jones 412 101-071022 Jones 412 143-011022 Jones 412 159-024123 Smith 216 201-014123 Smith 216 101-074123 Smith 216 214-01
Problem - If we change the room of Jones, we must change it in several places.
7
Second Normal Form (2NF)• Second Normal Form: Eliminate redundant
data Table: REGISTRATION
Table: STUDENT_ADVISORClassNo StudentNo
101-07 1022
143-01 1022
159-02 1022
201-01 4123
101-07 4123
214-01 4123
StudentNo Advisor AdvRoom1022 Jones 412
4123 Smith 216
Problem - If we remove one advisor, we will lose a student.
8
Third Normal Form (3NF)• Third Normal Form: Eliminate data not
dependant on keyTable: STUDENT Table: REGISTRATION
Table: ADVISOR
ClassNo StudentNo
101-07 1022
143-01 1022
159-02 1022
201-01 4123
101-07 4123
214-01 4123
StudentNo Advisor1022 Jones
4123 Smith
Advisor AdvRoomJones 412
Smith 216
9
Third Normal Form (3NF)
• Third Normal Form requires creation of primary key and foreign key relationships.
• Tables in a certain normalization level must satisfy the requirements of previous levels.
10
Third Normal Form (3NF)• Fully normalized tables:Table: STUDENT Table: REGISTRATION
Table: ADVISOR
Table: CLASS
ClassID StuID
1 1
2 1
3 1
4 2
1 2
5 2
StuID StudentNo AdvID
1 1022 12 4123 2
AdvID Advisor AdvRoom1 Jones 412
2 Smith 216
ClassID ClassNo Title1 101-07 Java Programming
2 143-01 Databases
3 159-02 Excel Spreadsheets
4 201-01 Web Development
5 214-01 Data Mining
11
Fourth & Fifth Normal Form• Further normalize the table, not covered in
our class.