Class12 Mysql Rev8
Class12 Mysql Rev8
MySQL : JOINS
1. In a database there are two tables 'Customer' and 'Bill' as shown below:
(i) How many rows and how many columns will be there in the Cartesian product of these
two tables?
(ii) Which column in the 'Bill' table is the foreign key?
With reference to these tables, Write commands in SQL for (i) and (ii) and output for (iii)
below:
(i) Display the CustNo, CustAddress and corresponding SetName for each customer.
(ii) Display the Customer Details for each customer who uses a Nokia handset.
(iii) select SetNo, SetName from Handsets, customer where SetNo = SetCode and
CustAddress = 'Delhi';
3. In a database there are two tables "Company" and "Model" as shown below:
W1th reference to these tables, wnte commands m SQL for (1) and (II) and output for (iii)
below:
(i) Display the PatNo, PatName and corresponding DocName for each patient
(ii) Display the list of all patients whose OPD_Days are MWF.
(iii) select OPD_Days, Count(*) from Doctors, Patients where Patients.Department =
Doctors.Department Group by OPD_Days;
5. In a database there are two tables "Product" and "Client" as shown below :
6. In a. Database School there are two tables Member and Division as show below.
(i) Which column can be set as the PRIMARY KEY in the MAGAZINE table?
(ii) Which column in the ‘MAGAZINE’ table is the foreign key?
(iii) How many rows and columns will be there in the Cartesian product of the above 2
tables.
(iv) Write command in SQL to display the mag_code, Mag_Title and corresponding types
for all the Magazines.
(v) Write the output :
(i) Select Mag_Code, Mag_Title, Number_of_Pages, Type From MAGAZINE,MAGTYPE
Where Magazine.Mag_Category=Magtype.Mag_Category and Type=’Spiritual’;
9. In a Database Kamataka_Sangam there are two tables with the instances given below :
(i) To display Tcode, Name and Aname of all the records where the number of tickets sold
is more than 5.
(ii) To display total number of tickets booked by agent “Mr. Ayush”
(iii) To display Acode, Aname and corresponding Tcode where Aname ends with “k”.
(iv) With reference to “TicketDetails” table, which column is the primary key ? Which
column is the foreign key? Give reason(s)
11 In a database there are two tables ‘CD’ and ‘TYPE’ as shown below :
.
With reference to these tables, write commands in SQL for (i) and (ii) and output for (iii)
below:
i. To display flight number, source, airlines of those flights where fare is less than Rs.
10000.
ii. To count total no of Indian Airlines flights starting from various cities.
iii. SELECT FLIGHTS.FNO, NO_OF_FL, AIRLINES FROM FLIGHTS,FARES WHERE FLIGHTS.FNO
= FARES.FNO AND SOURCE=’DELHI’;
14 A table STUDENT has 5 rows and 3 columns. Table ACTIVITY has 4 rows and 2 columns.
. What will be the cardinality and degree of the Cartesian product of them ?
15 Consider the following table named
. “GARMENT”.
18 With reference to the above given tables, Write commands in SQL for (i) and
. (ii) and output for (iii) below:
i. To display SalespersonID, names, orderids and order amount of all salespersons.
ii. To display names ,salespersons ids and order ids of those sales persons whose
names start with ‘A’ and sales amount is between 15000 and 20000.
iii. SELECT Salesperson.SalespersonId, name, age, amount FROM Salesperson, orders
WHERE Salesperson.salespersonId= Orders.salespersonId AND AGE BETWEEN 30
AND 45;
20 With reference to the above given tables, write commands in SQL for (i) and (ii)
. and output for (iii) :
(i) To display CourseId, TeacherId, Name of Teacher, Phone Number of Teachers living in
Delhi.
(ii) To display TeacherID, Names of Teachers, Subjects of all teachers with names of
Teachers starting with ‘S’.
(iii) SELECT CourseId, Subject,Course.TeacherId,Name,PhoneNumber FROM
Faculty,Course WHERE Faculty.TeacherId = Course.TeacherId AND Fee>=5000;
21 Consider the tables given below which are linked with each other and maintains
. referential integrity:
Table: SAP
Table : Store
With reference to the above given tables, write commands in SQL for (i) and (ii) and
output for (iii) below:
i. To display the ItemCode,ItemName and ReceivedDate of all the items .
ii. To display SAPID,ItemName,ItemStorageLocation of all the items whose
Received date is after 2nd May 2016.
iii. SELECT SAPID,ItemName,STOREID FROM SAP,Store WHERE
SAP.ItemCode=Store.ItemCode AND StoreLocation = “Hauz Khas”
iv. What will be the degree and cardinality of the cartesian product formed while
combining both the above given tables ‘SAP’ and ‘Store’ ?
v. Sangeeta is not able to add a new record in the table ‘Store’ through the
following query:
Insert into store values (1206,1006,’Karol Bagh’, ‘2016/07/25’);
Identify the error if there is any