Engineering Questions with Answers - Multiple Choice Questions

Database MCQ – Querying database part-1 DDL

1 - Question

Which is the main relation which is used in the university database which is referenced by all other relation of the university?
a) Teaches
b) Course
c) Department
d) Section

View Answer

Answer: c
Explanation: Department is the only relation which forms the main part of the university database.




2 - Question

The department relation has the an entry budget whose type has to be replaced by
a) Varchar (20)
b) Varchar2 (20)
c) Numeric (12,2)
d) Numeric

View Answer

Answer: c
Explanation: Department is the only relation which forms the main part of the university database.




3 - Question

In the course relation, the title field should throw an error in case of any missing title. The command to be added in title is
a) Unique
b) Not null
c) 0
d) Null

View Answer

Answer: b
Explanation: By specifying not null the value cannot be left blank.




4 - Question

In the above DDL command the foreign key entries are got by using the keyword
a) References
b) Key reference
c) Relating
d) None of the mentioned

View Answer

Answer: a
Explanation: References (table_name) give the prior table name for the entry.




5 - Question

Identify the error in the section relation
a) No error
b) Year numeric (4,0)
c) Building varchar (15)
d) Sec_id varchar (8)

View Answer

Answer: a
Explanation: The building and the sec_id have varchar values and year is of numeric type. So no such errors are found in the relation.




6 - Question

The following entry is given in to the instructor relation .

(100202,Drake,Biology,30000)
Identify the output of the query given
a) Row(s) inserted
b) Error in ID of insert
c) Error in Name of insert
d) Error in Salary of the insert

View Answer

Answer: b
Explanation: The varchar(5) value cannot hold the entry 100202.




7 - Question

Which of the following can be used as a primary key entry of the instructor relation.
a) DEPT_NAME
b) NAME
c) ID
d) All of the mentioned

View Answer

Answer: c
Explanation: The value ID can only be primary key unlike dept_name which is used as a foreign key.




8 - Question

In the section relation which of the following is used as a foreign key?
a) Course_id
b) Course_id,sec_id
c) Room_number
d) Course_id,sec_id,room_number

View Answer

Answer: a
Explanation: Course_id is the only field which is present in the course relation.




9 - Question

In order to include an attribute Name to the teaches relation which of the following command is used?
a) Alter table teaches include Name;
b) Alter table teaches add Name;
c) Alter table teaches add Name varchar;
d) Alter table teaches add Name varchar(20);

View Answer

Answer: d
Explanation: The form of the alter table command is
alter table r add AD;
where r is the name of an existing relation, A is the name of the attribute to be added, and D is the type of the added attribute.




10 - Question

To replace the relation section with some other relation the initial step to be carried out is
a) Delete section;
b) Drop section;
c) Delete from section;
d) Replace section new_table ;

View Answer

Answer: b
Explanation: Droping the table drops all the references to that table.

Get weekly updates about new MCQs and other posts by joining 18000+ community of active learners