Check sibling questions
Computer Science - Class 12
Chapter 8 - Database Concepts

Consider the following SQL command: CREATE TABLE MEMBER (MEM_ID INTEGER NOT NULL, NAME CHAR(15) NOT NULL, DATE_JOIN DATE, SEX CHAR(1) CHECK (SEX= ‘M’ OR SEX = ‘F’), ADDRESS VARCHAR(100) NOT NULL, PH_NO CHAR(15), PRIMARY KEY (MEM_NO), INDEX MEM_IDX (DATE_JOIN) );

Now answer the following questions:

NOT NULL ensures that

(A) Column cannot have blank value

(B) Column will not accept any value

(C) Column has a fixed value

(D) Column has a unique value

 

Answer:

By default, all columns in a table can hold null value ie., there is no particular value assigned for that column. The NOT NULL constraint ensures that a given column of a table is never assigned the null value.

So, the correct answer is (A)

 

Question 1 (ii)

By default format of date entered is

(A) DD-MM-YY

(B) MM-DD-YY

(C) YYYY-MM-DD

(D) DD-MM-YYYY

 

Answer:

The default format of date in SQL is YYYY-MM-DD.

Checking the options

  • (A) DD-MM-YY - It is not the default format of date in SQL.
  • (B) MM-DD-YY - It is not the default format of date in SQL.   
  • (C) YYYY-MM-DD - It is the default format of date in SQL.
  • (D) DD-MM-YYYY - It is not the default format of date in SQL.

So, the correct answer is (C)

 

Question 1 (iii)

The ______ constraint ensures that the value entered specifies a certain condition.

(A) NOT NULL

(B) NULL

(C) CHECK

(D) All of these

 

Answer:

Checking the options

  • (A) NOT NULL - Enforces a column to not accept null values.
  • (B) NULL - The NULL keyword is used to specify that a column can accept null values.
  • (C) CHECK - Limits the values that can be entered in certain columns based on a condition.
  • (D) All of these 

From the above explanation, it is clear that the CHECK constraint ensures that the value entered specifies a certain condition.

So, the correct answer is (C)

 

Question 1 (iv)

PRIMAY KEY in above example ensures that

(A) MEM_ID is entered primarily

(B) MEM_ID will hold a uniquely identified value

(C) MEM_ID will not remain blank

(D) All of these

 

Answer:

The primary key of a table uniquely identifies each record in the table. The value of the primary key should be unique and not null .

Checking the options

  • (A) MEM_ID is entered primarily - True for a primary key.   
  • (B) MEM_ID will hold a uniquely identified value - True for a primary key.  
  • (C) MEM_ID will not remain blank - True for a primary key.
  • (D) All of these 

Primary key ensures all the conditions given in the options.

So, the correct option is (D)

 

Question 1 (v)

The INDEX command in above example will

(A) Create an index on field DATE_JOIN

(B) Create an index namely MEM_IDX

(C) Both (a) and (b)

(D) None of the above

 

Answer:

The index command in MySQL creates indexes. They are used to retrieve data from the database more quickly than otherwise. The syntax to create an index is as follows:

CREATE INDEX index_name

ON table_name ( column1 , column2 , ...);  

The command INDEX MEM_IDX (DATE_JOIN) creates an index named MEM_IDX on the field DATE_JOIN.

Checking the options

  • (A) Create an index on field DATE_JOIN 
  • (B) Create an index namely MEM_IDX  
  • (C) Both (a) and (b)  
  • (D) None of the above 

Both option (A) and (B) are correct.

So, the answer is (C)

Get Real time Doubt solving from 8pm to 12 am!


Transcript

Consider the following SQL command: CREATE TABLE MEMBER (MEM_ID INTEGER NOT NULL, NAME CHAR(15) NOT NULL, DATE_JOIN DATE, SEX CHAR(1) CHECK (SEX= ‘M’ OR SEX = ‘F’), ADDRESS VARCHAR(100) NOT NULL, PH_NO CHAR(15), PRIMARY KEY (MEM_NO), INDEX MEM_IDX (DATE_JOIN) ); Now answer the following questions: NOT NULL ensures that (A) Column cannot have blank value (B) Column will not accept any value (C) Column has a fixed value (D) Column has a unique value Answer: By default, all columns in a table can hold null value ie., there is no particular value assigned for that column. The NOT NULL constraint ensures that a given column of a table is never assigned the null value. So, the correct answer is (A) Question 1 (ii) By default format of date entered is (A) DD-MM-YY (B) MM-DD-YY (C) YYYY-MM-DD (D) DD-MM-YYYY Answer: The default format of date in SQL is YYYY-MM-DD. Checking the options (A) DD-MM-YY - It is not the default format of date in SQL. (B) MM-DD-YY - It is not the default format of date in SQL. (C) YYYY-MM-DD - It is the default format of date in SQL. (D) DD-MM-YYYY - It is not the default format of date in SQL. So, the correct answer is (C) Question 1 (iii) The ______ constraint ensures that the value entered specifies a certain condition. (A) NOT NULL (B) NULL (C) CHECK (D) All of these Answer: Checking the options (A) NOT NULL - Enforces a column to not accept null values. (B) NULL - The NULL keyword is used to specify that a column can accept null values. (C) CHECK - Limits the values that can be entered in certain columns based on a condition. (D) All of these From the above explanation, it is clear that the CHECK constraint ensures that the value entered specifies a certain condition. So, the correct answer is (C) Question 1 (iv) PRIMAY KEY in above example ensures that (A) MEM_ID is entered primarily (B) MEM_ID will hold a uniquely identified value (C) MEM_ID will not remain blank (D) All of these Answer: The primary key of a table uniquely identifies each record in the table. The value of the primary key should be unique and not null. Checking the options (A) MEM_ID is entered primarily - True for a primary key. (B) MEM_ID will hold a uniquely identified value - True for a primary key. (C) MEM_ID will not remain blank - True for a primary key. (D) All of these Primary key ensures all the conditions given in the options. So, the correct option is (D) Question 1 (v) The INDEX command in above example will (A) Create an index on field DATE_JOIN (B) Create an index namely MEM_IDX (C) Both (a) and (b) (D) None of the above Answer: The index command in MySQL creates indexes. They are used to retrieve data from the database more quickly than otherwise. The syntax to create an index is as follows: CREATE INDEX index_name ON table_name (column1, column2, ...); The command INDEX MEM_IDX (DATE_JOIN) creates an index named MEM_IDX on the field DATE_JOIN. Checking the options (A) Create an index on field DATE_JOIN (B) Create an index namely MEM_IDX (C) Both (a) and (b) (D) None of the above Both option (A) and (B) are correct. So, the answer is (C)

Davneet Singh's photo - Co-founder, Teachoo

Made by

Davneet Singh

Davneet Singh has done his B.Tech from Indian Institute of Technology, Kanpur. He has been teaching from the past 12 years. He provides courses for Maths, Science, Social Science, Physics, Chemistry, Computer Science at Teachoo.