Sunteți pe pagina 1din 2

create table emp (empid int, deptid int foreign key references department(deptid)) 1.

Expain views in sql server with examples? 2.Explain stored procedures and functions with examples? 3.Explain triggers with examples? 4. The following tables are maintained by a book dealer: 1. AUTHOR (author-id: int, name: string, city: string, country: string) 2. PUBLISHER (publisher-id : int, name: string, city:string, country : string) 3. CATEGORY (category-id:int, description:string) 4. CATALOG (book-id : int, title : string, author-id:int, publisher-id:int, category-id:int, year:int, price:int) 5. ORDER-DETAILS (order-no:int, book-id:int, quantity:int) (i) Create the above tables by properly specifying the primary keys and the foreign key? (ii) Enter at least five tuples for each relation. (iii) Increase the price of books published by a publisher whose name starts with a by 10%.?

(iv) Write a query to find the book details whose price is maximum? (v) Write a query to find the book details whose price is greater than the average amount? (vi) Delete the tuple whose book price is 500 and author name ends with y? (vii) Display the name of the books whose author name is repeated more than once? (viii) Display the orderno whose book id is more than 2? (ix) Display the book id whose price is between 500 and 2000?

S-ar putea să vă placă și