Informatics Practices

Consider the following tables TRANSPORTER and DRIVER and answer the questions that follow :

Table : TRANSPORTER

ORDERIDITEMTRANSPORTDATEDESTINATIONDRIVERID
1120TELEVISION2019-03-19MUMBAID103
1121REFRIGERATOR2019-04-12UDAIPURD101
1122TELEVISION2019-05-06MUMBAID101
1123MICROWAVE2019-05-07KANPURD103
1124FURNITURE2019-06-15KANPURD102

Table : DRIVER

DRIVERIDDRIVERNAMEDRIVERGRADEPHONE
D101Radhey ShyamA981234567
D102Jagat Singh981017897
D103Timsy YadavB
D104Zoravar SinghA981107887

(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