0% found this document useful (0 votes)
83 views

DB Draft

The document contains 10 multiple choice questions about SQL concepts such as joins, aggregation, data definition and manipulation languages, and integrity constraints. Specifically, it tests knowledge of join types that preserve or discard non-matched tuples, equivalence between inner join syntax and using natural join, the purpose of outer joins, and which SQL statements are considered DDL, DML, or queries. It also covers data types, null values, integrity constraints like primary and foreign keys, and specialization in entity-relationship modeling.

Uploaded by

Mahmoud Elmahdy
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
83 views

DB Draft

The document contains 10 multiple choice questions about SQL concepts such as joins, aggregation, data definition and manipulation languages, and integrity constraints. Specifically, it tests knowledge of join types that preserve or discard non-matched tuples, equivalence between inner join syntax and using natural join, the purpose of outer joins, and which SQL statements are considered DDL, DML, or queries. It also covers data types, null values, integrity constraints like primary and foreign keys, and specialization in entity-relationship modeling.

Uploaded by

Mahmoud Elmahdy
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 10

1. The____condition allows a general predicate over the relations being joined.

a) On
b) Using
c) Set
d) Where
Answer: a
2. Which of the join operations do not preserve non matched tuples?
a) Left outer join
b) Right outer join
c) Inner join
d) Natural join
Answer: c
Explanation: INNER JOIN: Returns all rows when there is at least one match in BOTH tables.
3.
SELECT *
FROM student JOIN takes USING (ID);
The above query is equivalent to
a)
SELECT *
FROM student INNER JOIN takes USING (ID);
b)
SELECT *
FROM student OUTER JOIN takes USING (ID);
c)
SELECT *
FROM student LEFT OUTER JOIN takes USING (ID);
d) None of the mentioned
Answer: a
4. What type of join is needed when you wish to include rows that do not have matching values?
a) Equi-join
b) Natural join
c) Outer join
d) All of the mentioned
Answer: c
5. How many tables may be included with a join?
a) One
b) Two
c) Three
d) All of the mentioned
Answer: d
6. Which are the join types in join condition:
a) Cross join
b) Natural join
c) Join with USING clause
d) All of the mentioned
Answer: d
7. How many join types in join condition:
a) 2
b) 3
c) 4
d) 5
Answer: d
Explanation: Types are inner join, left outer join, right outer join, full join, cross join.
8. Which join refers to join records from the right table that have no matching key in the left
table are include in the result set:
a) Left outer join
b) Right outer join
c) Full outer join
d) Half outer join
Answer: b
Explanation: RIGHT OUTER JOIN: Return all rows from the right table and the matched rows
from the left table.
9. The operation which is not considered a basic operation of relational algebra is
a) Join
b) Selection
c) Union
d) Cross product
Answer: a
10. In SQL the statement select * from R, S is equivalent to
a) Select * from R natural join S
b) Select * from R cross join S
c) Select * from R union join S
d) Select * from R inner join S
Answer: b
2. Here which of the following displays the unique values of the column?
SELECT ________ dept_name
FROM instructor;
a) All
b) From
c) Distinct
d) Name
Answer: c
3. The ______ clause allows us to select only those rows in the result relation of the ____ clause
that satisfy a specified predicate.
a) Where, from
b) From, select
c) Select, from
d) From, where
Answer: a
4. The query given below will not give an error. Which one of the following has to be replaced to
get the desired output?
SELECT ID, name, dept name, salary * 1.1
WHERE instructor;
a) Salary*1.1
b) ID
c) Where
d) Instructor
Answer: c
5. The ________ clause is used to list the attributes desired in the result of a query.
a) Where
b) Select
c) From
d) Distinct
Answer: b
6. This Query can be replaced by which one of the following?
SELECT name, course_id
FROM instructor, teaches
WHERE instructor_ID= teaches_ID;
a) Select name,course_id from teaches,instructor where instructor_id=course_id;
b) Select name, course_id from instructor natural join teaches;
c) Select name, course_id from instructor;
d) Select course_id from instructor join teaches;
Answer: b
7.
SELECT * FROM employee WHERE salary>10000 AND dept_id=101;
Which of the following fields are displayed as output?
a) Salary, dept_id
b) Employee
c) Salary
d) All the field of employee relation
Answer: d
1.
SELECT name ____ instructor name, course id
FROM instructor, teaches
WHERE instructor.ID= teaches.ID;
Which keyword must be used here to rename the field name?
a) From
b) Rename
c) As
d) Join
View Answer

Answer: c
2.
SELECT * FROM employee WHERE dept_name="Comp Sci";
In the SQL given above there is an error . Identify the error.
a) Dept_name
b) Employee
c) “Comp Sci”
d) From
Answer: c
3.
SELECT emp_name
FROM department
WHERE dept_name LIKE ’ _____ Computer Science’;
Which one of the following has to be added into the blank to select the dept_name which has
Computer Science as its ending string?
a) %
b) _
c) ||
d) $
Answer: a
4. ’_ _ _ ’ matches any string of ______ three characters. ’_ _ _ %’ matches any string of at
______ three characters.
a) Atleast, Exactly
b) Exactly, Atleast
c) Atleast, All
d) All, Exactly
Answer: b
5.
SELECT name
FROM instructor
WHERE dept name = ’Physics’
ORDER BY name;
By default, the order by clause lists items in ______ order.
a) Descending
b) Any
c) Same
d) Ascending
Answer: d
6.
SELECT *
FROM instructor
ORDER BY salary ____, name ___;
To display the salary from greater to smaller and name in ascending order which of the following
options should be used?
a) Ascending, Descending
b) Asc, Desc
c) Desc, Asc
d) Descending, Ascending
Answer: c
7.
SELECT name
FROM instructor
WHERE salary <= 100000 AND salary >= 90000;
This query can be replaced by which of the following ?
a)
SELECT name
FROM instructor
WHERE salary BETWEEN 90000 AND 100000;
b)
SELECT name
FROM employee
WHERE salary <= 90000 AND salary>=100000;
c)
SELECT name
FROM employee
WHERE salary BETWEEN 90000 AND 100000;
d)
SELECT name
FROM instructor
WHERE salary BETWEEN 100000 AND 90000;
Answer: a
8.
SELECT instructor.*
FROM instructor, teaches
WHERE instructor.ID= teaches.ID;
This query does which of the following operation?
a) All attributes of instructor and teaches are selected
b) All attributes of instructor are selected on the given condition
c) All attributes of teaches are selected on given condition
d) Only the some attributes from instructed and teaches are selected
Answer: b
9. In SQL the spaces at the end of the string are removed by _______ function.
a) Upper
b) String
c) Trim
d) Lower
Answer: c

10. _____ operator is used for appending two strings.


a) &
b) %
c) ||
d) _
Answer: c
1. Which one of the following is used to define the structure of the relation, deleting relations
and relating schemas?
a) DML(Data Manipulation Langauge)
b) DDL(Data Definition Langauge)
c) Query
d) Relational Schema
Answer: b
2. Which one of the following provides the ability to query information from the database and to
insert tuples into, delete tuples from, and modify tuples in the database?
a) DML(Data Manipulation Langauge)
b) DDL(Data Definition Langauge)
c) Query
d) Relational Schema
Answer: a
3.
CREATE TABLE employee (name VARCHAR, id INTEGER)
What type of statement is this?
a) DML
b) DDL
c) View
d) Integrity constraint
Answer: b
4.
SELECT * FROM employee
What type of statement is this?
a) DML
b) DDL
c) View
d) Integrity constraint
Answer: a
Explanation: Select operation just shows the required fields of the relation. So it forms a DML.
5. The basic data type char(n) is a _____ length character string and varchar(n) is _____ length
character.
a) Fixed, equal
b) Equal, variable
c) Fixed, variable
d) Variable, equal
Answer: c
6. An attribute A of datatype varchar(20) has the value “Avi”. The attribute B of datatype
char(20) has value ”Reed”. Here attribute A has ____ spaces and attribute B has ____ spaces.
a) 3, 20
b) 20, 4
c) 20, 20
d) 3, 4
Answer: a
7. To remove a relation from an SQL database, we use the ______ command.
a) Delete
b) Purge
c) Remove
d) Drop table
Answer: d
8.
DELETE FROM r; //r - relation
This command performs which of the following action?
a) Remove relation
b) Clear relation entries
c) Delete fields
d) Delete rows
Answer: b
9.
INSERT INTO instructor VALUES (10211, ’Smith’, ’Biology’, 66000);
What type of statement is this?
a) Query
b) DML
c) Relational
d) DDL
Answer: b
10. Updates that violate __________ are disallowed.
a) Integrity constraints
b) Transaction control
c) Authorization
d) DDL constraints
Answer: a
1. A _____ indicates an absent value that may exist but be unknown or that may not exist at all.
a) Empty tuple
b) New value
c) Null value
d) Old value
Answer: c
2. If the attribute phone number is included in the relation all the values need not be entered into
the phone number column. This type of entry is given as
a) 0
b) –
c) Null
d) Empty space
Answer: c
1. To include integrity constraint in an existing relation use :
a) Create table
b) Modify table
c) Alter table
d) Drop table
Answer: c
2. Which of the following is not an integrity constraint?
a) Not null
b) Positive
c) Unique
d) Check ‘predicate’
Answer: b

3. CREATE TABLE Employee(Emp_id NUMERIC NOT NULL, Name VARCHAR(20) ,


dept_name VARCHAR(20), Salary NUMERIC UNIQUE(Emp_id,Name));
INSERT INTO Employee VALUES(1002, Ross, CSE, 10000)
INSERT INTO Employee VALUES(1006,Ted,Finance, );
INSERT INTO Employee VALUES(1002,Rita,Sales,20000);
What will be the result of the query?
a) All statements executed
b) Error in create statement
c) Error in insert into Employee values(1006,Ted,Finance, );
d) Error in insert into Employee values(1008,Ross,Sales,20000);

4. Inorder to ensure that the value of budget is non-negative which of the following should be
used?
a) Check(budget>0)
b) Check(budget<0)
c) Alter(budget>0)
d) Alter(budget<0)
Answer: a
Explanation: A common use of the check clause is to ensure that attribute values satisfy specified
conditions, in effect creating a powerful type system.

5. Foreign key is the one in which the ________ of one relation is referenced in another relation.
a) Foreign key
b) Primary key
c) References
d) Check constraint
Answer: b

6.

CREATE TABLE course


(...
FOREIGN KEY (dept name) REFERENCES department
. . . );
Which of the following is used to delete the entries in the referenced table when the tuple is
deleted in course table?
a) Delete
b) Delete cascade
c) Set null
d) All of the mentioned
Answer: b
1. The entity set person is classified as student and employee. This process is called _________
a) Generalization
b) Specialization
c) Inheritance
d) Constraint generalization
Answer: b
2. Which relationship is used to represent a specialization entity?
a) ISA
b) AIS
c) ONIS
d) WHOIS
3. The refinement from an initial entity set into successive levels of entity subgroupings
represents a ________ design process in which distinctions are made explicit.
a) Hierarchy
b) Bottom-up
c) Top-down
d) Radical
Answer: c
4. There are similarities between the instructor entity set and the secretary entity set in the sense
that they have several attributes that are conceptually the same across the two entity sets: namely,
the identifier, name, and salary attributes. This process is called
a) Commonality
b) Specialization
c) Generalization
d) Similarity
Answer: c
6. A _____________ constraint requires that an entity belong to no more than one lower-level
entity set.
a) Disjointness
b) Uniqueness
c) Special
d) Relational
Answer: a
7. Consider the employee work-team example, and assume that certain employees participate in
more than one work team. A given employee may therefore appear in more than one of the team
entity sets that are lower level entity sets of employee. Thus, the generalization is
_____________
a) Overlapping
b) Disjointness
c) Uniqueness
d) Relational
Answer: a
8. The completeness constraint may be one of the following: Total generalization or
specialization, Partial generalization or specialization. Which is the default?
a) Total
b) Partial
c) Should be specified
d) Cannot be determined
Answer: b
9. Functional dependencies are a generalization of
a) Key dependencies
b) Relation dependencies
c) Database dependencies
d) None of the mentioned
Answer: a
10. Which of the following is another name for a weak entity?
a) Child
b) Owner
c) Dominant
d) All of the mentioned
Answer: a

You might also like