You are on page 1of 9

Lab 2

Exercise 1. You have been given a form which shows the details of technical jobs carried out
for different schools by members of staff in the local college. You will note that one job may
require input from more than one member of staff. Each member of staff belongs to a department
within the college and the number of hours worked on each job along with the date the job was
undertaken are noted. A member of staff may work on more than one job on any given date.

The college would like to set up a relational database to manage the allocation of staff to jobs
and keep a more efficient record of the number of hours worked for each school within the
college.

Your task is making the database to 3NF (specify step by step: determine FDs, normalization,..).

TechNo TechName DeptId Department JobNo Date SchoolID School Hoursworked

298 Walls, Ian 1 Engineering 1002 12/9/07 192 Beauty 2.5

298 Walls, Ian 1 Engineering 1003 12/9/07 125 Computing 5.5

345 Smith, Alan 2 Helpdesk 1002 12/9/07 192 Beauty 3

345 Smith, Alan 2 Helpdesk 3440 18/9/07 346 Bus & Man 1.5

345 Smith, Alan 2 Helpdesk 1480 15/9/07 192 Beauty 3

380 Jackson, 3 Labs 3670 19/9/07 560 Design 4


Bob

380 Jackson, 3 Labs 3440 18/9/07 346 Bus & Man 2


Bob

300 Jones, Joe 2 Helpdesk 1450 15/9/07 125 Computing 1

300 Jones, Joe 2 Helpdesk 1480 15/9/07 192 Beauty 3

320 Young, Jill 3 Labs 3440 18/9/07 346 Bus & Man 4

320 Young, Jill 3 Labs 1002 12/9/07 192 Beauty 2.5

320 Young, Jill 3 Labs 3670 19/9/07 560 Design 2

Exercise 2. Based on the form below, design a database suitable for storing information.
(Name of counseling center)

(Code: ….)

Consultation registers list

From …../…../…… To ……/……./………

Result
Test
Name of Registrant

Sex

Name of counselor

Code of counselor
Code of Registrant

Registration time

Referral Service
Start time of
consultation

Negative
Positive
Female
Male
Date

Age

Yes
No

No
                               

                               

                               

                               

                               

                               

Code of referral services:


0 – Not 1 – Care and 2 – ST1 care 3 – TB care 4 – Prevention of
recommend treatment mother-to-child
infection
5 – Family 6 – Other 7 – Support 8 - Detoxification
planning medical care groups

ANSWERS:

Exercise 1:
We’re working with a table, which shows the details of technical jobs carried out for different
schools by members of staff in the local college: technicians’ numbers, technicians’ names,
departments ID, the departments, jobs’ numbers, dates, colleges ID, the colleges, and numbers
of hours worked. The table is in the first normal form since all column values are atomic.

TechNo TechName DeptId Department JobNo Date SchoolID School Hoursworked

298 Walls, Ian 1 Engineering 1002 12/9/07 192 Beauty 2.5

298 Walls, Ian 1 Engineering 1003 12/9/07 125 Computing 5.5

345 Smith, Alan 2 Helpdesk 1002 12/9/07 192 Beauty 3

345 Smith, Alan 2 Helpdesk 3440 18/9/07 346 Bus & Man 1.5

345 Smith, Alan 2 Helpdesk 1480 15/9/07 192 Beauty 3

380 Jackson, 3 Labs 3670 19/9/07 560 Design 4


Bob

380 Jackson, 3 Labs 3440 18/9/07 346 Bus & Man 2


Bob

300 Jones, Joe 2 Helpdesk 1450 15/9/07 125 Computing 1

300 Jones, Joe 2 Helpdesk 1480 15/9/07 192 Beauty 3

320 Young, Jill 3 Labs 3440 18/9/07 346 Bus & Man 4

320 Young, Jill 3 Labs 1002 12/9/07 192 Beauty 2.5

320 Young, Jill 3 Labs 3670 19/9/07 560 Design 2

The FDs include:

- {TechNo} -> {TechName, DeptId, Department}

- {DeptId} -> {Department}

- {JobNo} -> {Date, SchoolID, School}

- {SchoolID} -> {School}

- {TechNo, JobNo} -> {Hoursworked}

The primary keys are TechNo and JobNo.


 Second normal form (2NF):

 TECHNICIAN TABLE (key = TechNo)

TechNo TechName DeptId Department

298 Walls, Ian 1 Engineering

345 Smith, Alan 2 Helpdesk

380 Jackson, 3 Labs


Bob

300 Jones, Joe 2 Helpdesk

320 Young, Jill 3 Labs

 JOB AND SCHOOL TABLE (key = JobNo)

JobNo Date SchoolID School

1002 12/9/07 192 Beauty

1003 12/9/07 125 Computing

3440 18/9/07 346 Bus & Man

1480 15/9/07 192 Beauty

3670 19/9/07 560 Design

1450 15/9/07 125 Computing

 HOURS WORK TABLE (key = TechNo + JobNo)

TechNo JobNo Hoursworked

298 1002 2.5

298 1003 5.5

345 1002 3

345 3440 1.5

345 1480 3
380 3670 4

380 3440 2

300 1450 1

300 1480 3

320 3440 4

320 1002 2.5

320 3670 2

o Relationships:

- TechNo (TECHNICIAN TABLE) -> TechNo (HOURS WORK TABLE): 1 -> n.

- JobNo (JOB AND SCHOOL TABLE) -> JobNo (HOURS WORK TABLE): 1 -> n.

 Third normal form (3NF):

 TECHNICIAN TABLE (key = TechNo)

TechNo TechName DeptId

298 Walls, Ian 1

345 Smith, Alan 2

380 Jackson, 3
Bob

300 Jones, Joe 2

320 Young, Jill 3

 DEPARTMENT TABLE (key = DeptId)

DeptId Department

1 Engineering

2 Helpdesk

3 Labs
 JOB AND SCHOOL TABLE (key = JobNo)

JobNo Date SchoolID

1002 12/9/07 192

1003 12/9/07 125

3440 18/9/07 346

1480 15/9/07 192

3670 19/9/07 560

1450 15/9/07 125

 SCHOOL TABLE (key = SchoolID)

SchoolID School

192 Beauty

125 Computing

346 Bus & Man

560 Design

 HOURS WORK TABLE (key = TechNo + JobNo)

TechNo JobNo Hoursworked

298 1002 2.5

298 1003 5.5

345 1002 3

345 3440 1.5

345 1480 3

380 3670 4

380 3440 2
300 1450 1

300 1480 3

320 3440 4

320 1002 2.5

320 3670 2

o Relationships:

- TechNo (TECHNICIAN TABLE) -> TechNo (HOURS WORK TABLE): 1 -> n.

- JobNo (JOB AND SCHOOL TABLE) -> JobNo (HOURS WORK TABLE): 1 -> n.

- DeptId (DEPARTMENT TABLE) -> DeptId (TECHNICIAN TABLE): 1 -> n.

- SchoolID (SCHOOL TABLE) -> SchoolID (JOB AND SCHOOL TABLE): 1 -> n.

Exercise 2:

(Name of counseling center)

(Code: ….)

Consultation registers list

From …../…../…… To ……/……./………


Result
Test
Name of Registrant

Sex

Name of counselor
Code of Registrant

Code of counselor
Registration time

Referral Service
Start time of
consultation

Negative
Positive
Female
Male
Date

Age

Yes
No

No
                               

                               

                               

                               

                               

                               

Code of referral services:


0 – Not 1 – Care and 2 – ST1 care 3 – TB care 4 – Prevention of
recommend treatment mother-to-child
infection
5 – Family 6 – Other 7 – Support 8 - Detoxification
planning medical care groups

Start by gathering any existing data that will be included in the database. Then list the types of
data you want to store and the entities:

 REGISTRANT:

- Code of Registrant

- Name of Registrant

- Age

- Sex

 CONSULTATION:

- Date

- Registration time

- Start time of consultation

- Test
- Result

- Referral Service

 COUNSELOR:

- Name of counselor

- Code of counselor

 Entity-relationship diagram:

You might also like