Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- DROP table RentalItem;
- drop table item;
- drop table rental;
- drop table cust;
- drop sequence REntityID;
- create sequence REntityID start with 1000 increment by 1;
- create table cust(
- custID int default next value for REntityID primary key,
- fname varchar(50),
- lname varchar(50)
- );
- create table rental(
- rentalID int default next value for REntityID primary key,
- startdate datetime default getdate(),
- custid int not null references cust
- );
- Create table item(
- itemID int default next value for REntityID primary key,
- name varchar(60),
- type varchar(30),
- rentalPrice decimal(5,2), /* this is a comment */
- );
- create table RentalItem(
- rentalID int references rental,
- itemID int references item,
- ActualPrice decimal(5,2) ,
- constraint RentalItem_PK primary key (rentalID, itemid),
- );
- INSERT INTO cust(fname, lname)
- values('David','Patten'),
- ('Orson','Pratt'),
- ('Orson','Hyde');
- INSERT INTO item(name, type, rentalPrice)
- values('Unicycle1','cycle', 5),
- ('Unicycle2','cycle', 5),
- ('Bicycle1','cycle', 7),
- ('Mountain Bike','cycle', 8),
- ('Snowboard','Arctic', 5),
- ('Helmet1','safety', 1),
- ('Helmet2','safety', 1),
- ('Helmet3','safety', 1),
- ('Helmet4','safety', 1)
- ;
- insert into rental(custid)
- values((select custid from cust where lname='Patten'));
- insert into rentalitem values(
- (select max(rentalid) from rental),
- (select itemid from item where name = 'Mountain Bike'),
- (select rentalPrice *.95 from item where name = 'Mountain Bike')
- );
- insert into rentalitem values(
- (select max(rentalid) from rental),
- (select itemid from item where name = 'Helmet1'),
- 0
- );
- insert into rental(custid)
- values((select custid from cust where lname='Patten'));
- insert into rentalitem values(
- (select max(rentalid) from rental),
- (select itemid from item where name = 'Mountain Bike'),
- (select rentalPrice *.95 from item where name = 'Mountain Bike')
- );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement