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

Chapter 8 12th computer (1)

The document covers various database concepts, including definitions of key terms, the role of foreign keys, and the differences between primary and foreign keys. It also discusses the structure of database relations, constraints, and the importance of avoiding redundancy in data management. Additionally, it provides examples and scenarios related to database design and integrity constraints.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Chapter 8 12th computer (1)

The document covers various database concepts, including definitions of key terms, the role of foreign keys, and the differences between primary and foreign keys. It also discusses the structure of database relations, constraints, and the importance of avoiding redundancy in data management. Additionally, it provides examples and scenarios related to database design and integrity constraints.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 14

Chapter 8

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)

Differentiate between database state and database schema.


Answer
Database state Database schema

The database schema defines the


The data stored in database at a
design, structure, and organization of the
particular moment of time (i.e., the
database, serving as the blueprint or
state of the database at a particular
skeleton that determines how data is
instance of time) is called database
organized and related within the
state or instance of database.
database.

Question 3(b)

Differentiate between primary key and foreign key.


Answer

Primary Key Foreign Key

Primary Key is a column or A foreign key is an attribute whose value is


group of columns in a table that derived from the primary key of another table.
uniquely identify every row in A foreign key is used to represent the
that table. relationship between two tables.

Primary key cannot have Null


Foreign key can have Null values.
values.

There can be only one primary


Multiple foreign keys can exist in a table.
key in a table.

It is used to enforce entity It is used to enforce referential integrity and


integrity and ensure data maintain data consistency across related
uniqueness. tables.

Question 3(c)

Differentiate between degree and cardinality of a relation.


Answer

Degree of a relation Cardinality of a relation

The number of attributes in a relation is The number of tuples in a relation is


called the Degree of the relation. called the Cardinality of the relation.
Degree of a relation Cardinality of a relation

For example, if a relation has attributes For example, if a relation contains 10


like Name, Age, and Address, then its records or tuples, then its cardinality
degree is 3. is 10.

Question 4

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


redundancy in data through a database?
Answer
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.

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

1. 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.
2. 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.
3. No, since no student has selected Kabaddi as their preferred sport, there should
not be an entry for Kabaddi in the Sports Preferences table.

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

Are the states of both the relations equivalent? Justify.


Answer
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.

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:

1. The same bill cannot be generated for different orders.


2. 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?
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

Attributes Datatype Constraints

ItemNo Integer Primary Key, Unique, non-null value

ItemName VARCHAR Non-null value

Price Float Non-null value

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

Attributes Datatype Constraints

orderno integer Primary Key Unique, Non-null value

ItemNo integer Foreign key,Unique, Non-null value

Quantity integer Non-null value


Attributes Datatype Constraints

Price Float Non-null value

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.
(c) 'Calories' should be stored in the "Items" table because they are directly associated
with specific items.

Question 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.
(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.
(c) What is the degree of EMPLOYEE and DEPENDENT relation?
Answer
(a) 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 EMPLOYEE and DEPENDENT tables are linked using the EmployeeID key,
which is utilized to retrieve details of dependents associated with a specific employee.
(c) 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.

Question 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.
School Uniform Database
Attributes and Constraints
Table: UNIFORM
Attribute UCode UName UColor

Constraints Primary Key Not Null -

Table: COST

Attribute UCode Size Price

Constraints Composite Primary Key >0

Table: UNIFORM

UCode UName UColor

1 Shirt White

2 Pant Grey

3 Skirt Grey

4 Tie Blue

5 Socks Blue

6 Belt Blue

Table: COST

UCode Size COST Price

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

For the below given database STUDENT-PROJECT, answer the following:


(a) Name primary key of each table.
(b) Find foreign key(s) in table PROJECT-ASSIGNED.
(c) Is there any alternate key in table STUDENT? Give justification for your answer.
(d) Can a user assign duplicate value to the field RollNo of STUDENT table? Justify.
Student Project Database
Table: STUDENT

Roll No Name Class Section Registration_ID

11 Mohan XI 1 IP-101-15

12 Sohan XI 2 IP-104-15

21 John XII 1 CS-103-14

22 Meena XII 2 CS-101-14

23 Juhi XII 2 CS-101-10

Table: PROJECT

ProjectNo PName SubmissionDate

101 Airline Database 12/01/2018

102 Library Database 12/01/2018

103 Employee Database 15/01/2018

104 Student Database 12/01/2018

105 Inventory Database 15/01/2018

106 Railway Database 15/01/2018

Table: PROJECT ASSIGNED

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

Roll No Name Class Section Registration_ID

11 Mohan XI 1 IP-101-15

12 Sohan XI 2 IP-104-15

21 John XII 1 CS-103-14


Roll No Name Class Section Registration_ID

22 Meena XII 2 CS-101-14

23 Juhi XII 2 CS-101-10

Table: PROJECT

ProjectNo PName SubmissionDate

101 Airline Database 12/01/2018

102 Library Database 12/01/2018

103 Employee Database 15/01/2018

104 Student Database 12/01/2018

105 Inventory Database 15/01/2018

106 Railway Database 15/01/2018

Table: PROJECT ASSIGNED

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.

You might also like