Page 184 - Informatics_Practices_Fliipbook_Class12
P. 184
7. Which text function is used to convert a string to uppercase?
a. UCASE() b. LCASE() c. MID() d. LENGTH()
8. Which date function yields the current date and time?
a. NOW() b. DATE() c. MONTH() d. YEAR()
9. Which text function extracts a portion of a string based on the specified starting position and length?
a. MID() b. LENGTH() c. INSTR() d. LTRIM()
10. Which math function yields the remainder when x is divided by y?
a. POWER(x, y) b. ROUND(x, y) c. MOD(x, y) d. UCASE(x)
B. State whether the following statements are True or False:
1. A DDL command can be used to modify the constraints of an attribute in a table. __________
2. A DML command can only be used to retrieve data. __________
3. A string longer than the defined maximum length will result in the truncation of extra trailing
characters. __________
4. A VARCHAR data type can have a default value. __________
5. A table may have more than one attribute as a primary key. __________
6. SELECT is a DDL command. __________
7. UNIQUE constraint can be applied to multiple columns in a table. __________
C. Fill in the blanks.
1. Data Manipulation language (DML) includes statements that modify the __________ of a database.
2. The data type indicates the __________ of values for an attribute.
3. If the length of a field of type CHAR is not specified, the default length is __________.
4. Each SQL statement terminates with a __________.
5. __________ command is used to delete a table from a database.
6. The __________ command is used to add, delete, or modify columns in an existing table.
D. Answer the following questions:
1. Observe the following table Transaction and write the names of the most appropriate columns, which can be considered as
(i) candidate keys and (ii) primary key: (Based on CBSE, 2015)
Transaction
ItemCode Item Qty Price Transaction Date
1001 Plastic Folder 14" 100 3400 2014-12-14
1004 Pen Stand Standard 200 4500 2015-01-31
1005 Stapler Mini 250 1200 2015-02-28
1009 Punching Machine Small 200 1400 2015-03-12
1003 Stapler Big 100 1500 2015-02-02
Ans. We see from the table that there are two occurrences of Qty, obviously Qty does not qualify to be a candidate key.
We see from the table that each item has a unique price. However, this is not a permanent property of the table. In the
future, two different items may have the same price. Therefore, Price does not qualify to be a candidate key.
It appears from the table that each item is unique, so it qualifies to be a candidate key.
As there is a unique ItemCode for each item, ItemCode also identifies a tuple uniquely. Therefore, ItemCode also seems to
qualify to be a candidate key.
Subtle thing to note is that although there is a unique transaction for each item. However, as more transactions get
included, it is likely that there will be multiple transactions for the same item. So, Item alone does not qualify to be a
candidate key. Instead, a combination of Item and TransactionDate will form a candidate key.
170 Touchpad Informatics Practices-XII

