Which aggregate function is used to count the number of rows in an SQL query?
COUNT()
COUNT(DISTINCT)
COUNT(UNIQUE)
COUNT(*)
Difficulty Level: 1
Positive Marks: 1.00
Negative Marks: 0.33
Consider the two relations below in which primary keys are underlined. Identify all possible foreign key(s) from the options based on the two relations.

R(A, B, C)

S(B,C)

A
C
A,C
A,B,C
Difficulty Level: 1
Positive Marks: 1.00
Negative Marks: 0.33
Identify the valid datatype(s), which can be used in SQL to define the type of data?
varchar
real
float
All of the above
Difficulty Level: 1
Positive Marks: 1.00
Negative Marks: 0.33
A database indexes
Increases database size
Decreases database size
Doesn’t affect database size
Impacts database size differently in different cases
Difficulty Level: 1
Positive Marks: 1.00
Negative Marks: 0.33
In SQL, views
contains data not stored in the database tables
are computed using a SQL query
takes up more disk space whenever more data is added to the database
are a way to improve the read time of a table in a database
Difficulty Level: 1
Positive Marks: 1.00
Negative Marks: 0.33
Which of the following statements is/are CORRECT?

S1: In SQL, the UNIQUE constraint ensures that all values in a column are different.

S2: In SQL, CHECK constraint ensures whether the value in columns fulfils the specified condition or not.

Only S1
Only S2
Both S1 and S2
Neither S1 nor S2
Difficulty Level: 1
Positive Marks: 2.00
Negative Marks: 0.66
Which of the following statements is/are INCORRECT about DELETE and TRUNCATE commands in SQL?

S1: DELETE command is used to delete a specific row from the table whereas the TRUNCATE command is used to remove all rows from the table.

S2: We can use the DELETE command with WHERE clause but cannot use the TRUNCATE command with it.

Only S1
Only S2
Both S1 and S2
Neither S1 nor S2
Difficulty Level: 1
Positive Marks: 2.00
Negative Marks: 0.66
Which of the following statements is/are CORRECT in SQL?

S1: In SQL, a table can have many foreign keys.

S1: In SQL, a table can have many primary keys.

Only S1
Only S2
Both S1 and S2
Neither S1 nor S2
Difficulty Level: 1
Positive Marks: 2.00
Negative Marks: 0.66
Consider the following three SQL queries (Assume the data in the people table):

(a)Select Name from people where Age > 31;

(b)Select Name from people where Height > 190;

(c)Select Name from people where (Age > 31) or (Height > 190);

If the SQL queries (a) and (b) above, return 20 rows and 17 rows in the result set respectively, then what is one possible number of rows returned by the SQL query (c) ?

3
17
20
31
Difficulty Level: 1
Positive Marks: 2.00
Negative Marks: 0.66
All rows correspond to students whose rollnum’s are between 20 and 30.

(i) SELECT * FROM Student WHERE rollnum are between 20 and 30;

(ii) SELECT * FROM Student WHERE rollnum IN(20,30)

Only (i)
Only (ii)
Both (i) and (ii)
None
Difficulty Level: 1
Positive Marks: 2.00
Negative Marks: 0.66
Column X of a relation has the following list of values in the six rows of the table: 3, NULL, 2, 3, NULL, 5. The correct value of AVG(DISTINCT X) is _______ (You may compute your answer to 2 decimal places)
3.33
Difficulty Level: 1
Positive Marks: 2.00
Negative Marks: 0.00
SELECT Pname FROM TABLE Project WHERE dnum=4;
SELECT Pname FROM Project FOR dnum=4;
SELECT Pname FROM TABLE Project FOR dnum=4;
SELECT Pname FROM Project WHERE dnum=4;
Difficulty Level: 1
Positive Marks: 2.00
Negative Marks: 0.66
Refer the following table ‘employee’ and identify the CORRECT “CREATE TABLE” statement.

  1. CREATE TABLE employee

(

id int NOT NOT NULL,

lastname varchar(255) NOT NULL,

firstname varchar(255),

age int,

PRIMARY KEY(ID)

);

  1. CREATE TABLE employee

(

id int NOT NULL,

lastname varchar(255) NOT NULL,

firstname varchar(255),

age int,

PRIMARY KEY(ID, lastname)

);

  1. CREATE TABLE employee

(

id int,

lastname varchar(255) NOT NULL,

firstname varchar(255),

age int,

PRIMARY KEY(ID, lastname)

);

  1. CREATE TABLE employee

(

id int NOT NULL,

lastname varchar(255) NOT NULL,

firstname varchar(255),

age int,

PRIMARY KEY(lastname)

);

Difficulty Level: 1
Positive Marks: 2.00
Negative Marks: 0.66
Consider the relation schema class(class_name, age). Identify the query to find the names and average age of all classes, whose average age is greater than 10.
SELECT class_name, age FROM class GROUP BY class_name HAVING AVG(age)>10;
SELECT class_name, age FROM class HAVING AVG(age)>10 GROUP BY class_name;
SELECT class_name, AVG(age) FROM class GROUP BY class_name HAVING AVG(age)>10;
SELECT class_name, AVG(age) FROM class HAVING AVG(age)>10 GROUP BY class_name;
Difficulty Level: 1
Positive Marks: 2.00
Negative Marks: 0.66
Consider the following Employee table:

SELECT Branch, SUM(Salary)

FROM Employee

GROUP BY City;

SELECT Branch, SUM(Salary)

FROM Employee

GROUP BY Branch;

SELECT SUM(Salary)

FROM Employee

GROUP BY Branch;

SELECT Branch, SUM(Salary)

FROM Employee;

Difficulty Level: 1
Positive Marks: 2.00
Negative Marks: 0.66