Informatics Practices
Consider the following tables TRANSPORTER and DRIVER and answer the questions that follow :
Table : TRANSPORTER
| ORDERID | ITEM | TRANSPORTDATE | DESTINATION | DRIVERID |
|---|---|---|---|---|
| 1120 | TELEVISION | 2019-03-19 | MUMBAI | D103 |
| 1121 | REFRIGERATOR | 2019-04-12 | UDAIPUR | D101 |
| 1122 | TELEVISION | 2019-05-06 | MUMBAI | D101 |
| 1123 | MICROWAVE | 2019-05-07 | KANPUR | D103 |
| 1124 | FURNITURE | 2019-06-15 | KANPUR | D102 |
Table : DRIVER
| DRIVERID | DRIVERNAME | DRIVERGRADE | PHONE |
|---|---|---|---|
| D101 | Radhey Shyam | A | 981234567 |
| D102 | Jagat Singh | 981017897 | |
| D103 | Timsy Yadav | B | |
| D104 | Zoravar Singh | A | 981107887 |
(i) Can the column 'PHONE' be set as the primary key of the table DRIVER ? Give reason(s).
Or
Identify the Primary key in the table 'DRIVER'. Give reason(s) for your choice.
(ii) In the PHONE column of "DRIVER" table, each phone number is taking same number of bytes (being padded with spaces to specified length) irrespective of the number of characters actually stored in that column. Which data type has been used for PHONE column ?
Or
Identify data type and size to be used for column DRIVERID.
SQL Joins & Grouping
4 Likes
Answer
(i) No, the column 'PHONE' cannot be set as the primary key of the table "DRIVER" because it contains NULL values and primary keys must have unique, non-NULL values for each row.
Or
The primary key in the 'DRIVER' table is 'DRIVERID' because it uniquely identifies each driver, and it does not allow null values, ensuring that each row can be uniquely identified.
(ii) The data type used for the "PHONE" column is "CHAR", which is a fixed-length data type. "CHAR" pads the values with spaces to ensure each value takes up the same amount of storage space.
Or
The data type and size for the column "DRIVERID" would be "VARCHAR(4)" to accommodate the alphanumeric values of length 4.
Answered By
1 Like
Related Questions
Write a SQL query to display all the divnos in Member table but not in the Division table.
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 Write a SQL query to display all the divnos in Division table but not in the Member table.
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 Write a SQL query to display common divnos from both the tables.
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 With reference to the below given tables, write commands in SQL for (i) to (iii) :
Table : TRANSPORTER
ORDERID ITEM TRANSPORTDATE DESTINATION DRIVERID 1120 TELEVISION 2019-03-19 MUMBAI D103 1121 REFRIGERATOR 2019-04-12 UDAIPUR D101 1122 TELEVISION 2019-05-06 MUMBAI D101 1123 MICROWAVE 2019-05-07 KANPUR D103 1124 FURNITURE 2019-06-15 KANPUR D102 Table : DRIVER
DRIVERID DRIVERNAME DRIVERGRADE PHONE D101 Radhey Shyam A 981234567 D102 Jagat Singh 981017897 D103 Timsy Yadav B D104 Zoravar Singh A 981107887 (i) To display OrderId, Item being transported, DriverId and names of Drivers for all the orders that are being transported by drivers with 'A' grade.
(ii) To display DriverId, Names of drivers and Travel dates for drivers who are travelling after 1st March, 2019.
Or
How many rows will be there in Cartesian product of the two tables in consideration here ?
(iii) To display Orderld, Driverld and names of Drivers for all the orders that are transporting TELEVISION.