You are on page 1of 15
a 1 (a) Define degree and cardinality. Based upon given table, write degree and cardinality. Table: PATIENTS [Paso[—_Patame [Dept [Dost] [Raa — SOT Ps sat [or [a [eta fer [5 [sak orto [20 | v) and output for (v) & (vii) based on table oe commands for the queries (#) (0 ,) Write SQ) @ and CUSTOMER. Table : COMPANY 1D. NAME CITY PRODUCTNAME a Tit [| SONY DELHI m2 | NOKIA MUMBAI 333 [ ONIDA DELHI TV 444_| SONY MUMBAI__| MOBILE 10; (vii) SELECT AVG(QTY) FROM CUSTOMER, WHERE NAME LIKE "%r%"; (viii) SELECT PRODUCTNAME, CITY, PRICE FROM COMPANY, CUSTOMER JUCTNAME="MOBILE"; WHERE COMPANY.CID=CUSTOMER.CID AND PROD NEE = ibe apna Gorse RE Ae + eee ae 2 a) Differentiate between Data Definition Language and Data Manipulation Language. 2 Consider the following table SCHOOLBUS and answer (4) and (¢) parts of this question: 6 TABLE : SCHOOLBUS RiNo covered Jenpacity | noofstudents [distance | Transporter | Charges \ Vasant Kunj | 100 120 [10 Shivam Travels | 100000 2 Hauz Khas 80 80 | 10 Anand Travels | 85000 3 Pitampura 60 55 30 Anand Travels _ | 60000 4 Rohini 100 90 35 Anand Travels _| 100000 5 Yamuna Viha [50 60 20 Bhalla Co. 300mm | 6 [Krishna Nagar_ [70 80 30 Yadav Co. 80000 7 Vasundhara 100 110 20 Yadav Co. 100000 8 Paschim Vihar | 40 40. 20 Speed Travels mal 9 __ [Saket 120 120 10 Speed Travels 10 | Janak Puri 100 | 100 20 Kisan Tours (4) Write SQL commands for the following statements: (i) To show all records whose noofstudents is more than the capacity as in ascending order of RtNo. (ii) To show area_covered for buses covering more than 20 km, but charges less than T 80000. (iii) To show Transporter wise total no. of students travelling. (iv) Add a new record with following data: (11, ‘Moti Bagh’, 35, 32, 10, ‘Kisan Tours’, 35000) (c) Give the output of the following SQL queries: (i) Select sum(distance) from SchoolBus where Transporter = “Yadav Co.”; (ii) Select min(noofstudents) from SchoolBus; (iii) Select avg(charges) from SchoolBus where Transporter = ‘Anand Travels’; (iv) Select distinct transporter from SchoolBus; 3 (a) Differentiate between ALTER and UPDATE command 2 Sel following tables STATIONERY and CONSUMER and answer (b) and (c) parts of this question: 6 TABLE : STATIONERY S_ID DPO1 PLO2 EROS StationeryName Dot Pen Pencil Company _ | Price ABC 10 XYZ 6 TABLE : CONSUMER C_1D_| ConsumerName[aaares [51] [Topper 1c | De ROU (b) Write SQL commands for the following statements: : ee i) i i is Delhi. (i) To display the details of those Consumers whose Address is (ii) To display the details of Stationery whose Price is in the range of %8 to £15 (Both values included). (iii) To display the ConsumerName, Address from table Consumer and Company and Price from snery, with their corresponding matching 8_ID. (iv) To increase the Price of all Stationery by @ 2. (c) Give the output of the following SQL queries: () SELECT DISTINCT Addres FROM CONSUMER; Gi) SELECT Company, MAX(Price), MIN(Price), COUNT(*) ROM STATIONERY GROUP BY Company; (ii) SELECT CONSUMER. ConsumerName, STATIONERY. StationeryName, STATIONERY.Price FROM STATIONERY, CONSUMER WHERE CONSUMER.S_ID=STATIONERY.S_ID; (iv) Select StationeryName, Price*3 FROM STATIONERY; 4 (a) Define the term degree and cardinality of a relation? 2 Consider the following table FAMILY and answer (b) and (c) parts of this question: 6 | No. | Name | Mishra Chaddha Yadav FemaleMembers MaleMembers — | Income Occupation service business business 20000 mixed 14000 5000 10000 service jan product of two relation §. (a) Explain Carte Consider the following table PREPAID and answer (4) and (c) parts of this question: TABLE : PREPAID Cname Model Connection | Activation_Date Validity | Amount (Number of days valid) asian 008 aFeb2005 602030 | TarMay-2004 [368 [3020 Meetali Nokia Indicom 24-Sep-2004 890 ane Idea Hutch Ramanuj Anupam Sai Ram Deepa Samsung LG Nokia LG Sony 18-Jan-2005 10-Dec-2004 08-Mar-2005 30-Jan-2005 02-Feb-2005 Indicom Reliance Idea Airtel Karan Jayant Siemens (b) Write SQL commands for the following statements: (i) To display Cname and Amount of customers having “Samsung” model and “Hutch” connection, arranged in descending order of Amount. (ii) To display different types of connection available. (iii) To display sum of validity for each type of connection. (iv) To display Cname, connection and date of expiry. Where date of expiry is date of activation (of connection) + validity (number of days valid). (c) Give the output of the following SQL queries: (8) Select count(distinct Model) from PREPAID; (ii) Select Max(Activation_Date), Min(Activation_Date) from PREPAID; (iii) Select avg(Validity) from PREPAID where Model = ‘LG’; (iv) Select Max(Amount) from PREPAID where connection = ‘IDEA’; 6 (a) Differentiate between Primary key and Candidate key. 2 Consider the following tables BANK and CUSTOMER and answer (6) and (c) parts of this question: 6 TABLE : BANK | Acc_no | CName | Bname Dateofopen T_Transactions Karan Bank of Baroda 15000. 12-Jan-1998 10 [Puneet_[StateBank | 25000_[ 01-Feb-1997] 09 04-Apr-1999 05-Jan-1998 Eanes) TABLE : CUSTOMER (>) Write SQL commands for the following Statements; () Display data for all Customers whose trai (i) Display data for all Customers sorted by their dateofopen, (ii) To count the number of customers with amount <30000. (iv) List the minimum and maximum amount from the table BANK. (c) Give the output of the following SQL queries: (*) SELECT BANK.Cname, CUSTOMER. Thank FROM Bank, Customer WHERE Bank.Bname=Customer, Thank; (ii) SELECT COUNT(DISTINCT BNAME) FROM BANK; (iii) SELECT BNAME, SUM(AMOUNT) FROM BANK GROUP BY BNAME HAVING COUNT(*) < 3; (iv) Select MAX(Amount) from BANK where amount > 30000: nsaction is between & and 11. 7 a9 (a) Explain the concept of Union between tw Note: Answer the questions (b) and (c) Table: STORE Table : ITEM © tables, with the help of appropriate example. on the basis of the following tables STORE and ITEM. 2 () (b) Write the SQL queries (1 to 4) (1) To display IName and Price of all the items in ascending order of their Price. (2) To display SNo and SName of all Stores located in CP. (3) To display Minimum and Maximum Price of each IName from the table ITEM. (4) To display IName, Price of all items and their respective SName where they are available. Write the output of the following SQL commands (1 to 4): (1) SELECT DISTINCT IName FROM ITEM WHERE Price >= 5000; (2) SELECT Area, COUNT(*) FROM STORE GROUP BY Area; (3) SELECT COUNT(DISTINCT Area) FROM STORE; (4) SELECT IName, Price * 0.05 Discount FROM ITEM WHERE SNo IN(‘S02’,’S03’); ne Lalaw and verifier it neine a tenth table 2 ghar* WhatAge( {return Ageranyers My 8 (a)_ Explain the concept of Cartesian Product between two tables, with the help of appropriate example. 2 Answer the questions (b) and (c) on the basis of the following tables SHOPPE and Table: SHOPPE Id SName ABC Computronics All Infotech Media Tech shoppe Ge eal Geeks Tecno Soft Nehru Place Nehru Place S004 S005 | Hitech Tech Store Table : ACCESSORIES AOQ3_ | Keyboard (b) Write the SQL queries : 4 (i) To display Name and Price of all the accessories in ascending order of their Price. (ii) To display Id and SName of all Shoppe located in Nehru Place. (iii) To display Minimum and Maximum Price of each Name of ACCESSORIES. (iv) To display Name, Price ofall Accessories and their respective SName where they are available. (c) Write the output of the following SQL commands : 2 (i) SELECT DISTINCT Name FROM ACCESSORIES WHERE Price >= 5000; (ii) SELECT Area, COUNT(*) FROM SHOPPE GROUP BY Area; (iii) SELECT COUNT(DISTINCT Area) FROM SHOPPE; (iv) SELECT Name, Price*0.05 DISCOUNT FROM ACCESSORIES WHERE Id IN (‘S002’, ‘S003”);

You might also like