Design a set of database tables to store people and cars A p
Design a set of database tables to store people and cars. A person has a name, a unique driver license number, and an address. Every car has a unique vehicle identification number, manufacturer, type, and year. Every car has one owner, but one person can own multiple cars. Show the CREATE TABLE statements that could be used to create these two tables. Give SQL commands to create a Book table, with columns for the ISBN, author, and title, and to insert all textbooks that you are using this semester. Using the tables for the invoice database used as an example in chapter 24, give a SQL query that lists all customers who have an unpaid invoice (the amount paid on the invoice is zero).
Solution
CREATE TABLE Persons
{
Name varchar(255),
License varchar(255) NOT NULL PRIMARY KEY,
Address varchar(255)
};
CREATE TABLE Cars
{
VehicleID int NOT NULL PRIMARY KEY,
Manufacturer varchar(255),
Type varchar(255),
Year int,
owner varchar(255)
};
Explanation
CREATE TABLE table_name
(
column1 type(size),
column2 type(size),
column3 type(size),
....
);
