Assignment 1: A) Create The Tables With The Appropriate Integrity Constraints
Assignment 1: A) Create The Tables With The Appropriate Integrity Constraints
•
create table sale( bill_no int(20)primary key,bill_date varchar(30),Cust_id int(20),
item_id int(20), foreign key (Cust_id) references Customer (Cust_id), foreign key
(item_id) references item (item_id), qty_sold int(20));
c) List all the bills for the current date with the customer names
and item numbers.
• select
Cust_name,item_id from sale natural join Customer where bill_date='2019-10-08';
d)List the total Bill details with the quantity sold, price of the item and the final
amount
• select Cust_id,Cust_name from sale natural join item natural join Customer
where price>50;
ASSIGNMENT 2
a)Create the tables with the appropriate integrity constraints
• create table student(Stud_no int(10) primary key, Stud_name varchar(20));
• create Membership(Mem_no int(10) primary key, Stud_no int(10));
• create table Book(book_no int(10) primary key, book_name varchar(20),
author varchar(20));
• create table Iss_rec(iss_no int(10) primary key, iss_date date,
Mem_no int(10), book_no int(10),
foreign key(Mem_no) references Membership(Mem_no),
foreign key(book_no) references Book(book_no));
f)Give a count of how many books have been bought by each student
• select Stud_name, count(Stud_no) from Iss_rec natural join Book natural join
Membership natural join student group by Stud_no;
g)Give a list of books taken by student with stud_no as 2
• select iss_no, iss_date,book_no, book_name from Iss_rec natural join Book natural join
Membership natural join student where Stud_no=2;
i)Create a view which lists out the iss_no, iss _date, stud_name, book name
• select iss_no, iss_date,Stud_name, book_name from Iss_rec natural join Book natural
join Membership natural join student;
j)Create a view which lists the daily issues-date wise for the last one week
• select iss_no, iss_date, Mem_no, Stud_name, book_no, book_name from
Iss_rec natural join Book natural join Membership natural join student
order by iss_date asc;
assignment 4
b.)
c.) select cust_name,mem_no from customer natural join membership;
d.) select case_name,cust_name from iss_rec natural join cassette natural join membership natural join
customer where iss_rec.iss_date='2019-10-05';
e)select cust_no,cust_name from iss_rec natural join cassette natural join membership natural join
customer where case_name="ecst";
f.)select cust_no,cust_name,count(cust_no) from iss_rec natural join membership natural join customer
group by cust_no;
g)
select cass_no,case_name from iss_rec natural join cassette natural join membership natural join customer
where mem_no=15;
h)
i)
create view detail as select iss_no, iss_date, cust_name, case_name from iss_rec natural join cassette
natural join membership natural join customer;
assignment 3
a)
b)
c)
e)
select emp_id,emp_name from paydetails natural join employee where paydetails.basic between 10000
and 20000;
f)
h)
i)
create view sho as select emp_name,dept_name,basic,deductions from paydetails natural join department
natural join employee;
j)
create view list as select emp_name,basic-deductions+additions as netsalary from paydetails natural join
employee;