1 of 13

CSE 344: Section 5

Database Design

1

Jul 14 , 2022

Design Section

2 of 13

Announcements

  • HW 3 due yesterday (tomorrow with 2 late days)
  • HW 4 released yesterday, due next Friday (July 28th)

2

Jul 14 , 2022

Design Section

3 of 13

Database Design

3

Jul 14 , 2022

Database Design

Database Design or Logical Design or Relational Schema Design is the process of organizing data into a database model.

Consider what data needs to be stored and the interrelationship of the data.

Arbitrary Data

Database

There are no good or bad designs, just tradeoffs.

Design Section

4 of 13

Data Relationship Discovery

How do we find relationships between attributes?

Flights dataset:

Did you know that every canceled flight�has an actual_time of 0?

  1. Domain approach
  2. Data mining approach

4

Jul 14 , 2022

Design Section

5 of 13

Data Relationship Discovery

Domain approach:

Before looking at the data, �think about the domain

Research the domain and realize that �canceled flights have a 0 flight time!

5

Jul 14 , 2022

Design Section

6 of 13

Data Relationship Discovery

Data mining approach:

Don’t worry about the domain, �just find patterns in the data

Look at the data and notice that every time canceled = 1, then actual_time = 0.

SELECT DISTINCT actual_time

FROM Flights

WHERE canceled = 1;

The only actual_time value is 0

6

Jul 14 , 2022

Design Section

7 of 13

Data Relationship Discovery

How do we find relationships between attributes?

7

Jul 14 , 2022

Domain Approach

E/R Diagrams

Data Approach

Functional Dependencies (FDs)

Boyce-Codd Normal Form (BCNF)

Design Section

8 of 13

ER Diagrams

  • Visual graph of entities and relationships

8

Jul 14 , 2022

Product

Company

Person

employs

buys

makes

price

name

ceo

name

address

address

name

id

Design Section

9 of 13

Relationships

  • one-one: ssn - UW student id
  • one-many: ssn - phone#
  • many-many: store - product
  • is-a: computer - PC and computer - Mac
  • has-a: country - city
    • What country does the city of Cambridge belong to?

9

Jul 14 , 2022

 

“at most one”

“exactly one”

is a

“subclass”

no constraint

other constraint

Design Section

10 of 13

E/R Demo

Create an ER diagram containing the following:

  • The id, name, gender, country of birth, �and country region (continent) of birth for students and faculty
  • The major of students
  • The salary of faculty
  • The courses that each student takes
  • The department each course is offered in

10

Jul 14 , 2022

Design Section

11 of 13

E/R Demo

11

Jul 14 , 2022

The id, name, gender, country of birth, and country region of birth for students and faculty

The major of students

The salary of faculty

The courses that each student takes

The department each course is offered in

Design Section

12 of 13

E/R Demo – Sample Solution

12

Jul 14 , 2022

The id, name, gender, country of birth, and country region of birth for students and faculty

The major of students

The salary of faculty

The courses that each student takes

The department each course is offered in

Design Section

13 of 13

E/R Demo – Sample Solution

13

Jul 14 , 2022

Country (name, region)

People (id, country_name, gender, p_name)

Faculty (People.id, salary)

Student (People.id, major)

Course (courseID, dept)

Took (Student.People.id, Course.courseID)

Design Section