0% found this document useful (0 votes)
20 views8 pages

06 DBMS

Uploaded by

Himanshu Tonk
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views8 pages

06 DBMS

Uploaded by

Himanshu Tonk
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

Database Concepts

1. Give the terms for each of the following:


(a) Collection of logically related records.
Ans. Table
(b) DBMS creates a file that contains description about the data stored in the
database.
Ans. Data Dictionary
(c) Attribute that can uniquely identify the tuples in a relation.
Ans. UNIQUE or Primary key constraint
(d) Special value that is stored when actual data value is unknown for an
attribute.
Ans. NULL
(e) An attribute which can uniquely identify tuples of the table but is not
defined as primary key of the table.
Ans. Alternate Key
(f) Software that is used to create, manipulate and maintain a relational
database.
Ans. Database Management System.
2. Why foreign keys are allowed to have NULL values? Explain with an
example.
Ans. A null value can be entered in a foreign key, indicating that the records are not
related. In certain situations, a foreign key may accept a NULL value if it's not
a part of the primary key of the foreign table.
For example, consider an Orders table in a database. Each order may or may
not be associated with a customer. If an order is placed by a guest or a new
customer who hasn't been added to the system yet, the CustomerID foreign
key in the Orders table can be NULL to indicate that there is no associated
customer record for that order.
3. Differentiate between:
(a) database state and database schema.
Database State Database Schema
The data stored in database at a The database schema defines the
particular moment of time (i.e., the design, structure, and organization of
state of the database at a particular the database, serving as the blueprint
instance of time) is called database or skeleton that determines how data
state or instance of database. is organized and related within the
database.

(b) Primary Key and Foreign Key.


Primary Key Foreign Key
Primary Key is a column or group A foreign key is an attribute whose
of columns in a table that uniquely value is derived from the primary key
identify every row in that table. of another table. A foreign key is used
to represent the relationship between
two tables.
Primary key cannot have Null Foreign key can have Null values.
values.
There can be only one primary key Multiple foreign keys can exist in a
in a table. table.
It is used to enforce entity integrity It is used to enforce referential
and ensure data uniqueness. integrity and maintain data
consistency across related tables.

(c) Degree and Cardinality of a relation.


Degree of a relation Cardinality of a relation
The number of attributes in a The number of tuples in a relation is
relation is called the Degree of the called the Cardinality of the relation.
relation.
For example, if a relation has The number of tuples in a relation is
attributes like Name, Age, and called the Cardinality of the relation.
Address, then its degree is 3.

4. Compared to a file system, how does a database management system avoid


redundancy in data through a database?
Ans. A database stores the data at a central location wherefrom all application
programs can access data. This removes the need of saving own data by
application program and thus it reduces data redundancy.
5. What are the limitations of file system that can be overcome by a relational
DBMS?
Ans. The limitations of file system overcome by a relational DBMS are as follows:
(i) Data Redundancy
(ii) Data Inconsistency
(iii) Data Isolation
(iv) Data Dependence
(v) Difficulty in data access
(vi) Controlled data sharing
6. A school has a rule that each student must participate in a sports activity. So
each one should give only one preference for sports activity. Suppose there
are five students in a class, each having a unique roll number. The class
representative has prepared a list of sports preferences as shown below.
Answer the following:
Table: Sports Preferences
Roll_no Preference
9 Cricket
13 Football
17 Badminton
17 Football
21 Hockey
24 NULL
NULL Kabaddi
(a) Roll no 24 may not be interested in sports. Can a NULL value be assigned to
that student’s preference field?
Ans. In a relational database model where each student is required to have exactly
one preference for a sports activity, assigning a NULL value to Roll no 24's
preference field is not permitted.
(b) Roll no 17 has given two preferences in sports. Which property of relational
DBMS is violated here ? Can we use any constraint or key in the relational
DBMS to check against such violation, if any?
Ans. The primary key constraint ensures uniqueness in a relational database table.
If Roll no 17 has two sports preferences, it violates this rule because a primary
key constraint on "Roll_no" would not allow different values for the same roll
number. By using a primary key constraint on "Roll_no," the relational
database management system (DBMS) can prevent such violations by rejecting
attempts to insert rows with duplicate roll numbers.
(c) Kabaddi was not chosen by any student. Is it possible to have this tuple in
the Sports Preferences relation ?
Ans. No, since no student has selected Kabaddi as their preferred sport, there
should not be an entry for Kabaddi in the Sports Preferences table.
7. In another class having 2 sections, the two respective class representatives
have prepared 2 separate Sports Preferences tables, as shown below:
Sports preference of section 1 (arranged on roll number column)
Table: Sports Preferences
Roll_no Sports
9 Cricket
13 Football
17 Badminton
21 Hockey
24 Cricket
Sports preference of section 2 (arranged on Sports name column, and
column order is also different)
Table: Sports Preferences
Roll_no Sports
Badminton 17
Cricket 9
Cricket 24
Football 13
Hockey 21
Are the states of both the relations equivalent? Justify.
Ans. Yes, the states of both the relations are equivalent as the order of rows and
columns does not matter and data is just the same in both the relations.
8. The school canteen wants to maintain records of items available in the
school canteen and generate bills when students purchase any item from the
canteen. The school wants to create a canteen database to keep track of
items in the canteen and the items purchased by students. Design a
database by answering the following questions:

(a) To store each item name along with its price, what relation should be used?
Decide appropriate attribute names along with their data type. Each item
and its price should be stored only once. What restriction should be used
while defining the relation?
Ans. To store each item name along with its price in the canteen database, we can
create a relation (table) called "Items" with the following attributes:
Items table
Attributes Datatype Constraints
ItemNo Integer Priimary, non-null, Unique
ItemName Varchar Non-null
Price Float Non-null
The restriction that should be used while defining the "Items" relation is to set
the "ItemNo" attribute as the primary key. This ensures that each item number
is unique and that each item and its price are stored only once in the database.
(b) In order to generate bill, we should know the quantity of an item
purchased. Should this information be in a new relation or a part of the
previous relation? If a new relation is required, decide appropriate name
and data type for attributes. Also, identify appropriate primary key and
foreign key so that the following two restrictions are satisfied:
The same bill cannot be generated for different orders.
Ans. Yes, the item sale information should be stored in a separate relation, say
"SaleOrders".
SaleOrders table
Attributes Datatype Constraints
Orderno Integer Primary key, Unique,
Non-null
ItemNo Integer Foreign Key, Non-null
Quantitiy Integer Non-null
Price Float Non-null
With this design, we satisfy both restrictions:
Each order has a unique OrderNo, ensuring that the same bill cannot be
generated for different orders. The foreign key constraint on ItemNo ensures
that bills can only be generated for available items in the canteen.
Bill can be generated only for available items in the canteen.
(c) The school wants to find out how many calories students intake when they
order an item. In which relation should the attribute 'calories' be stored?
Ans. 'Calories' should be stored in the "Items" table because they are directly
associated with specific items.
9. An organisation wants to create a database EMPDEPENDENT to maintain
following details about its employees and their dependent.
EMPLOYEE(AadharNumber, Name, Address, Department, EmployeeID)
DEPENDENT(EmployeeID, DependentName, Relationship)
(a) Name the attributes of EMPLOYEE, which can be used as candidate keys.
Ans. In the EMPLOYEE table, the attributes AadharNumber and EmployeeID can
be used as candidate keys. This means that either AadharNumber or
EmployeeID can uniquely identify each record in the EMPLOYEE table.
(b) The company wants to retrieve details of dependent of a particular
employee. Name the tables and the key which are required to retrieve this
detail.
Ans. The EMPLOYEE and DEPENDENT tables are linked using the EmployeeID
key, which is utilized to retrieve details of dependents associated with a
specific employee.
(c) What is the degree of EMPLOYEE and DEPENDENT relation?
Ans. In the EMPLOYEE relation, there are five attributes, resulting in a degree of 5.
Similarly, the DEPENDENT relation has three attributes, making its degree 3.
10. School uniform is available at M/s Sheetal Private Limited. They have
maintained SCHOOL_UNIFORM Database with two relations viz.
UNIFORM and COST. The following figure shows database schema and its
state.

(a) Can they insert the following tuples to the UNIFORM Relation ? Give
reasons in support of your answer.
(i) 7, Handkerchief, NULL
(ii) 4, Ribbon, Red
(iii) 8, NULL, White
Ans. (i) Tuple (7, Handkerchief, NULL): This tuple can be inserted because
there is no constraint mentioned in the schema that prohibits NULL
values for the UColor attribute.
(ii) Tuple (4, Ribbon, Red): This tuple can be inserted as all attributes have
valid non-null values.
(iii) Tuple (8, NULL, White): This tuple cannot be inserted because UName
attribute cannot be NULL as per the schema constraints.
(b) Can they insert the following tuples to the COST Relation ? Give reasons in
support of your answer.
(i) 7, S, 0
(ii) 9, XL, 100
Ans. (i) Tuple (7, S, 0): This tuple cannot be inserted because the COST Price
attribute must be greater than 0 as per the schema constraints.
(ii) Tuple (9, XL, 100): This tuple can be inserted as all attributes have valid
values and the COST Price is greater than 0.
11. In a multiplex, movies are screened in different auditoriums. One movie can
be shown in more than one auditorium. In order to maintain the record of
movies, the multiplex maintains a relational database consisting of two
relations viz. MOVIE and AUDI respectively as shown below:
Movie(Movie_ID, MovieName, ReleaseDate)
Audi(AudiNo, Movie_ID, Seats, ScreenType, TicketPrice)
(a) Is it correct to assign Movie_ID as the primary key in the MOVIE relation?
If no, then suggest an appropriate primary key.
Ans. Yes, assigning Movie_ID as the primary key in the MOVIE relation is correct
because each movie has a unique Movie_ID.
(b) Is it correct to assign AudiNo as the primary key in the AUDI relation? If
no, then suggest appropriate primary key.
Ans. It is not correct to assign AudiNo as the primary key in the AUDI relation
because an AudiNo can be repeated for different movies screened in different
auditoriums. To uniquely identify each record in the AUDI relation, a
composite primary key consisting of AudiNo and Movie_ID should be used.
(c) Is there any foreign key in any of these relations?
Ans. Yes, there is a foreign key in the AUDI relation. The Movie_ID attribute in the
AUDI relation is a foreign key that references the Movie_ID primary key in
the MOVIE relation.
12. For the Above given database STUDENT-PROJECT, answer the following:
(a) Name primary key of each table.
Ans. Primary key of each table:
STUDENT: Roll No.
PROJECT: ProjectNo.
PROJECT ASSIGNED: Registration_ID.
(b) Find foreign key(s) in table PROJECT-ASSIGNED.
Ans. The ProjectNo column in the PROJECT ASSIGNED table is a foreign key that
references the ProjectNo column in the PROJECT table.
(c) Is there any alternate key in table STUDENT? Give justification for your
answer.
Ans. In the STUDENT table, the Registration_ID column serves as an alternate key
since it uniquely identifies each student.
(d) Can a user assign duplicate value to the field RollNo of STUDENT table?
Justify.
Ans. No, a user cannot assign a duplicate value to the Roll No field of the
STUDENT table because Roll No is the primary key of the table and it must be
unique.
13. For the below given database STUDENT-PROJECT, can we perform the
following operations?
(a) Insert a student record with missing roll number value.
Ans. No. the Roll No attribute in the STUDENT table is marked as primary key and
NOT NULL. Therefore, inserting a student record with a missing Roll No
value would violate the NOT NULL constraint and is not allowed.
(b) Insert a student record with missing registration number value.
Ans. Yes, the registration_ID attribute in the STUDENT table does not have a NOT
NULL constraint specified in the schema. Therefore, it is possible to insert a
student record without registration number value.
(c) Insert a project detail without submission-date.
Ans. Yes, the SubmissionDate attribute in the PROJECT table does not have a NOT
NULL constraint specified in the schema. Therefore, it is possible to insert a
project detail without a SubmissionDate value.
(d) Insert a record with registration ID IP-101-19 and ProjectNo 206 in table
PROJECT-ASSIGNED.
Ans. No, we cannot perform this operation. ProjectNo in PROJECT ASSIGNED
table serves as a foreign key that references the primary key in the PROJECT
table. Since ProjectNo "206" is not present in the PROJECT table, it cannot be
inserted into the PROJECT ASSIGNED table.

You might also like