P. 1
Nov-2006 SQL Solved paper tybscit 5 sem

Nov-2006 SQL Solved paper tybscit 5 sem

|Views: 768|Likes:
Published by vaibvhav
query
query

More info:

Published by: vaibvhav on Nov 24, 2009
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as DOC, PDF, TXT or read online from Scribd
See more
See less

10/31/2012

pdf

text

original

NOV- 2006 SQL Attribute Custid Lname Fname Area Phone Attribute Mvno Title Type Star Price

Attribute Invno Mvno Custid Issue date Return date Q.1 CUSTOMER Data Type Varchar(2) Varchar(15) Varchar(15) Varchar(2) Number(8) MOVIE Datatype Number(2) Varchar(25) Varchar(10) Varchar(25) Number(8,2) INVOICE Datatype Varchar(3) Number(2) Varchar(3) Date Date Constraints Primary key

Constraints Primary key

Constraints Primary key Foreign key movie(mvno) Foreign Key customer(custid)

A)State the features of Sql which have made it successful in the market. Ans in page 8 of James R. Groff. B) Explain the relational database model. Ans in page 57 of James R. Groff. c) If a view is updated, is the original table updated? Under what conditions can a view not be updated? Ans in page 423-424 of James R. Groff. D) Explain the concept of Null values. Ans in page 91 of James R. Groff. E) Create the table RIVERS according to the description shown below. Data type Upto 20 characters long Upto 4 digits Upto 20 characters long Constraint Unique and not null Values between 100 and 4160 Required

Attribute Name Length Outflow Ans:

Create table river (name varchar2(20) unique not null, Length number(4) check (length between 101 and 4160), Outflow varchar2(20) not null)

1. Add a new column called Maxdepth to the rivers table Make sure that the values of this column range from 100 to 250 feet. Ans: Alter table rivers add(Maxdepth number(3) Check (maxdepth between 100 and 250)) Q.2 A) State and explain the Codd’s 12 Rules. Ans in page 65-66 of James R. Groff. B) State and explain the built-in functions available in Sql-2 standard. Ans in page 89 of James R. Groff. C) Write SQL queries for the following: i)Create table ‘CITY’ With the following fields Field ID NAME State Data type INTEGER Upto 20 char 2 char Constraint PRIMARY KEY

Latitude Number Longitude Number Ans: Create table city ( Id number(5) primary key, Name varchar2(20), State char(2), Latitude number(5), Longitude number(5)) ii. Create table DATA with following fields: Field Data type Constraint ID Integer Forign Key Matching City Id MONTH Integer Must Be Between 1 And 12 TEMP_F Number Must Be Between -80 And 150 Rain_I Number Must be between 0 and 100 (ID+MONTH) Primay key Ans: Create table data( Id integer, Month integer check(month between 1 and 12), Temp_f number(3) check(temp_f between -80 and 150), Rain_i number(3) check(rain_i between 0 and 100 ), Primary key (ID,MONTH), Constraint fkey foreign key(ID) references city) iii. List the temperatures for July from table Data, Lowest temperatures first, picking up city name and latitude by joining with the table city. Ans : Select Temp_f, name, Latitude from Data d, City c where d.Id=c.Id and month=7 order by Temp_f asc iv. List (using Subquery) the cities with year round average temperature above 50 degrees. Ans : Select name from City where Id in( Select id from Data where 50 < All( Select avg(temp_f) from data group by ID)) Q3. A) Explain the column check constraint in sql-2. How can it be applied to many different columns in the database? Ans in page 295 of James R. Groff. B) Explain the problems created by referential cycles on referential integrity. Ans in page 308 of James R. Groff. C) What is a deadlock? How can it be avoided? Explain various techniques used to overcome deadlocks. Ans in page 348 of James R. Groff.

Q.4.

A) Explain the syntax of the select statement with various clauses that can be attached to it. Ans in page 96 of James R. Groff. B) Enumerate the problems that can corrupt referential integrity of the parent/child Relationships in a database. Ans in page 299 James R. Groff. C) Write SQL statements for the following based on the tables CUSTOMER, MOVIE AND INVOICE I. Find out the movies that cost more than 159 and also find the new cost as original cost*15 Ans: select mvno, price*15 “NEW COST” from movie where price>159 II. Print the names and types of all the movie except horror movies Ans: select title, type from movie where type not in(‘horror’) III. List the various movie types available Ans: select distinct type from movie IV. List the mvno, title of movies whose stars begins with letter’m’ Ans: select mvno, title, type from movie where star like ‘m%’ V. Determine the maximum and minimum of price. Rename the title as max-price and min_price respectively.

Ans: select max(price) “max_price”, Min(price) “min_price” From movie VI. Find out number of movies in each type Ans: select count (type) from movie group by type VII. Find out Lname, Fname and mvno of customers who have been issued a movie. Ans: select mvno, Lname , Fname From customers, invoice Where customer.custid = invoice.custid Q.5 A) What is a trigger? How are triggers used to implement referential integrity? Ans in page 320-322 of James R. Groff. B) What is a transaction? Why is it necessary thata transactioneither be complete or completely aborted? Explain the two transaction processing statement in sql. Ans in page 328 of James R. Groff. C)Write SQL statements for the following based on the tables CUSTOMER, MOVIE AND INVOICE I. Print the information of invoice table in the following format for all records. The invoice no of customer id.{ custid} is { invno} and movie no is { movno} Ans: Select ‘the invoice no of customer id : ’|| custid||’ is ‘|| invno||’ and movie No. is ‘|| movno from invoice II. Select the title, custid, mvno for all the movies that are issued. Ans: Select Title, mvno, custid from movie, invoice Where movie.mvno= invoice.mvno III. Find out which customers have been issued movie number (Mvno)9. Ans: Select fname from Customer,invoice Where customer.custid=invoice.custid and mvno=9 IV. Display the month(in alphabets) in which customers are supposed to return the movies Ans: Select to_char(Returndate,’mon’) From invoice Or Select Month(returnDate) from Invoice Q.6 A) Explain the concept of domain in sql-2 standard. Ans in page 296 of James R. Groff. B) Explain the different types of joins in sql. Give an example of each type. Ans in page 175-180 of James R. Groff. C) Write SQL statements for the following based on the tables CUSTOMER, MOVIE AND INVOICE I. Delete all the records having return date before 10th July ‘05 Ans: Delete from invoice Where returndate<’10-JUL-05’ II. Find out if the movie starring ‘TOM Cruise’ is issued to any customer and list the custid to whom it is issued Ans: Select custid from invoice, movie Where invoice.mvno=movie.mvno and movie.star like ‘Tom Cruise’ III. Find the names of customers who have been issued movie of type’drama’ Ans: Select Fname||’ ‘||lname “Name” From customer c, movie M, invoice i Where c.custid=i.custid AND m.mvno=i.mvno And m.type like ‘drama’ IV. Find out the title of the movies that have been issued to the customer whose Fname is’ Mary’ Ans: Select title from customer, movie, invoice Where customer.custid=invoice.custid AND Movie.mvno=invoice.mvno AND Customer.Fname like ‘Mary’ Q.7. A) Explain the different database architectures.

Ans in page 37-40 of The Complete Ref. James R. Groff. B) What are aliases? How can they be created and dropped? Ans in page 386 of The Complete Ref. by James R. Groff. C) Write SQL statements for the following based on the tables CUSTOMER, MOVIE AND INVOICE i. ii. Add a column Remark of type varchar and size 25 to the invoice table Ans: Alter table invoice add(Remark varchar(25)); Find the names of all customers having ‘a’ in the second letter in their fname Ans: Select Fname||’ ‘|| lname “Name” From customer Where fname like ’_a%’ Find out the movie number which has been issued to customer whose first name is ‘IVAN’ Ans: select i.mvno from customer c, invoice i Where c.custid=i.custid and fname like ‘IVAN’ Display the title, Lname,Fname for customers having movie number greater than or equal to three in the following format. The movie taken by { Fname} { Lname} is { Title} Ans: Select ‘The movie taken by ‘|| Fname||’ ‘|| Lname||’ is ‘||Title from customer c, movie m, invoice i where c.custid=i.custid AND m.mvno=i.mvno and m.mvno>=3 -----------------------

iii.

iv.

You're Reading a Free Preview

Download
scribd
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->