0% found this document useful (0 votes)
17 views5 pages

DBMS 8th Assignment

Uploaded by

cvm28890000
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views5 pages

DBMS 8th Assignment

Uploaded by

cvm28890000
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
You are on page 1/ 5

1.

The following tables are maintained by a book dealer

AUTHOR(author-id: int, name: string, city: string, country: string)

PUBLISHER(publisher-id: int name: string, city: string, country: string)

CATLOG(book-id: int, title : string, author-id: int, publisher-id: int, category: int, year:

int, price: int)

CATEGORY(category-id: int, description: string)

ORDER-DETAILS(order-no: int, book-id: int, quantity: int)

i) Create above tables by properly specifying the primary keys and the foreign keys.

create table author(author_id number primary key, name varchar2(50), city varchar2(50), country
varchar2(50));

create table publisher(publisher_id number primary key, name varchar2(50), city varchar2(50), country
varchar2(50));

create table catlog(book_id number primary key, title varchar2(50), author_id number, publisher_id
number, category number, year number, price number, foreign key(author_id) references
author(author_id), foreign key(publisher_id) references publisher(publisher_id));

create table category(category_id number primary key, description varchar2(50));

create table order_details(order_no number primary key, book_id number, quantity number, foreign
key(book_id) references catlog(book_id));

Output:

Table created.

Table created.

Table created.

Table created.

Table created.

ii) Enter atleast five tuples for each relation.

insert into author values(1,'Yash','Mumbai','India');


insert into author values(2,'Henry','Chicago','United States of America');

insert into author values(3,'Ajay','Kolkata','India');

insert into author values(4,'Neha','Delhi','India');

insert into author values(5,'Riya','Mumbai','India');

insert into publisher values(1,'Ram', 'Kolkata','India');

insert into publisher values(2,'Shyam', 'Chennai','India');

insert into publisher values(3,'William', 'New York City','United States of America');

insert into publisher values(4,'Chitra', 'Mumbai','India');

insert into publisher values(5,'Aana', 'Los Angeles','United States of America');

insert into catlog values(1,'The Sunset',3,4,2,2014,1200);

insert into catlog values(2,'The Evening',2,1,4,2009,800);

insert into catlog values(3,'Calamity',3,3,5,2011,1500);

insert into catlog values(4,'Hello',5,4,2,2018,1300);

insert into catlog values(5,'Friends',5,5,1,2010,400);

insert into category values(1,'Describes relation between close ones');

insert into category values(2,'Describes different periodic movements');

insert into category values(3,'Describes relation between strangers');

insert into category values(4,'Describes the environment at a certain time');

insert into category values(5,'Describes different life-taking occurrences');

insert into order_details values(1,1,4500);

insert into order_details values(2,2,5600);


insert into order_details values(3,3,7300);

insert into order_details values(4,4,10500);

insert into order_details values(5,5,15800);

Output:

1 row(s) inserted.

1 row(s) inserted.

1 row(s) inserted.

1 row(s) inserted.

1 row(s) inserted.

1 row(s) inserted.

1 row(s) inserted.

1 row(s) inserted.

1 row(s) inserted.

1 row(s) inserted.

1 row(s) inserted.

1 row(s) inserted.

1 row(s) inserted.

1 row(s) inserted.

1 row(s) inserted.

1 row(s) inserted.

1 row(s) inserted.
1 row(s) inserted.

1 row(s) inserted.

1 row(s) inserted.

1 row(s) inserted.

1 row(s) inserted.

1 row(s) inserted.

1 row(s) inserted.

1 row(s) inserted.

iii) Give the details of the authors who have 2 or more books in the catalog and the price of the books is
greater than the average price of the books in the catalog and the year of publication is after 2010.

select a.* from author a where a.author_id in(select c.author_id from catlog c group by c.author_id
having count(c.book_id)>=2 and max(c.price)>(select avg(price) from catlog) and min(c.year)>2010);

Output:

iv) Find the author of the book which has maximum sales.

select a.name as author,c.title as book_name from author a inner join (catlog c inner join order_details o
on o.book_id=c.book_id) on a.author_id=c.author_id where quantity=(select max(quantity) from
order_details);

Output:

v) Demonstrate how to increase price of books published by specific publisher by 10%.


select book_id,title,price as old_price,(price+(price*10/100)) as updated_price from catlog c inner join
publisher p on c.publisher_id=p.publisher_id where name='Chitra';

Output:

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy