Vous êtes sur la page 1sur 1

Name:___________________________

CIS-182
Homework #2 – Implementing Relationships
Turn in printed copies of your SQL statements and screen shot showing the successful
completion of each statement.
Use the ALTER command to add primary keys to the Operators, Vehicles and Trips tables.
The primary key for each table should be based on an identity field.
Create two new tables that are used to create relationships with the existing tables (use the
diagram below to illustrate the relationships):
• Run Table: One operator has many work assignments, called runs. Each run needs
an identifier, and belongs to an operator; use an identity field for the run identifier, and
include a field to serve as a foreign key for the operator table. All fields are required.
The Bid Date field cannot be more than six months in the future.
• Schedule Table: A schedule identifies the vehicle that will perform each trip, with
each schedule entry belonging to a run. Create a table that has an identity field as a
primary key, and a foreign key to identify the run the schedule belongs to, and the
vehicle performing that schedule. All fields are required.
Modify the Trip table: Add a field to identify the schedule that the trip belongs to; this field
is not required. Add a new constraint that Start time must fall between 5:30am and
11:50pm.
Turn in this sheet with your SQL code and screen prints.

Operators
Runs Vehicles
PK OperatorID
PK RunID PK VehicleID
SeniorityNumber
FirstName FK1 OperatorID Manufacturer
LastName BidDate Model
Year
PurchaseDate

Schedule
PK ScheduleID

FK1 RunID
FK2 VehicleID

Trips
PK TripID

FK1 ScheduleID
StartLocation
StartTime
EndLocation
EndTime
EffectiveDate

3/26/10

Vous aimerez peut-être aussi