create table sql query and insert data sql query for the below -
VehicleType(make, model, doors, body,trim)
Vehicle(regNum, fleetNum, colour, make,model)
ScheduledService(date,kilometrage,regNum,depotId)
ServiceHistory(date,cost,description,regNum,depotId)
Records(make,model,tariffId,rentalPrice)
DailyTariff(tariffId, conditions)
Invoice(invoiceId,qualityCheck,datePaid,finalCost,date)
Insurance(insuranceId, policyType, cost)
Insures(insuranceId,date,policyNumber)
HiredVehicle(date, cardType, cardNo, kilometrage, days,tariffId,clientId,depotId,regNum)
Depot(depotId, street,postcode,phone,fax)
Booking(startDate,hiredays,colour,depotId,make,model,clientId)
Client(clientId,street,postcode,phone)
PersonalClient(clientId, fName, lName, title, driversNum)
CompanyClient(clientID, cname)
underlined are primary keys and italicised are foreign keys.
If you have any doubts, please give me comment...
CREATE TABLE VehicleType(
make VARCHAR(30),
model VARCHAR(30),
doors INT,
body VARCHAR(50),
trim VARCHAR(50),
PRIMARY KEY(make, model)
);
CREATE TABLE Vehicle(
regNum VARCHAR(10),
fleetNum INT,
colour VARCHAR(20),
make VARCHAR(30),
model VARCHAR(30),
PRIMARY KEY(regNum),
FOREIGN KEY(make, model) REFERENCES VehicleType(make, model)
);
CREATE TABLE ScheduledService(
date DATE,
kilometrage INT,
regNum VARCHAR(10),
depotId INT,
PRIMARY KEY(date, kilometrage, regNum, depotId)
);
CREATE TABLE ServiceHistory(
date DATE,
cost FLOAT,
description VARCHAR(255),
regNum VARCHAR(10),
depotId INT,
PRIMARY KEY(date, cost, description, regNum, depotId)
);
CREATE TABLE Records(
make VARCHAR(30),
model VARCHAR(30),
tariffId INT,
rentalPrice FLOAT(5,2)
PRIMARY KEY(make, model, tariffId),
)
CREATE TABLE DailyTariff(
tariffId INT,
conditions VARCHAR(100)
FOREIGN KEY(make, model) REFERENCES VehicleType(make, model)
);
CREATE TABLE Invoice(
invoiceId INT NOT NULL PRIMARY KEY,
qualityCheck INT,
datePaid DATE,
finalCost FLOAT(5,2),
date DATE
);
CREATE TABLE Insurance(
insuranceId INT NOT NULL PRIMARY KEY,
policyType VARCHAR(20),
cost FLOAT(5,2)
);
CREATE TABLE Insures(
insuranceId INT,
date DATE,
policyNumber INT,
PRIMARY KEY(insuranceId, policyNumber, date)
);
CREATE TABLE HiredVehicle(
date DATE,
cardType VARCHAR(10),
cardNo INT,
kilometrage INT,
days INT,
tariffId INT,
clientId INT,
depotId INT,
regNum INT
);
CREATE TABLE Depot(
depotId INT NOT NULL PRIMARY KEY,
street VARCHAR(30),
postcode CHAR(5),
phone VARCHAR(15),
fax VARCHAR(15)
);
CREATE TABLE Client(
clientId INT NOT NULL PRIMARY KEY,
street VARCHAR(50),
postcode CHAR(5),
phone VARCHAR(15)
);
CREATE TABLE PersonalClient(
clientId INT NOT NULL PRIMARY KEY,
fName VARCHAR(100),
lName VARCHAR(100),
title VARCHAR(5),
driversNum VARCHAR(15)
FOREIGN KEY(clientId) REFERENCES Client(clientId)
);
CREATE TABLE CompanyClient(
clientId INT NOT NULL PRIMARY KEY,
cname VARCHAR(100),
FOREIGN KEY(clientId) REFERENCES Client(clientId)
);
CREATE TABLE Booking(
startDate DATE,
hiredays INT,
colour VARCHAR(20),
depotId INT,
make VARCHAR(30),
model VARCHAR(30),
clientId INT,
FOREIGN KEY(make, model) REFERENCES VehicleType(make, model),
FOREIGN KEY(clientId) REFERENCES Client(clientId)
);
create table sql query and insert data sql query for the below - VehicleType(make, model, doors,...
I want the create table sql from the below ER Diagram - Invoice Insurance insurancelD (PK) cyType invoicelD (PK) eck datePaid VehicleType rentalPrice /finalCost make (PK) model (PK) DailyTariff 0..1 1.1 0..1 rs 0.." tariffID (PK) bodh conditions policyNumber Records trim Generated for 1..1 1..1 Tariffs Has a Insures PersonalClient 0.. 1..1 Hired 0 Vehicle 0. HiredVehicle 1 1-1 na ame regNum (PK) date (PK) IName fleetNum cardType title 11 Nominate driversNum Ca Client kilometrage Schedules 0 1.1 days 1.1...
Answer all questions on paper: Consider the database model below The database model FIGURE 7.1 CUSTOMER INVOICE LINE PK CUS CODE INV NUMBER FK1 CUS_COOE NV DATE CUS LNAME CUS FNAME CUS INITIAL CUS AREACODE CUS PHONE CUS BALANCE LINE UNITS LINEPRICE - isfound in VENDOR PRODUCT V NAME supplies P INDATE P DESCRIPT CONTACT de- V AREACODE V PHONE V STATE V ORDER ?,.QOH P MIN P PRICE Write the SQL code for creating the database and all the...
Question 2: SQL-5 marks Using the GAMEMEMBERS relational schema below a) List the order in which the tables were created? b) Write the CREATE TABLE statement for MEMBER table. Use appropriate data types and size. HINT please look at the sample data in part c LEVEL GAME Levelp Level GAMEName GAMEMEMBER GAMEMemberiD MemberiD GAMEID Leyelp Date MEMBER MemberiD FName LName Address Suburb State PostCode Phone RegionlD REGION RegionName RegionID c) Write a SQL statement that will insert the following data...
SQL Query Question: I have a database with the tables below, data has also been aded into these tables, I have 2 tasks: 1. Add a column to a relational table POSITIONS to store information about the total number of skills needed by each advertised position. A name of the column is up to you. Assume that no more than 9 skills are needed for each position. Next, use a single UPDATE statement to set the values in the new...