105k views
3 votes
Create a database model while following the steps listed below:

Create a simple class diagram containing three classes: Vehicle, Car, and Truck. Provide two attributes for each of these three classes.
Create a rough sketch of a relational table that will store the objects belonging to the aforementioned three classes.
Ensure you have tried all three options—single table, two tables, and three tables—in your database design.
Enter two objects per table, corresponding to the classes.
Use the two-table design to recreate a Car object.
Repeat the preceding step to recreate a Truck object.
Create a simple association relationship in a separate class diagram showing Driver and Car.
Apply a multiplicity of 1 on the driver side and N on the Car side.
Add/modify your table designs to handle storing of two objects belonging to Car and two belonging to Driver.
Modify the multiplicity on the Driver side to N. This makes it a many-to-many multiplicity.
Modify your table designs to handle this multiplicity and show where and how the KEYS or IDs will have to be placed.
Create a class diagram corresponding to the tables you have designed. Stereotype all classes on that class diagram as <>.

1 Answer

2 votes

Final answer:

To create a database model for the given scenario, start by creating a class diagram with three classes: Vehicle, Car, and Truck. Then, create relational tables to store objects belonging to these classes, using three options: single table, two tables, and three tables.

Step-by-step explanation:

To create a database model for the given scenario, we will start with creating a class diagram. We will have three classes: Vehicle, Car, and Truck. Each class will have two attributes. For example, the Vehicle class could have attributes like make and model, the Car class could have attributes like color and number of doors, and the Truck class could have attributes like cargo capacity and towing capacity.

Next, we will create a rough sketch of a relational table to store objects belonging to these classes. We will try three options: single table, two tables, and three tables.To handle the single table option, we would create a table with columns for all the attributes of the three classes. Each object would be represented as a row in this table.

For the two table option, we would create separate tables for the Car and Truck classes. Each table would have columns for the attributes of the respective class, and each object would be stored as a row in the respective table. For the three table option, in addition to the separate tables for Car and Truck, we would have a separate table for the Vehicle class. The Vehicle table would have a primary key that would be used as a foreign key in the Car and Truck tables to establish a relationship.

User Ayush Goyal
by
8.1k points