Nptel Assignment
Nptel Assignment
Question 1
Which of the following statements is (are) incorrect?
Answer: a), c)
Explanation: Logical level: describes the data stored in the database and the relationships among
them.
Physical level: focuses on how data is stored physically.
View level: provides abstraction for users, hiding the complexities of the database structure.
1
Question 2
Consider the following SQL statement(s):
S1:
S2:
Answer: b)
Explanation: Based on the syntax of the language, option (b) is the correct answer. DDL(Data
Definition Language) includes CREATE, DROP, ALTER, TRUNCATE, RENAME; DML(Data Ma-
nipulation Language) includes INSERT, UPDATE, DELETE. For more details, refer to Module 2.
2
Question 3
Identify the valid primary key for the relation event registration from the given instance.
event registration
participant id event id registration date status
1001 E001 2024-01-10 Confirmed
1002 E002 2024-01-11 Pending
1003 E001 2024-01-10 Confirmed
1001 E003 2024-01-12 Confirmed
1004 E002 2024-01-14 Pending
a) participant id
Answer: c)
Explanation: A composite primary key consists of two or more attributes that together uniquely iden-
tify a record in the table. Option c) is the correct answer because the combination of participant id
and event id ensures uniqueness for each registration. Other options do not guarantee uniqueness
across all rows.
3
Question 4
Identify the correct statement/s.
Answer: c)
Explanation: (101, John) is an instance of the schema Employee(empID, empName). A relation
schema defines the structure of the data, and an instance contains actual data values fitting the schema.
4
Question 5
Consider a relation CityDetails(CityName, Population, CountryName) where the superkeys are as
follows: {CityName}, {CityName, Population}, {CityName, CountryName}, {CityName, Population,
CountryName}.
b) {CityName, Population}
c) {CityName}
d) {CityName, CountryName}
Answer: c)
Explanation: Minimal superkeys are candidate keys. Here, CityName alone is a superkey, so any
superset of CityName will also be a superkey. But only CityName can be a candidate key.
Hence, (c) is the correct option.
5
Question 6
Consider the following relations:
Employee(eid, ename, salary)
Department(did, eid)
a) RA1 = RA2
b) RA1 ⊂ RA2
c) RA2 ⊆ RA1
d) RA1 ⊆ RA2
Answer: d)
Explanation: A natural join only includes tuples where the eid matches, whereas a Cartesian product
includes all possible combinations of tuples. Hence, option (d) is correct.
6
Question 7
Consider the following instance of the CourseDetails(CourseID, CourseName) relation:
CourseID CourseName
C101 Mathematics
C102 Physics
Answer: d)
Explanation: Option (a) is incorrect because CourseID “C105” does not exist in the referenced
relation CourseDetails. Option (b) is incorrect because EnrollmentID cannot have duplicate values,
violating the primary key constraint. Option (c) is incorrect because primary key values cannot be
NULL, as seen in the first tuple. Hence, option (d) is the correct answer.
7
Question 8
Consider the following table:
CityDetails
CityName Population StateName
Mumbai 20000 Maharashtra
Delhi 19000 Delhi
Bengaluru 12000 Karnataka
Hyderabad 10000 Telangana
Ahmedabad 8000 Gujarat
Pune 6000 Maharashtra
Identify the correct operation(s) that produce the following output from the above relation:
a) σ(Population>=12000) (CityDetails)
d) σ(Population>=19000) (CityDetails)
Answer: a), c)
Explanation: As per Relational Operators syntax and semantics, options (a) and (c) correctly
filters cities with a population greater than or equal to 12000 as per the given instance.
8
Question 9
Consider the following tables:
CityDetails1
CityName Population StateName
Mumbai 20000 Maharashtra
Delhi 19000 Delhi
Ahmedabad 8000 Gujarat
Pune 6000 Maharashtra
CityDetails2
CityName Population StateName
Mumbai 20000 Maharashtra
Bengaluru 12000 Karnataka
Ahmedabad 8000 Gujarat
Chennai 10000 Tamil Nadu
Identify the correct operation(s) which produce the following output from the above two relations:
a) CityDetails1 − CityDetails2
b) CityDetails1 ∩ CityDetails2
c) CityDetails2 − CityDetails1
d) CityDetails1 ∪ CityDetails2
Answer: b)
Explanation: As per Relational Operators syntax and semantics, option (b) is correct because
the result is the intersection of CityDetails1 and CityDetails2 .
9
Question 10
Consider the following table:
CityDetails
CityName Population StateName
Mumbai 20000 Maharashtra
Delhi 19000 Delhi
Bengaluru 12000 Karnataka
Hyderabad 10000 Telangana
Ahmedabad 8000 Gujarat
Pune 6000 Maharashtra
Identify the correct operation(s) that produce the following output from the above relation:
FilteredCityDetails
CityName StateName
Mumbai Maharashtra
Delhi Delhi
Bengaluru Karnataka
Answer: c)
Explanation: The operation in option (c) first applies the selection operator (σ(Population >= 12000) )
Q
to filter rows where Population is at least 12000. Then, the projection operator ( (CityName, StateName) )
is applied to retain only the CityName and StateName columns, which matches the desired output.
10
Course Name: Database Management System
Assignment 2 - Week 2 (Jan 2025)
TYPE OF QUESTION: MCQ/MSQ
Question 1
In an e-commerce system, the instance of OrderDetails is as follows:
OrderDetails
OrderID ProductID Quantity
O101 P001 3
O102 P002 2
O103 P003 5
O104 P004 1
O105 P005 4
For the given instance, the Quantity values need to be updated by decreasing 1 for those entries
where the current values are greater than 2. What is the correct SQL Query for updating the current
instance?
Answer: b)
Explanation: To modify an existing value in a table, the UPDATE statement is used in SQL, followed
by setting the new values for the columns based on a specified condition. The correct query is:
UPDATE Tablename
SET column1 = value1, column2 = value2, column3 = value3,....
WHERE condition;
1
Question 2
Consider the following two tables representing a book store system:
OrderDetails
BookDetails
OrderID BookID Quantity
BookID Category
O101 B001 5
B001 Fiction
O102 B003 2
B002 Science
O103 B002 7
B003 Fiction
O104 B001 1
What is the output of the following SQL query?
a) Fiction: 8, Science: 7
b) Fiction: 6, Science: 7
c) Fiction: 9, Science: 7
d) Fiction: 8, Science: 6
Answer: a)
Explanation: The query performs an inner join between OrderDetails and BookDetails on BookID.
The result is grouped by Category, and the SUM(Quantity) is calculated for each category. The in-
termediate table after the join is:
2
Question 3
Consider the following instance ProductDetails of an e-commerce application:
ProductDetails
ProductID Name Price Category
P001 Laptop 50000 Electronics
P002 Mobile 20000 Electronics
P003 Shoes 3000 Footwear
P004 Watch 1500 Accessories
P005 Shirt 800 Clothing
Identify the correct statement to create a VIEW on the ProductDetails table to retrieve Name and
Price of all products in the Electronics category, and name the view as ‘Electronics Products’:
a) Create Electronics_Products
AS SELECT Name, Price
FROM ProductDetails
WHERE Category = ‘Electronics’;
Answer: b)
Explanation: The correct syntax for creating a VIEW is:
3
Question 4
Consider the following table for a ride-sharing application:
DriverDetails
DriverID Location
D001 Bangalore
D002 Hyderabad
D003 Chennai
D004 Pune
D005 Bhopal
D006 Delhi
Which of the following options will be present in the output generated by the SQL query:
SELECT Location FROM DriverDetails WHERE Location LIKE ‘B%’ AND Location LIKE ‘%e’ ;
a) Bangalore
b) Bhopal
c) Pune
d) Hyderabad
Answer: a)
Explanation: The operator ‘LIKE’ uses patterns described by special characters: percent (%) and
underscore ( ). The % character matches any substring, and the character matches any single
character.
The clause ‘WHERE Location LIKE ‘B%’ matches locations starting with ‘B’, such as ‘Bangalore’
and ‘Bhopal’.
The clause “AND Location LIKE ‘%e’ ” further filters the result to include locations ending with ‘e’.
Thus, only ‘Bangalore’ satisfies both conditions.
4
Question 5
Consider the two instances:
OrderDetails
ProductDetails
OrderID ProductID Quantity
ProductID ProductName
O001 P001 10
P001 Laptop
O002 P002 5
P002 Mouse
O003 P003 8
P003 Keyboard
O004 P002 3
Which of the following relational algebra operations will generate the following output:
Answer: a)
Explanation: A NATURAL JOIN joins two relations based on all the columns with the same name.
In this case, the common column is ProductID. The result includes rows where there is a matching
ProductID in both relations.
An EQUI JOIN is a join where the join condition contains an equality operator. An EQUI JOIN returns
only the rows that have equal values for the specified column(s) and the compared column(s) twice.
Hence, option (a) is the correct answer.
5
Question 6
Which of the following statements is incorrect?
Answer: a), d)
Explanation: The INSERT command is used to add rows, not modify or remove them. The DELETE
command removes data (rows) from a relation but does not remove the relation itself. Hence, options
(a) and (d) are the answer.
6
Question 7
Consider the following instance of the DriverDetails(DriverID, Name, Age, City) relation.
DriverDetails
DriverID Name Age City
D001 John 25 New York
D002 Sarah 32 Los Angeles
D003 Michael 30 Chicago
D004 Alice 28 New York
D005 David 35 Los Angeles
D006 Emma 40 Chicago
D007 Olivia 22 New York
D008 James 28 Los Angeles
Answer: a)
Explanation: The SQL query selects drivers whose age is greater than the average age of other
drivers in the same city. The subquery calculates the average age of drivers in the same city for each
driver (using ‘d1.City = d2.City’), and the outer query selects the drivers whose age is greater than
the calculated average for their city.
Hence, option a) is correct.
7
Question 8
Consider the following instance of the DriverDetails(DriverID, Name, Age, City) relation.
DriverDetails
DriverID Name Age City
D001 John 25 New York
D002 Sarah 32 Los Angeles
D003 Michael 30 Chicago
D004 Alice 28 New York
D005 David 35 Los Angeles
D006 Emma 40 Chicago
D007 Olivia 22 New York
D008 James 28 Los Angeles
What will be the output of the following query?
Answer: c)
Explanation: The SQL query selects drivers whose age is greater than the average age of drivers in
the ‘Los Angeles’ city. The subquery calculates the average age of drivers in ‘Los Angeles’, which is
(32+35+28)/4 = 31.67. The outer query selects drivers whose age is greater than 31.67.
Therefore, the correct answer is option c).
8
Question 9
Consider the following instance DriverDetails of a transportation application:
DriverDetails
DriverID Name Age City
D001 John 25 New York
D002 Sarah 32 Los Angeles
D003 Michael 30 Chicago
D004 Alice 28 New York
D005 David 35 Los Angeles
D006 Emma 40 Chicago
D007 Olivia 22 New York
D008 James 28 Los Angeles
What will be the output of the following query?
Answer: a)
Explanation: The query uses the IN operator to select drivers whose City is either ‘New York’ or
‘Chicago’. The rows that match these conditions are shown in the output table. Hence, option a) is
correct.
9
Question 10
Consider the following instance DriverDetails of a transportation application:
DriverDetails
DriverID Name Age City
D001 John 25 New York
D002 Sarah 32 Los Angeles
D003 Michael 30 Chicago
D004 Alice 28 New York
D005 David 35 Los Angeles
D006 Emma 40 Chicago
D007 Olivia 22 New York
D008 James 28 Los Angeles
Identify the correct statement to find the DriverID, Name, and City of DriverDetails table whose
Age is between 25 and 35.
Answer: c)
Explanation: The BETWEEN operator selects values within a given range. The values can be numbers,
text, or dates, and both the start and end values are included.
The correct syntax for using the BETWEEN operator is:
SELECT columnname(s)
FROM tablename
WHERE columnname BETWEEN value1 AND value2;
The IN operator allows specifying multiple values in a WHERE clause. It is a shorthand for multiple OR
conditions, but it is not used for ranges.
Hence, option c) is correct.
10
Course Name: Database Management System
Assignment 3 - Week 3 (Jan 2025)
TYPE OF QUESTION: MCQ/MSQ
Question 1
An organization, collecting car renters’ information, considers the following relations:
Renter(Renter ID, Contact)
Renting(Renter ID, Car Number)
Car(Car Number, Model).
What will the following relational algebra expression return to the organization?
a) The Contacts of those Renters who are Renting at most one Car at that instance.
b) The Contacts of those Renters who are Renting every Car at that instance.
c) The Contacts of those Renters who are Renting at least one Car at that instance.
d) The Contacts of those Renters who are not Renting any Car at that instance.
Answer: d)
Explanation: ΠContact (Renter) returns all the Contacts from the enlisted Renters.
ΠContact (Renter 1 Renting) returns the Contacts of those Renters whose IDs have matched with
some ID in Renting i.e. the Contacts of those Renters who are Renting some Car at that instance.
Therefore, the (Contacts of all Renters − the Contacts of those Renters renting some Car) gives
the Contacts of those Renters who are not Renting any Car.
Hence, option d) is correct.
1
Question 2
An institute, maintaining a biological information system, designs an entity Species having the at-
tributes ID, Name, and Tags. ID is unique and cannot be NULL. The Name is composed of Generic
and Specific names. Tags can have multiple values. Which of the following ER notation represents
the entity Species correctly?
a)
b)
c)
d)
Answer: b)
Explanation: From the given problem, the ID should be the key attribute, denoted by underline,
Name should be a composite attribute where the sub-atrributes Generic, Specific should be denoted
with an indentation and Tags is a multivalued attribute enclosed by {}.
Hence, option b) is correct.
2
Question 3
Consider 2 instances:
Chapter
PageNo Topic Length
Paragraph
1 Introduction 5
PageNo Topic
2 SQL 6
2 SQL
3 RA 7
3 RA
4 FD 8
3 ERD 2
Which of the following operations return the 2 tuples that are present in Paragraph?
a) (Chapter)-(ΠPageNo,Topic (Chapter)-Paragraph)
Answer: c)
Explanation: Option (a) results in invalid − operation as the “arity” of Chapter and
(ΠPageNo,Topic (Chapter)-Paragraph) are not same.
Option (b) is incorrect as the ∩ operation has relations with incompatible domains of attributes on
L.H.S and R.H.S.
Option (c) is correct. As Paragraph ⊂ Chapter, ΠPageNo,Topic (Chapter) ∪ Paragraph results in
all the values of PageNo, Topic in Chapter and the ∩ selects the ones in Paragraph only.
Option (d) is incorrect as the outermost projection operation results in ambiguity.
3
Question 4
Consider the relations Temp India(Place, Celsius) and Temp France(Place, Celsius) and the
following instances:
Temp India
Temp France
Place Celsius
Place Celsius
Ahmedabad 29
Nice 20
Jaipur 22
Paris 18
Roorkee 22
Dijon 11
Kolkata 21
a) Temp India
b) Temp France
Answer: a)
Explanation: ((Temp India ∪ Temp France)) produces all tuples from both relations.
(Temp India - Temp France) = Temp India.
Thus, ((Temp India ∪ Temp France)-(Temp India - Temp France)) = Temp France
and Temp India-((Temp India ∪ Temp France)-(Temp India - Temp France)) = Temp India.
Hence, option (a) is correct.
4
Question 5
Consider the relational schema Photography(Photographer, Camera, Theme, Location).
Choose the correct Tuple Relational Calculus that represents the following statement
“Display all photographers who clicked photographs with a DSLR camera in Darjeeling.”
Answer: d)
Explanation: The tuple to be selected is represented by ‘t’ and the selection conditions are written
with ∧ as per the given question. According to the projection and selection operations shown in
lecture slides 12.26 - 12.28, option (d) shows the correct syntax and semantics of the Tuple Relational
Calculus.
5
Question 6
Consider the following instance of the relation CakeShop(Owner, Name):
CakeShop
Owner Name
Peter BakeCake
Viola CakeStop
John Cherry
Peter SweetTooth
Peter FudgePalace
Viola Desserted
Which of the following relational algebra expression does generate names of those Owners who owns
two or more CakeShops?
Answer: b)
Explanation: The Cartesian product between the renamed tables will generate 36 tuples and the
condition σC1.Owner=C2.Owner∧C1.N ame̸=C2.N ame selects the following tuples out of the 36 tuples:
6
Question 7
Consider the relational schema FormulaBook(Page, Sl, Formula).
An embedded SQL query is written with C as host language to derive some Formula entered in the
FormulaBook according to the following conditions
EXEC SQL
DECLARE c CURSOR FOR
SELECT Formula
FROM FormulaBook
WHERE Page> :PageGiven AND Sl=:SLGiven
END EXEC
Select the correct option for declaring the variables PageGiven and SLGiven.
a) EXEC-SQL BEGIN
int :PageGiven ;
int :SLGiven ;
EXEC-SQL END;
d) EXEC-SQL BEGIN
int PageGiven ;
int SLGiven ;
EXEC-SQL END;
Answer: b)
Explanation: The declaration of the variables are enclosed within
EXEC-SQL BEGIN DECLARE SECTION
EXEC-SQL END DECLARE SECTION;
The variable declaration follow the host language syntax. Hence, option (b) is correct.
7
Question 8
In a printing company, a Book is printed by multiple Employees and an Employee prints multiple
Books. The Books are identified by their unique Title. A Book also has an Edition and multiple
values of the attribute Author. An Employee has a unique ID. Assuming there is a Prints relation
between Book and Employee, what will be the correct schema for Prints and Book?
a) Prints(Title, ID)
Book(Title, Edition, Author)
b) Prints(ID)
Book(Title Edition)
Book author(Title, Author)
c) Prints(Title, ID)
Book(Title, Edition)
Book author(Title, Author)
Answer: c)
Explanation: The following represents the ER diagram of the given case.
In many-to-many relation, the relation Prints should have the primary keys of the participating
entities and since Author is multivalued, a separate schema has to be created named Book author.
Hence, option (c) is correct.
8
Question 9
Consider the Entity Relationship Diagram:
a)
b)
c)
d)
Answer: a)
Explanation: As per the alternate ER notation shown in lecture slide 15.27.
9
Question 10
Consider the Entity Relationship Diagram:
Answer: c), d)
Explanation: Option (a) and (b) are true as per the ER Diagram notations. Age is a derived attribute
of Owner. DOB is not a component attribute of Address. Hence, options (c) and (d) are not true.
10
Course Name: Database Management System
Assignment 4 - Week 4 (Jan 2025)
TYPE OF QUESTION: MCQ/MSQ
Question 1
Consider the relation MchineParts(PartNo, MachineNo, Color, Shape, Position) with the fol-
lowing Functional Dependencies:
FD1: PartNo → {MachineNo, Color}
FD2: MachineNo → Shape
FD3: {Color, Shape} → Position
FD4: Position → PartNo
Which of the following is not a candidate key?
a) {Color, Shape}
b) {MachineNo, Shape}
c) {MachineNo, Color}
d) Position
Answer: b)
Explanation: The closure ({MachineNo, Shape})+ ={MachineNo, Shape}. The closure of all other
optons produce the attributes {PartNo, MachineNo, Color, Shape, Position}. Hence, option (b)
is correct.
1
Question 2
Consider the following relational schema: Airway(Flno, Flname, Source, Destination).
The following functional dependencies hold:
FD1: Flname → Source
FD2: Source → Flno
FD3: Source → Destination
What is the highest normal form of Airway?
a) 1NF
b) 2NF
c) 3NF
d) BCNF
Answer: b)
Explanation: Flname is the key. The relation is in 1NF.
Since there is no partial dependency, it is in 2NF.
But, FD1, FD2 and FD1, FD3 show transitive dependency. So it is not in 3NF.
Hence, option b) is correct.
2
Question 3
Consider the relational schema Investor(InvestmentNo, Amount, Tenure). Two organisations iden-
tify 2 different sets of Functional Dependencies for Investor:
OrganisationA={
FD1: InvestmentNo → {Amount, Tenure}
FD2: Amount → InvestmentNo
FD3: Tenure → InvestmentNo
}
OrganisationB={
FD1: InvestmentNo → Amount
FD2: Amount → Tenure
FD3: Tenure → InvestmentNo
}
Answer: c)
Explanation:
Step 1:
The closures of attribute sets to the L.H.S of FD1, FD2, FD3 under OrganisationA are estimated
using th FDSs in OrganisationA and OrganisationB.
OrganisationA: (InvestmentNo)+ ={InvestmentNo, Amount, Tenure}
OrganisationB: (InvestmentNo)+ ={InvestmentNo, Amount, Tenure}
OrganisationA: (Amount)+ ={InvestmentNo, Amount, Tenure}
OrganisationB: (Amount)+ ={InvestmentNo, Amount, Tenure}
OrganisationA: (Tenure)+ ={InvestmentNo, Amount, Tenure}
OrganisationB: (Tenure)+ ={InvestmentNo, Amount, Tenure}
Hence, OrganisationA covers OrganisationB.
Step 2:
The closures of attribute sets to the L.H.S of FD1, FD2, FD3 under OrganisationB are estimated
using th FDSs in OrganisationA and OrganisationB. Since there is no additional attribute set to
the L.H.S of any FD in OrganisationB, from step 1 it can be concluded that OrganisationB covers
OrganisationA.
Step 3:
Since, OrganisationA covers OrganisationB and OrganisationB covers OrganisationA,
OrganisationA and OrganisationB are equivalent. Hence, option (c) is correct.
3
Question 4
Consider the following relation Work:
Work
Incharge Department Experience
S. Roy Production 5
A. Bera Sales 2
S. Roy HR 5
S. Rai Development 3
B. Mallik Testing 4
S. Sinha Testing 4
a) Department → Experience
b) Incharge → Experience
c) Experience → Incharge
d) Incharge → Department
Answer: a), b)
Explanation: For options a), b), the attributes on the L.H.S can uniquely identify the attributes
on the R.H.S.
4
Question 5
In a relation BloodDonation, the attributes are: DonorID, DonorName, DonorAddress, and DonorBloodGroup.
DonorID can uniquely identify DonorName, DonorAddress. DonorName can uniquely identify DonorBloodGroup.
If the first donor, having DonorID = A1, DonorName = Aman, DonorAddress = Kolkata and DonorBloodGroup
= A+ was registered and recorded under the schema, which of the following records will be invalid as
another entry in BloodDonation?
Answer: a)
Explanation: If the other donor has DonorID = A2, DonorName = Aman, DonorAddress = Mumbai
and DonorBloodGroup= B+, it violates the functional dependency DonorName → DonorBloodGroup.
This is because, Aman will be associated with both A+ and B+. Hence, the record in option (a) cannot
be the other entry in the instance. Hence, option (a) is correct.
5
Question 6
A software company maintains a relation OnlineRace with attributes like GameID, Player, CarType,
CarColor, RaceTime, Laps. GameID can uniquely identify all other attributes. Player can uniquely
identify CarType and Laps is identified by RaceTime. What is the highest normal form of OnlineRace?
a) 1NF
b) 2NF
c) 3NF
d) BCNF
Answer: b)
Explanation: The relation OnlineRace has the following functional dependencies:
FD1: GameID → {Player, CarType, CarColor, RaceTime, Laps}
FD2: Player → CarType
FD3: RaceTime → Laps
GameID is the key and there are no partial dependencies. However, FD2 and FD3 show transitive
dependencies as they are dependencies between non-key attributes.
Hence, the highest Normal Form is 2NF.
6
Question 7
Consider the relation PollutionControl(FactoryID, EmissionLevel, EmissionEffect, Locality)
with the following Functional Dependencies:
FD1: {FactoryID, EmissionLevel} → {EmissionEffect, Locality}
FD2: {EmissionLevel, EmissionEffect} → Locality
PollutionControl is decomposed into the following:
PollutionControl1(FactoryID, EmissionLevel, EmissionEffect) and
PollutionControl2(FactoryID, EmissionLevel, Locality)
Which of the following statements is(are) true?
Answer: a)
Explanation: The decomposition is lossless as
(1) PollutionControl1 ∩ PollutionControl2={FactoryID, EmissionLevel}
(2) PollutionControl1 ∪ PollutionControl2={FactoryID, EmissionLevel, EmissionEffect,
Localityl}
(3){FactoryID, EmissionLevel} is a primary key. Hence {FactoryID, EmissionLevel} → PollutionControl1,
PollutionControl2.
The decomposition is not dependency preserving as
(1) Non-trivial dependencies derived from original FDs for PollutionControl1 are Set1={ {FactoryID,
EmissionLevel} → EmissionEffect}
(2) Non-trivial dependencies derived from original FDs for PollutionControl2 are Set2={ {FactoryID,
EmissionLevel} → Locality}
(3) FDs derivable from Set1 ∪ Set2={{FactoryID, EmissionLevel} → {EmissionEffect, Locality}}
which is FD1. However, FD2 cannot be derived. Hence option (a) is correct.
7
Question 8
Consider the relation Tea(Mfd, Origin, Type, Flavor, Rating) with the following Functional De-
pendencies:
FD1: Mfd → {Origin, Type}
FD2: Origin → Flavor
FD3: {Type, Flavor} → Rating
FD4: Rating → Mfd
What is the maximum number of candidate keys for the relation Tea?
a) 2
b) 3
c) 4
d) 5
Answer: c)
Explanation: By estimating the closure of all combination of the attributes, it can be observed that
the closure of the following attributes produce all other attributes:
Mfd, Rating, {Origin, Type}, {Type, Flavor}.
Hence, these 4 are the candidate keys.
8
Question 9
Consider the relation TimeCounter(LogID, Days, Hours, Mins, Secs) with the following func-
tional dependencies:
FD1: LogID→{Days, Hours}
FD2: Days→Mins
FD3: {Hours, Mins}→Secs
FD4: Secs→LogID
Which of the following functional dependencies violate the BCNF form?
a) FD1
b) FD2
c) FD3
d) FD4
Answer: b)
Explanation: From the given functional dependencies, the candidate keys can be identified as
LogID, Sec, {Days, Hours} and {Hours, Mins}. FD2 is neither trivial nor the L.H.S of this de-
pendency form a superkey of the given relation and hence, violates BCNF form. Hence, options (b) is
correct.
9
Question 10
Consider the relation Carnival(CID, Location, Span, RideCount, ShowCount, StartTime, EndTime,
Crowd) with the following functional dependencies:
FD1: CID→{Location, Span, RideCount}
FD2: {CID, RideCount}→ShowCount
FD3: {ShowCount, StartTime, EndTime}→Crowd
FD4: StartTime→{EndTime, Crowd}
Which of these functional dependencies can be eliminated without changing the primary key of the
relation?
a) FD1
b) FD2
c) FD3
d) FD4
Answer: c)
Explanation: The given functional dependencies imply that only attributes CID and StartTime
cannot be reached from any other attributes. Hence, the key for this relation can be evaluated to
be {CID, StartTime}. If we remove any other FD except FD3, the key of the relation will change.
Hence, option (c) is correct.
10
Course Name: Database Management System
Assignment 5 - Week 5 (Jan 2025)
TYPE OF QUESTION: MCQ/MSQ
Question 1
Which of the followings can be the solution(s) of Password Leakage in Database Servers?
Answer: a), d)
Explanation: Refer to lecture slide 22.
1
Question 2
Which of the following statement(s) is/are incorrect?
Answer: b), c)
Explanation: World Wide Web is distributed information system based on hypertext. Hyper Text
Transfer Protocol is connectionless. So, these two options are wrong.
Refer to Module 21.
So, options b) and c) are the answer.
2
Question 3
Consider the following table DEFAULTER (ID, NAME, AMOUNT). If we want to create an index
on DID column, which type of indexing will be preferred?
DEFAULTER
DID NAME AMOUNT
415 AISHA 20000
124 JOHN 5000
347 EDWARD 100
145 RAY 200
209 AKASH 900
a) Sparse index
b) Secondary index
c) Dense index
d) Clustering index
Answer: c)
Explanation: When the file is not sorted on the indexed field or when the index file is small,
compared to the size of the memory, it is preferable to use dense indexing. The above table has only
5 records and DID field is not in sorted order.
Hence, option c) is correct.
3
Question 4
A magnetic disk has 16 platter surfaces, 256 tracks per surface, 512 sectors per track, and 1024 bytes
per sector. How many number of bits will be required to address a sector?
a) 17
b) 21
c) 27
d) 31
Answer: b)
Explanation: Number of platter surfaces = 16
Number of tracks per surface = 256
Number of sectors per track = 512
Therefore, total number of sectors
= Total number of platter surfaces x Number of tracks per surface x Number of sectors per track
= 16 x 256 x 512 sectors
= 24+8+9 sectors
=221
So, Number of required bits to address the sector = 21 bits
Hence, option b) is correct.
4
Question 5
Availability of Redundant Arrays of Independent Disks system is 97%. Mean Time Between Failure
(MTBF) is 36 days. What is the approximate Mean Time To Repair (MTTR) of the system?
a) 10.80 Hours
b) 26.72 Hours
c) 34.92 Hours
d) 88.36 Hours
Answer: b)
Explanation: Mean time between failures is the average time between failures.
Mean time between failures (MTBF) = total available time / number of failures.
Mean time to repair is the average time taken to repair the system.
Mean time to repair(MTTR)= total unavailable time /number of failures
Availability = Total available time /(total available time +total unavailable time)
M T BF
(M T BF +M T T R) = 97%
36∗24∗100
(36∗24+M T T R) = 97
36 ∗ 24 + M T T R = 36∗24∗100
97
MTTR = (36∗24∗100)−(36∗24∗97)
97 hours
MTTR = 26.72 hours
Hence, option b) is correct.
5
Question 6
In a Coding Competition, participants individually can enroll their names for the competition.
There are many groups in the competition depending on the age of the participants. A participant
can participate in only one group and a group can consist of multiple participants. Each group
has a unique name and a participant also has a unique id. The result of each group will be main-
tained separately. Which of the following statement(s) are correct?
d) Gname can be the foreign key of Participate relation between Group and Participant.
Answer: b), d)
Explanation: If we draw the ER diagram of it, we can see there will be a one-to-many relationship
between Group and Participant.
Gname is the primary key of the entity Group table. Hence, can be the foreign key of Participate
relation between Group and Participant.
6
Question 7
A flash storage system uses the size of a page 4 KB and 32-bit page-address for its operation. More-
over, the flash translation table is stored as an array. If the size of the flash memory is 64 GB, what
will be the size of the flash translation table?
a) 64 MB
b) 32 MB
c) 24 MB
d) 16 MB
Answer: a)
Explanation: Size of the flash memory = 64 GB = 64 x 230 bytes
Size of a page = 4 KB = 4 x 210 bytes
30
Number of pages = 64×24×210
= 16 x 220
Size of page address = 32 bits = 4 bytes
Therefore, the size of the flash translation table = 16 x 220 x 4 bytes = 64 MB
Hence, option a) is correct.
7
Question 8
Consider the following string of reference:
12, 25, 31, 42, 12, 25, 50, 12, 25, 31, 42, 50
Find the number of replacements (where an existing value is replaced by a new value because the
buffer is full) incurred using the least recently used (LRU) buffer replacement algorithm with 3 empty
buffer frames.
a) 12
b) 10
c) 8
d) 7
Answer: d)
Explanation:
Buffer Comments
12 12 is added to empty buffer
12 25 25 is added to empty buffer
12 25 31 31 is added to empty buffer
42 25 31 12 is least recently used. Hence, replaced by 42
42 12 31 25 is least recently used. Hence, replaced by 12
42 12 25 31 is least recently used. Hence, replaced by 25
50 12 25 42 is least recently used. Hence, replaced by 50
50 12 25 No replacement, 12 present
50 12 25 No replacement, 25 present
31 12 25 50 is replaced, as 12, 25 are recently used
31 42 25 12 is replaced, as it is least recently used element
31 42 50 25 is replaced
Hence, altogether 7 replacements have been done. So, option d) is the answer.
8
Question 9
Consider a file organization, where the size of one record is 48 bytes, the size of the disk block pointer
is 10 bytes, and the size of one disk block is 512 bytes. If organization of the file is sequential and
unspanned (one block can store only whole records), maximum how many records can be stored in
one block?
a) 12
b) 11
c) 10
d) 9
Answer: c)
Explanation: The file organization is unspanned. So, one block can store N numbers of whole
records and one block pointer.
One record size(V) = 48 bytes
Disk block size = 512 bytes
Disk block pointer (p) = 10 bytes
Actual Storage size of one block = (512-10) =502 bytes
N = 502/48 = 10
So, maximum 10 records can be stored in a block.
9
Question 10
Identify the correct statement(s) about the following RAID levels?
Answer: b), c)
Explanation: RAID 0 provides block-level striping without parity or mirroring and RAID 5 provides
block-level striping with distributed parity. Therefore, these two statements are given in options a)
and d) are incorrect.
Hence, options b) and c) are the answers.
10
Course Name: Database Management System
Assignment 6 - Week 6 (Jan 2025)
TYPE OF QUESTION: MCQ/MSQ
Question 1
Which of the statement(s) is (are) correct?
Answer: a), d)
Explanation: Key value of non-leaf nodes of B-tree does not appear in the leaf node. So they contain
record pointers also.
Size of non-leaf nodes of B + tree is smaller than leaf nodes as they do not contain any record pointers.
So, these two statements are wrong.
Hence, options a) and d) are the answer.
1
Question 2
Consider the following two table. Identify the correct worst case time Complexity for the given
operation and data structure.
Answer: b)
Explanation: The worst-case search time complexity for the operations on data structures are:
2
Question 3
Consider a hash table of size m = 1000 and the hash function h(k) = Round(k ÷ 7) % 1000. Compute
the location where the key k = 97531 will be stored.
a) 97
b) 139
c) 531
d) 933
Answer: d)
Explanation: the hash function is h(k) = Round(k ÷ 7) % 1000
key k = 97531
So, Location = Round(97531 ÷ 7) % 1000
= Round(13933) % 1000
= 13933 % 1000
= 933
Hence, option d) is correct.
3
Question 4
How many maximum numbers of keys, a B-tree of order 6 can store? The height of the tree is 4 and
the root node is assumed to be in height zero.
a) 9330
b) 7775
c) 1554
d) 1295
Answer: b)
Explanation: A B-tree of order m and height h will have the maximum number of keys when all
nodes are completely filled.
A height-0, B-tree of order 6 can store 5 keys.
A height-1, B-tree of order 6 can have 6 children. So, can have 6x5 + 5 keys.
Similarly, maximum number of keys in a B-tree of height h = (mh+1 –1) keys
Here, m=6 and h=4. Hence, maximum keys = (64+1 –1)
So, 65 − 1 = 7776 - 1 = 7775
Hence, option b) is correct.
4
Question 5
In a B+ tree indexing, size of the search key field is 10 bytes. If the block size is 2 kilobytes
and the block pointer size is 14 bytes, calculate the order of a non-leaf node?
a) 204
b) 146
c) 85
d) 58
Answer: c)
Explanation: A B+ Tree of order m means every node has at most m children.
So, there will be only m number of block pointers and (m − 1) number of key value in any non-leaf
nodes.
5
Question 6
A relational table is saved in the disk and indexed with bitmap index. Size of the bitmap indexed
file is 512 bytes. If there are 16 distinct values in the index column, how many rows are there in the
relation table?
a) 256
b) 128
c) 64
d) 32
Answer: a)
Explanation: A bitmap index on a n row table with k distinct values in the index column will have
n x k bits in the bitmap.
Therefore, n x k bits = The size of the bitmap index = 512 bytes
So, n = (512 x 8) ÷ 16 = 256
So, option (a) is correct.
6
Question 7
Consider the following 2-3-4 Tree:
If we want to add a new key 40, what will be the resultant tree?
a)
b)
c)
d)
Answer: b)
Explanation: When we want to insert 40, it will come into the left-most sub-tree of 42. There are
already 3 elements in that node. So, the node will split and 20 will go up into the root. In root there
are already 3 elements, it also splits. Therefore, after adjustment of all pointers, the tree will look
like:
7
Question 8
A hash table contains 10 (indices 0 to 9) buckets and uses linear probing to resolve collisions. The key
values are integers and the hash function used is (key % 10). Given the following input (221, 334,
447, 771, 574, 427, 673, 841), which of the following statements is true?
Answer: c)
Explanation: After inserting all keys, the buckets will be:
8
Question 9
Consider the following table:
Answer: a)
Explanation: CATEGORY MUSIC is present in 3rd and 5th tuple and absent in 1st, 2nd and 4th tuples.
So, the bitmap indices for MUSIC is 00101. Similarly, GRADE A is present in 1st, 3rd and 4th tuples and
is absent in 2nd and 5th tuples. So, the bitmap indices for GRADE A is 10110.
Hence, option a) is correct.
9
Question 10
Suppose there is a relation student(id, name, age), with a B+ tree index with search key id. What
is the worst-case cost of finding records satisfying 20 < id < 40 using this index, in terms of the
number of records retrieved m and the height of the tree is h?
a) O(m*h)
b) O(2*h +m)
c) O(log h +m)
d) O(h+m)
Answer: d)
10
Course Name: Database Management System
Assignment 7 - Week 7 (Jan 2025)
TYPE OF QUESTION: MCQ/MSQ
Question 1
Consider the following lock compatibility matrix where S denotes a shared lock and X denotes
an exclusive lock:
S X
S True False
X False False
a) A transaction holding an S lock on a data item allows other transactions to acquire an S lock
but not an X lock on the same data item.
b) A transaction holding an S lock on a data item allows other transactions to acquire an X lock on
the same data item.
c) A transaction holding an X lock on a data item allows other transactions to acquire another X
lock on the same data item.
d) A transaction holding an X lock on a data item prevents other transactions from acquiring an S
lock on the same data item.
Answer: a), d)
Explanation: According to the lock compatibility matrix, a transaction holding an S lock allows
other transactions to acquire S locks but does not permit X locks. Therefore, statement (b) and (c)
are incorrect.
1
Question 2
Consider the following schedule S involving five transactions T1 , T2 , T3 , T4 , and T5 :
T1 T2 T3 T4 T5
W(X)
R(X)
W(Y)
W(X)
R(Z)
W(Y)
R(X)
W(Z)
Answer: (b)
Explanation: By drawing the precedence graph for the transactions and checking for cycles, we
can determine the serializability of the schedule. If no cycles are found, the schedule is conflict
serializable.
Additionally, conflict serializable schedules are always view serializable. So, option (b) is
correct.
2
Question 3
Consider the following schedule S involving five transactions T1 , T2 , T3 , T4 and T5 :
T1 T2 T3 T4 T5
R(Z)
R(X)
R(Y)
W(X)
W(X)
W(Z)
W(Z)
a) T1→T4→T5→T2→T3
b) T1→T2→T3→T4→T5
c) T1→T2→T4→T5→T3
d) T1→T4→T3→T5→T2
Answer: d)
Explanation: If we draw the precedence graph of the transactions as shown in the following, we
can observe that the graph has no cycle.
So, the above schedule is a conflict serializable schedule.
All conflict serializable schedules are view serializable too.
All possible topological orderings of the above precedence graph will be the possible conflict
serializable schedule.
Hence, the incorrect order of execution of all transactions among the given options is: T1→T4→T3→T5→T2
So, option (d) is the answer.
3
Question 4
Consider the following schedule S involving five transactions T1 , T2 , T3 , T4 and T5 :
T1 T2 T3 T4 T5
R(Z)
R(X)
W(X)
R(X)
R(Z)
W(X)
W(Z)
W(Y)
W(Z)
W(Y)
W(Y)
a) 1
b) 2
c) 3
d) 5
Answer: d)
Explanation: If we draw the precedence graph of the schedule, we can observe that the graph
has no cycle. Hence, the above schedule is conflict serializable schedules.
All possible topological orderings of the above precedence graph will be the possible conflict
serializable schedule.
1. T1 → T4 → T2 → T5 → T3
2. T1 → T4 → T2 → T3 → T5
3. T1 → T2 → T4 → T3 → T5
4. T1 → T2 → T4 → T5 → T3
5. T1 → T2 → T3 → T4 → T5
Hence, option d) is correct.
4
Question 5
Consider the following schedule S of transactions T1 and T2 .
The read operation on data item A is denoted by read(A) and the write operation on data item A is
denoted by write(A).
T1 T2
read(A)
A:=A-500
read(C)
write(A)
read(B)
temp:=C∗0.5
C:=C-temp
B:=B+500
write(C)
write(B)
read(B)
B:=B+temp
write(B)
c) S is serializable only as T1 , T2 .
d) S is serializable only as T2 , T1 .
Answer: c)
Explanation: First, swap all non-conflicting instructions of the above schedule S.
T1 and T2 both are working on a same data item.
So, S is serializable only as T1 , T2 .
Hence, option (c) is correct.
5
Question 6
Consider the following schedule S.
T1 T2 T3
R(Y)
W(Y)
R(Y)
W(Y)
W(Y)
a) 1
b) 2
c) 4
d) 6
Answer: a)
Explanation: Step 1: Final Update on data item: This is done on Y by T1.
Since the final update on Y is made by T1, the transaction T1 must execute after the transactions T2
and T3 So, (T2,T3) → T1.
Step 2: Initial Read + Which transaction updates after read?
Transaction T3 does the initial read Y; then, T2 updates on it.
Hence, the dependency is: T3 → T2
Step 3: Write Read Sequence: T2 writes Y and then T1 reads Y.
Hence, the dependency is as follows. T2 → T1
Thus, the only possible way, this is possible is: T3 → T2 → T1.
Hence, total possible view serializable schedule of S= 1.
So, option (a) is correct.
6
Question 7
Consider two transactions given below where lock-X(A) denotes Ti has obtained an Exclusive-mode
lock on item A and lock-S(A) denotes Ti has obtained a Shared-mode lock on item A.
T1 T2
lock-X(A) lock-X(A)
read(A) read(A)
lock-X(B) A:= A-100
read(B) write(A)
B:= B+100 lock-S(B)
write(B) read(B)
lock-S(C) lock-S(C)
read(C) read(C)
unlock(C) unlock(B)
commit unlock(C)
unlock(A) commit
unlock(B) unlock(A)
a) T2 follows the rigorous two-phase locking protocol, but T1 follows the strict two-phase
locking protocol only .
b) T1 follows the rigorous two-phase locking protocol, but T2 follows the strict two-phase
locking protocol only.
Answer: c)
Explanation: Transaction T1 first unlocks all Shared-mode lock and then commits. After commit, it
unlocks Exclusive-mode lock . That is why, T1 follows the strict two-phase locking protocol.
Transaction T2 first unlocks all Shared-mode lock and then commits. After commit, it unlocks
Exclusive-mode lock . That is why, it follows the strict two phase locking protocol only.
So, option (c) is correct.
7
Question 8
Consider the following schedule S.
T1 T2
R(X)
W(X)
R(Y)
W(Y)
COMMIT
R(X)
W(X)
R(Y)
W(Y)
COMMIT
Answer: c)
Explanation: Recoverable schedule: If a transaction Tj reads a data item previously written by a
transaction Ti , the commit operation of Ti must appear before the commit operation of Tj .
Cascadeless schedules: For each pair of transactions Ti and Tj such that Tj reads a data item previously
written by Ti , the commit operation of Ti appears before the read operation of Tj .
Here, T2 read all data items after commit operation of T1 . Hence, the schedule is recoverable as well
as casecadeless.
So, option (c) is correct.
8
Question 9
Consider the following schedule S.
T1 T2 T3
R(X)
W(X)
R(X)
W(X)
R(Y)
W(Y)
R(Y)
W(Y)
abort
a) If T2 fails (aborts), only T1 will be rolled back, while T3 will remain unaffected.
b) If T2 fails (aborts), only T3 will be rolled back, while T1 will remain unaffected.
d) If T2 fails (aborted), both transactions T1, and T3 must also be rolled back.
Answer: d)
Explanation:
• In the given schedule, T3 depends on the data item Y written by T2. If T2 aborts, T3 must also
roll back to ensure consistency.
• In the given schedule, T2 depends on the data item X written by T1. If T2 aborts, T1 must also
roll back to ensure consistency.
Thus, the correct answer is (d): If T2 fails, both transactions T1, and T3 must also be rolled back.
9
Question 10
Suppose in a database, there are three transactions T1 , T2 , and T3 with timestamps 20, 21, and 22
respectively. T2 is holding some data items which T1 and T3 are requesting to acquire. Which of the
following statement(s) is (are) correct in respect of Wait-Die Deadlock Prevention Scheme?
c) Transaction T1 will wait for T2 to release the data item and Transaction T3 will rollback.
Answer: c)
Explanation: In Wait-Die Deadlock Prevention scheme:
Older transaction may wait for younger one to release data item. (older means smaller timestamp)
Younger transactions never wait for older ones; they are rolled back instead.
Transaction T1 is older than T2 , hence T1 will wait until the data item is released. Transaction T3 is
younger than Transaction T2 , so it will be rolled back.
Hence, option c) is correct.
10