Chapter 8 12th computer (1)
Chapter 8 12th computer (1)
Database Concepts
Q.1 Give the terms for each of the following:
(a) Collection of logically related records.
(b) DBMS creates a file that contains description about the data stored in the
database.
(c) Attribute that can uniquely identify the tuples in a relation.
(d) Special value that is stored when actual data value is unknown for an attribute.
(e) An attribute which can uniquely identify tuples of the table but is not defined as
primary key of the table.
(f) Software that is used to create, manipulate and maintain a relational database.
Answer
(a) Table
(b) Data dictionary
(c) Primary key
(d) NULL
(e) Alternate Key
(f) Database Management System (DBMS)
Question 2
Why foreign keys are allowed to have NULL values? Explain with an example.
Answer
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.
Question 3(a)
Question 3(b)
Question 3(c)
Question 4
Question 5
What are the limitations of file system that can be overcome by a relational DBMS?
Answer
The limitations of file system overcome by a relational DBMS are as follows:
1. Data Redundancy
2. Data Inconsistency
3. Data Isolation
4. Data Dependence
5. Difficulty in data access
6. Controlled data sharing
Question 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
Roll_no Preference
17 Badminton
17 Football
21 Hockey
24 NULL
NULL Kabaddi
1. Roll no 24 may not be interested in sports. Can a NULL value be assigned to that
student’s preference field ?
2. 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?
3. Kabaddi was not chosen by any student. Is it possible to have this tuple in the
Sports Preferences relation ?
Answer
Question 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
Sports Roll_no
Badminton 17
Cricket 9
Cricket 24
Football 13
Hockey 21
Question 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 ?
(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:
(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?
Answer
(a) 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
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) Yes, the item sale information should be stored in a separate relation, say
"SaleOrders".
SaleOrders table
Question 9
Question 10
Table: COST
Table: UNIFORM
1 Shirt White
2 Pant Grey
3 Skirt Grey
4 Tie Blue
5 Socks Blue
6 Belt Blue
Table: COST
1 M 500
1 L 580
1 XL 620
2 M 810
2 L 890
2 XL 940
UCode Size COST Price
3 M 770
3 L 830
3 XL 910
4 S 150
4 L 170
5 S 180
5 L 210
6 M 110
6 L 140
6 XL 160
(a) Can they insert the following tuples to the UNIFORM Relation ? Give reasons in
support of your answer.
1. 7, Handkerchief, NULL
2. 4, Ribbon, Red
3. 8, NULL, White
(b) Can they insert the following tuples to the COST Relation ? Give reasons in support
of your answer.
1. 7, S, 0
2. 9, XL, 100
Answer
(a)
1. 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.
2. Tuple (4, Ribbon, Red): This tuple can be inserted as all attributes have valid non-
null values.
3. Tuple (8, NULL, White): This tuple cannot be inserted because UName attribute
cannot be NULL as per the schema constraints.
(b)
1. Tuple (7, S, 0): This tuple cannot be inserted because the COST Price attribute
must be greater than 0 as per the schema constraints.
2. Tuple (9, XL, 100): This tuple can be inserted as all attributes have valid values and
the COST Price is greater than 0.
Question 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.
(b) Is it correct to assign AudiNo as the primary key in the AUDI relation ? If no, then
suggest appropriate primary key.
(c) Is there any foreign key in any of these relations ?
Answer
(a) Yes, assigning Movie_ID as the primary key in the MOVIE relation is correct
because each movie has a unique Movie_ID.
(b) 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) 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.
Question 12
11 Mohan XI 1 IP-101-15
12 Sohan XI 2 IP-104-15
Table: PROJECT
Registration_ID ProjectNo
IP-101-15 101
IP-104-15 103
CS-103-14 102
Registration_ID ProjectNo
CS-101-14 105
CS-101-10 104
Answer
(a) Primary key of each table:
STUDENT: Roll No.
PROJECT: ProjectNo.
PROJECT ASSIGNED: Registration_ID.
(b) The ProjectNo column in the PROJECT ASSIGNED table is a foreign key that
references the ProjectNo column in the PROJECT table.
(c) In the STUDENT table, the Registration_ID column serves as an alternate key
since it uniquely identifies each student.
(d) 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.
Question 13
For the below given database STUDENT-PROJECT, can we perform the following
operations?
(a) Insert a student record with missing roll number value.
(b) Insert a student record with missing registration number value.
(c) Insert a project detail without submission-date.
(d) Insert a record with registration ID IP-101-19 and ProjectNo 206 in table
PROJECT-ASSIGNED.
Student Project Database
Table: STUDENT
11 Mohan XI 1 IP-101-15
12 Sohan XI 2 IP-104-15
Table: PROJECT
Registration_ID ProjectNo
IP-101-15 101
IP-104-15 103
CS-103-14 102
CS-101-14 105
CS-101-10 104
Answer
(a) 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) 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) 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) 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.