Informatics Practices
In a Database School there are two tables Member and Division as shown below.
Table : Member
| EmpId | Name | Pay | Divno |
|---|---|---|---|
| 1001 | Shankhya | 34000 | 10 |
| 1003 | Ridhima | 32000 | 50 |
| 1002 | Sunish | 45000 | 20 |
Table : Division
| Divno | Divname | Location |
|---|---|---|
| 10 | Media | TF02 |
| 20 | Dance | FF02 |
| 30 | Production | SF01 |
(i) Identify the foreign key in the table Member.
(ii) What output, you will get, when an equi-join query is executed to get the NAME from Member Table and corresponding from Division table ?
SQL Joins & Grouping
3 Likes
Answer
(i) The foreign key in the "Member" table is the "Divno" column, which references the "Divno" column in the "Division" table.
(ii)
SELECT m.Name, d.Divname
FROM Member m JOIN Division d ON m.Divno = d.Divno;
Output
+----------+---------+
| Name | Divname |
+----------+---------+
| SHANKHYA | Media |
| SUNISH | Dance |
+----------+---------+
Answered By
1 Like
Related Questions
A table "TRAINS" in a database has degree 3 and cardinality 8. What is the number of rows and columns in it ?
In a database there are two tables "Product" and "Client" as shown below :
Table : Product
P_ID ProductName Manufacture Price P001 Moisturiser XYZ 40 P002 Sanitizer LAC 35 P003 Bath Soap COP 25 P004 Shampoo TAP 95 P005 Lens Solution COP 350 Table : Client
C_ID ClientName City P_ID 01 Dreamz Disney New Delhi P002 05 Life Line Inc Mumbai P005 12 98.4 New Delhi P001 15 Appolo Banglore P003 Write the commands in SQL queries for the following :
(i) To display the details of Product whose Price is in the range of 40 and 120 (Both values included).
(ii) To display the ClientName, City from table Client and ProductName and Price from table Product, with their corresponding matching P_ID.
(iii) To increase the Price of all the Products by 20.
Consider following tables to answer below question :
Salesman (salesman_id, name, city, commission ) and Customer (customer_id, cust_name, city, grade, salesman_id )Write an SQL query to display all salesmen and customer located in Chennai.
Consider following tables to answer below question :
Salesman (salesman_id, name, city, commission ) and Customer (customer_id, cust_name, city, grade, salesman_id )Write an SQL query to display distinct salesman and their cities.