Question

In: Computer Science

Problem 1. Please create the following tables for a tool rental database with appropriate primary keys...

Problem 1. Please create the following tables for a tool rental database with appropriate primary keys & foreign keys. [30 points]

Assumptions:

  1. Each tool belongs to a category.
  2. Each category may have a parent category but the parent category should not have parent category (so at most two levels). E.g., a Tool A belongs to electric mower, and electric mower belongs to mower. Mower has no parent category.
  3. Each tool can be rented at different time units. The typical time units are hourly, daily, and weekly. There is a different price for each time unit and tool combination. E.g., tool A may be rented at $5 per hour, $30 per day, and $120 per week.
  4. Each customer can rent a tool for a certain number of time units. If the tool is returned late a late fee will be charged.

  

The list of tables is:

Tables:

Cust Table:

cid, -- customer id

cname, --- customer name

cphone, --- customer phone

cemail, --- customer email

Category table:

ctid, --- category id

ctname, --- category name

parent, --- parent category id since category has a hierarchy structure, power washers, electric power washers, gas power washers. You can assume that there are only two levels.

Tool:

tid, --- tool id

tname, --- tool name

ctid, --- category id, the bottom level.

quantity, --- number of this tools

Time_unit table allowed renting unit

tuid, --- time unit id

len, --- length of period, can be 1 hour, 1 day, etc.

min_len, --- minimal #of time unit, e.g., hourly rental but minimal 4 hours.

Tool_Price:

tid, --- tool id

tuid, --- time unit id

price, -- price per period

Rental:

rid, --- rental id

cid, --- customer id

tid, --- tool id

tuid, --- time unit id

num_unit, --- number of time unit of rental, e.g., if num_unit = 5 and unit is hourly, it means 5 hours.

start_time, -- rental start time

end_time, --- suppose rental end_time

return_time, --- time to return the tool

credit_card, --- credit card number

total, --- total charge

Solutions

Expert Solution

Syntax for creating database

create database tool;

Syntax for selecting database

use tool_rental;

Syntax for creating Customer Table

create table cust_table(cid int NOT NULL,cname varchar(30),cphone varchar(11),cemail varchar(100), PRIMARY KEY(cid));

Syntax for creating Category table

create table category_table(ctid int NOT NULL,ctname varchar(50),parent varchar(50),primary key(ctid));

Syntax for Tool table

create table tool(tid int not null,tname varchar(50),ctid int not null, quantity int, primary key(tid),foreign key(ctid) references category_table(ctid));

Syntax for Time Unit table

create table time_unit(tuid int not null,len_hours int,min_len int, primary key(tuid));

Syntax for Tool price table

create table tool_price(tid int not null,tuid int not null,price float,foreign key(tid) references tool(tid),foreign key(tuid)references time_unit(tuid));

Syntax for Rental Table

create table rental(rid int not null,cid int not null,tid int not null,num_unit int,start_time datetime,end_time datetime,return_time datetime,creadit_card int,total int,primary key(rid),foreign key(cid) references cust_table(cid),foreign key(tid) references tool(tid));


Related Solutions

Please create the following tables for a tool rental database with appropriate primary keys & foreign...
Please create the following tables for a tool rental database with appropriate primary keys & foreign keys. Assumptions: 1. Each tool belongs to a category. 2. Each category may have a parent category but the parent category should not have a parent category (so at most two levels). E.g., a Tool A belongs to the electric mower, and electric mowers belong to mowers. Mower has no parent category. 3. Each tool can be rented at different time units. The typical...
Create a Database Schema for a hotel reservation system. indicate the Primary Keys, Foreign Keys, and...
Create a Database Schema for a hotel reservation system. indicate the Primary Keys, Foreign Keys, and the one-to-one or one-to-many relationships between the tables. Also describe in a small paragraph the scope of the back-end database, by explaining the different tables and their relations in your schema.
Database Design CIW State_Capitals Physical Database Create primary and secondary keys for the attached unfinished physical...
Database Design CIW State_Capitals Physical Database Create primary and secondary keys for the attached unfinished physical database design. CREATE DATABASE STATE_CAPITALS; GO USE STATE_CAPITALS; GO CREATE TABLE Country( Country_Code varchar(10) NOT NULL, Country_Name varchar(50) NOT NULL, Population int NOT NULL, Country_Size float NOT NULL ) GO CREATE TABLE Region( Country_Code varchar(10) NOT NULL, Region_Code varchar(10) NOT NULL, Region_Name varchar(50) NOT NULL ) GO CREATE TABLE State( Region_Code varchar(10) NOT NULL, State_Code char(2) NOT NULL, State_Name varchar(50) NOT NULL, Date_of_Statehood int...
In the world of database design and building it is very important to define Primary keys...
In the world of database design and building it is very important to define Primary keys in each table. The text this week talks about primary keys. What are they and why are they so important to a properly functioning database?
Consider the following three tables, primary and foreign keys. Table Name        SalesPeople Attribute Name                  &nbsp
Consider the following three tables, primary and foreign keys. Table Name        SalesPeople Attribute Name                                Type                                      Key Type EmployeeNumber             Number                               Primary Key Name                                   Character JobTitle                                  Character            Address                                 Character PhoneNumber                     Character YearsInPosition                             Number Table Name        ProductDescription Attribute Name                                Type                                      Key Type                 ProductNumber                Number                               Primary Key                 ProductName                  Character                            ProductPrice                   Number Table Name        SalesOrder Attribute Name                                Type                                      Key Type                 SalesOrderNumber        Number                               Primary Key                 ProductNumber               Number                               Foreign Key                 EmployeeNumber           Number                               Foreign Key                 SalesOrderDate                Date Assume that you...
Database exercise: inpatient cases Create database using name RUMKIT Create tables below in that database patient(idPatient,...
Database exercise: inpatient cases Create database using name RUMKIT Create tables below in that database patient(idPatient, fullName, biologicalMother, birthdate, address) doctor(idDr, fullName, specialization, consulRates) inpatient(idPatient, entryTime, outTime, idDr, idRoom). Please make entryTime as column that is going to be filled automatically when care record is being add room(idRoom, roomName, cost) fill the data above to each table Create sql query and relational algebra expressions for the query Please give me detailed answer so I could learn from it. Thank you...
Consider the database of a car rental company that contains three tables drivers, cars and reservation...
Consider the database of a car rental company that contains three tables drivers, cars and reservation tables. Drivers:                                           Reservation:                              Cars: Dno Dname age Dno Cno Day Cno Cmake Color 22 Dustin 45 22 101 10/10 101 BMW Blue 29 Brutus 33 22 102 10/10 102 VW Red 31 Lubber 55 22 103 10/8 103 OPEL Green 32 Andy 25 22 104 10/7 104 FIAT Red 58 Rusty 35 31 102 11/10 64 Horatio 35 31 103 11/6 71 Zorba...
Consider the database of a car rental company that contains three tables drivers, cars and reservation...
Consider the database of a car rental company that contains three tables drivers, cars and reservation tables. Drivers:                                           Reservation:                              Cars: Dno Dname age Dno Cno Day Cno Cmake Color 22 Dustin 45 22 101 10/10 101 BMW Blue 29 Brutus 33 22 102 10/10 102 VW Red 31 Lubber 55 22 103 10/8 103 OPEL Green 32 Andy 25 22 104 10/7 104 FIAT Red 58 Rusty 35 31 102 11/10 64 Horatio 35 31 103 11/6 71 Zorba...
Using your downloaded DBMS (MS SQL Server), create a new database. Create the database tables based...
Using your downloaded DBMS (MS SQL Server), create a new database. Create the database tables based on your entities defining The attributes within each table The primary and foreign keys within each table *****Show your database tables, tables attributes, primary and foreign keys***** Do not forget to check the lesson slides and videos that show you how to convert an ER/EER into a database schema, and how to create a database and tables using MS SQL Server.
Database: Question 11 Using the ERD from problem 10, create the relational schema.(Create an appropriate collection...
Database: Question 11 Using the ERD from problem 10, create the relational schema.(Create an appropriate collection of attributes for each of the entities. Make sure you use the appropriate naming conventions to name the attributes.)
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT