C H A P T E R
22
Object-Based Databases
Practice Exercises
22.1 A car-rental company maintains a database for all vehicles in its cur-
rent fleet. For all vehicles, it includes the vehicle identification number,
license number, manufacturer, model, date of purchase, and color. Spe-
cial data are included for certain types of vehicles:
•
Trucks: cargo capacity.
•
Sports cars: horsepower, renter age requirement.
•
Vans: number of passengers.
•
Off-road vehicles: ground clearance, drivetrain (four- or two-wheel
drive).
Construct an SQL schema definition for this database. Use inheritance
where appropriate.
Answer: For this problem, we use table inheritance. We assume that
MyDate, Color and DriveTrainType are pre-defined types.
create type Vehicle
(vehicle
id integer,
license number char(15),
manufacturer char(30),
model char(30),
purchase
date MyDate,
color Color)
create table vehicle of type Vehicle
create table truck
(cargo
capacity integer)
under vehicle
create table sportsCar
1
评论0