Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
284 views

CIS182 Homework 2

The document provides instructions to modify several tables in a database to implement relationships. It instructs the user to: 1) Add primary keys to the Operators, Vehicles and Trips tables based on identity fields. 2) Create two new tables, Runs and Schedule, to relate existing tables based on the diagram. Runs includes an identity primary key and foreign key to Operators. Schedule includes an identity primary key and foreign keys to Runs and Vehicles. 3) Modify the Trips table to include a foreign key to Schedule and add a constraint that start time must be between 5:30am and 11:50pm.

Uploaded by

rriness
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
284 views

CIS182 Homework 2

The document provides instructions to modify several tables in a database to implement relationships. It instructs the user to: 1) Add primary keys to the Operators, Vehicles and Trips tables based on identity fields. 2) Create two new tables, Runs and Schedule, to relate existing tables based on the diagram. Runs includes an identity primary key and foreign key to Operators. Schedule includes an identity primary key and foreign keys to Runs and Vehicles. 3) Modify the Trips table to include a foreign key to Schedule and add a constraint that start time must be between 5:30am and 11:50pm.

Uploaded by

rriness
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 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

You might also like