Escolar Documentos
Profissional Documentos
Cultura Documentos
SCHEMA - PHYSICAL Exercise 2 Create the physical schema for BUS ERD.
Exercise 3 Review constraints for primary and foreign
CONSTRAINTS
keys.
Inserting Data Exercise 4 Inserting data to a the BUS example
MODEL SOLUTIONS
Solution Exercise 1 Produce a BUS ERD.
ER Modeling
Exercise 1 Produce a BUS ERD.
A small bus company keeps details of the starting place, destination, and fare for all
routes which it operates. Each route has a unique route number and is divided into a
number of stages. A stage is identified by the names of the bus stops that mark its
beginning and end. For example, route number 154 goes from Hartlepool-Greatham,
Greatham-Wolviston, Wolviston-Billingham, and Billingham-Norton. Each stage may
appear in a number of routes, and is given a different sequence number for each
route. For example, Greatham-Wolviston is stage 2 on route 154, stage 3 on route
178 Billingham-Sunderland, and stage 6 on route 105 Stockton-Hartlepool. The
distance in miles is kept for each stage. Each route is associated with a number of
scheduled departures, each of which is identified by a day of the week and a time.
The estimated arrival time at the destination is recorded for each departure. There
may be a number of departures, for different routes, leaving at the same time?on the
same day. For example, route 154 departs at 9.15 on Monday, 10.00 on Wednesday,
and at 9.30 and 15.00 on Saturday. Route 105 also departs at 9.30 on Saturday.
Once a week a particular bus is allocated to each departure scheduled for the
following week. The data on which bus is allocated to which departure is only kept for
one week , being removed when buses are allocated for the following week. Details
of the registration number and seating capacity of each bus are recorded. Every
route must consist of at least one stage, but details of a stage may be kept even if it
is not currently part of route. Details of the scheduled departures are recorded before
buses are allocated. Details of all buses are recorded even if they are not currently
allocated to any departures. Details of routes are to be recorded before departures
have been arranged.
TASKS
You may decide to modify the data requirements or generate additional data attributes
to assist in your design of the database. Write down details of any assumptions you
have made that you feel are important.
SCHEMA - PHYSICAL
Exercise 2 Create the physical schema for BUS ERD.
SQL Server Physical Schema are the SQL commands required for Table
Definitions.
These commands are loaded into the QA interface and executed to create the
tables for the ERDs.
CONSTRAINTS
Exercise 3 Review the constraints for primary and foreign
keys.
Make sure the constraints for primary and foreign keys are
embedded correctly in the SQL code generated in Ex 2.
General Constraints
Inserting Data
Exercise 4 Inserting data to the BUS database
Using the INSERT command write an insert schema to load the BUS
database with sample data.
ACCESS - SQL
Exercise 5 Produce a MS Access and MS SQL Server project
based on this case study
MODEL SOLUTIONS
The following model and schema does not cover every aspect of the case study.
Travels_on_a
Bus Route
0.. * 0.. *
Minimum no. of buses travelling on each route?
Maximum no. of buses travelling on each route?
Minimum no. of routes travelled by each bus?
Maximum no. of routes travelled by each bus?
1..1
Route
PK is route_no
Consists_of
Route Stages
0..* 1..*
Minimum no. of routes for each stage?
Maximum no. of routes for each stage?
Minimum no. of stages for each route?
Maximum no. of stages for each route?
Consists_of
Stage_on_a_route Route
0..* 1..1
0..* PK is route_no
Is_a
1..1
PK is stage_start, stage_end
Stage
ERD BUS.
Makes_a
Bus Departure
1..1 1..*
0..*
Along_a
1..1
Consists_of
Stage_on_a_route Route
0..*
1..1
0..*
1..1
Stage
Note order of insert. Load tables without foreign keys first. Otherwise an error- cannot
insert value does not exist as primary key will occur on foreign key tables. Important that
data is consistent e.g. that departures refer to data in bus