Transcript
Page 1: 5. Database Design Lingma Acheson Department of Computer and Information Science IUPUI CSCI N207 Data Analysis Using Spreadsheets 1

1

5. Database Design

Lingma AchesonDepartment of Computer and Information Science

IUPUI

CSCI N207 Data Analysis Using Spreadsheets

Page 2: 5. Database Design Lingma Acheson Department of Computer and Information Science IUPUI CSCI N207 Data Analysis Using Spreadsheets 1

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

Page 3: 5. Database Design Lingma Acheson Department of Computer and Information Science IUPUI CSCI N207 Data Analysis Using Spreadsheets 1

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

Page 4: 5. Database Design Lingma Acheson Department of Computer and Information Science IUPUI CSCI N207 Data Analysis Using Spreadsheets 1

4

Data Normalization

• Must know before starting the design!• Different levels of normalization determines

how good your table design is.• Relational model revisit:

Page 5: 5. Database Design Lingma Acheson Department of Computer and Information Science IUPUI CSCI N207 Data Analysis Using Spreadsheets 1

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

Page 6: 5. Database Design Lingma Acheson Department of Computer and Information Science IUPUI CSCI N207 Data Analysis Using Spreadsheets 1

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.

Page 7: 5. Database Design Lingma Acheson Department of Computer and Information Science IUPUI CSCI N207 Data Analysis Using Spreadsheets 1

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.

Page 8: 5. Database Design Lingma Acheson Department of Computer and Information Science IUPUI CSCI N207 Data Analysis Using Spreadsheets 1

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

Page 9: 5. Database Design Lingma Acheson Department of Computer and Information Science IUPUI CSCI N207 Data Analysis Using Spreadsheets 1

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.

Page 10: 5. Database Design Lingma Acheson Department of Computer and Information Science IUPUI CSCI N207 Data Analysis Using Spreadsheets 1

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

Page 11: 5. Database Design Lingma Acheson Department of Computer and Information Science IUPUI CSCI N207 Data Analysis Using Spreadsheets 1

11

Fourth & Fifth Normal Form• Further normalize the table, not covered in

our class.


Recommended