Vous êtes sur la page 1sur 7

Case Study Solution

Case Study Solution Database Design using MySQL 07-Feb-06 : [1]


Entities
“A county bus company owns a number of buses and has
asked you to create a database to keep track of their
business. Each bus is allocated to a particular route, with
some routes having several allocated buses. Each route
passes through a number of towns. One or more drivers
are allocated to each stage of the route, which
corresponds to a journey through some or all of the towns
on a route. Some of the towns have a garage where
buses can be kept, each bus having one ‘home’ garage.”

Case Study Solution Database Design using MySQL 07-Feb-06 : [2]


Relationships
‘Each bus is allocated to a particular route, with some routes having several allocated buses’
BUS [many-to-one] ROUTE
‘Each route passes through a number of towns’
ROUTE [many-to-many] TOWN
‘each stage of the route’
ROUTE [one-to-many] STAGE
‘One or more drivers are allocated to each stage’
DRIVER [many-to-one] STAGE
‘[a stage] corresponds to a journey through some or all of the towns on a route’
STAGE [many-to-many] TOWN
‘Some of the towns have a garage’
TOWN [one-to-one] GARAGE
‘each bus having one ‘home’ garage’
BUS [many-to-one] GARAGE

Case Study Solution Database Design using MySQL 07-Feb-06 : [3]


Attributes

BUS (registration, num_pass)


ROUTE (number, avg_pass)
TOWN (name, pop)
STAGE (number)
DRIVER (emp_num, name, phone)
GARAGE (name)

Case Study Solution Database Design using MySQL 07-Feb-06 : [4]


EAR Diagram

BUS ROUTE

GARAGE STAGE DRIVER

TOWN

Case Study Solution Database Design using MySQL 07-Feb-06 : [5]


Relational Table Schema
TABLE bus (reg, passengers, route, garage)
TABLE route (number, avg_pass)
TABLE stage (number, route)
TABLE town (name, population)
TABLE garage (name, town)
TABLE driver (emp_id, name, phone, stage)
TABLE map (stage, town)

Case Study Solution Database Design using MySQL 07-Feb-06 : [6]


Review
• Practised designing a database from a
real life specification:
– Define entities, relationships and attributes.
– Draw up an EAR diagram.
– Map this EAR diagram to a normalised
relational table schema.

Case Study Solution Database Design using MySQL 07-Feb-06 : [7]

Vous aimerez peut-être aussi