DBMS Lab Manual Program
DBMS Lab Manual Program
PEO1 Be successful in solving engineering problems associated with computer science and
engineering domains.
PEO3 Communicate effectively and exhibit leadership qualities, team spirit necessary for a
successful career in either industry, research or entrepreneurship.
PEO4 Continue to learn and advance their career through participation in the activities of
professional bodies, obtaining professional certification, pursue of higher education.
PSO1 Apply software engineering practices and strategies in diversified areas of computer
science for solving problems using open source environment.
PSO2 Develop suitable algorithms and codes for applications in areas of cognitive technology,
computer networks with software engineering principles and practices.
Program Outcomes
Course Overview
Course Outcomes
COs Description
21CSL55. Demonstrate the Basics Concepts and SQL Queries of Database Management System.
1
21CSL55. Apply the Conceptual Design Model and Database Hierarchical Structure to construct the
2 real-world requirement.
21CSL55. Analyze the various constraints to populate the database through SQL Queries.
3
21CSL55. Implement different working concepts of DBMS using SQL Queries.
4
21CSL55. Present the result of database creation and querying process, document it.
5
Syllabus
Introduction to SQL
SQL stands for “Structured Query Language” and can be pronounced as “SQL” or
“sequel – (Structured English Query Language)”. It is a query language used for accessing and
modifying information in the database. IBM first developed SQL in 1970s. Also it is an
ANSI/ISO standard. It has become a Standard Universal Language used by most of the relational
database management systems (RDBMS). Some of the RDBMS systems are: Oracle, Microsoft
SQL server, Sybase etc. Most of these have provided their own implementation thus enhancing
its feature and making it a powerful tool. Few of the SQL commands used in SQL programming
are SELECT Statement, UPDATE Statement, INSERT INTO Statement, DELETE Statement,
WHERE Clause, ORDER BY Clause, GROUP BY Clause, ORDER Clause, Joins, Views,
GROUP Functions, Indexes etc.
SQL Commands
SQL commands are instructions used to communicate with the database to perform
specific task that work with data. SQL commands can be used not only for searching the
database but also to perform various other functions like, for example, you can create tables, add
data to tables, or modify data, drop the table, set permissions for users.
CREATE TABLE
table_name
(column_name1 datatype constraint,
column_name2 datatype,...
column_nameNdatatyp
e);
SQL Data Types:
column_name2,..)
referenced_table_name(column_name)
4) Unique Key:
This constraint ensures that a column or a group of columns in each row have a distinct value.
A column(s) can have a null value but the values cannot be duplicated.
Syntax to define a Unique key at column level:
[CONSTRAINT constraint_name] UNIQUE
5) Check Constraint:
This constraint defines a business rule on a column. All the rows must satisfy this rule. The
constraint can be applied for a single column or a group of columns.
DELETE
Commit command
Rollback command
This command restores the database to last commited state. It is also use with savepoint command to
jump to a savepoint in a transaction.
Savepoint command
savepoint command is used to temporarily save a transaction so that you can rollback to that point
whenever necessary.
LAB EXPERIMENTS
Solution:
Entity-Relationship Diagram
Author_Name
Book_id Title
Pub_YearM N
written-by
Book Book_Authors
N
Has
N No_of_copies
Branch_id
Published-by
Publisher_Name
M M N
1 In
Branch_Name
Book_Copies Library_Branch
Address
N Address
Publisher Date_out
Book_Lending
Phone
Card_No
Due_date
N
Card
PROGRAM
>create table Publisher(Name varchar(20) primary key, Address varchar(50) not null,phone
varchar(10));
>desc Publisher;
+---------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+---------+-------------+------+-----+---------+-------+
| Name | varchar(20) | NO | PRI | NULL | |
| Address | varchar(50) | NO | | NULL | |
| phone | varchar(10) | YES | | NULL | |
+---------+-------------+------+-----+---------+-------+
> select
B.Book_Id,B.Title,B.Publisher_Name,A.Author_Name,C.Num_of_Copies,C.Branch_Id
-> from Book B,Book_Author A, Book_Copies C where B.Book_Id=A.Book_Id and
B.Book_Id=C.Book_Id;
+---------+-------------------+----------------+---------------+---------------
+-----------+
| Book_Id | Title | Publisher_Name | Author_Name | Num_of_Copies |
Branch_Id |
+---------+-------------------+----------------+---------------+---------------
+-----------+
| 2001 | DBMS | Pearson | Kanishka Bedi | 10 |
3001 |
| 2002 | Computer Networks | Oxford | Poornima M | 15 |
3002 |
| 2003 | Java | Mc Graw Hill | P C Tripathi | 10 |
3003 |
| 2004 | C Programming | O_Reilly | P N Reddy | 5 |
3004 |
| 2005 | PHP | Dreamtech | Vishwa Kiran | 20 |
3005 |
+---------+-------------------+----------------+---------------+---------------
+-----------+
+----------+
| pub_year |
+----------+
| 2015 |
| 2019 |
| 2016 |
| 2017 |
+----------+
5. Create a view of all books and its number of copies that are currently
available in the Library.
Solution:
Entity-Relationship Diagram
Program CREATE DATABASE
TABLE CREATION:
SALESMAN:
> create table SALESMAN(Salesman_id int primary key, Name varchar(20), City
varchar(50), Commission int);
CUSTOMER:
> create table CUSTOMER(Customer_id int primary key, Cust_Name varchar(20) not
null, City varchar(20),Grade int, Salesman_id int,
-> foreign key(Salesman_id) references SALESMAN(Salesman_id) on delete set null);
ORDERS:
SALESMAN:
+-------------+---------+----------+------------+
| Salesman_id | Name | City | Commission |
+-------------+---------+----------+------------+
| 1000 | Vinay | Banglore | 25 |
| 2000 | Ravi | Banglore | 20 |
| 3000 | Pavan | Mysore | 15 |
| 4000 | Smith | Delhi | 30 |
| 5000 | Mythili | Manglore | 15 |
+-------------+---------+----------+------------+
CUSTOMER:
+-------------+-----------+----------+-------+-------------+
| Customer_id | Cust_Name | City | Grade | Salesman_id |
+-------------+-----------+----------+-------+-------------+
| 11 | Preethi | Udupi | 100 | 1000 |
| 22 | Poojavan | Banglore | 200 | 1000 |
| 33 | Hemanth | Banglore | 300 | 2000 |
| 44 | Chethan | Mandya | 200 | 3000 |
| 55 | Savitha | Banglore | 400 | 4000 |
+-------------+-----------+----------+-------+-------------+
ORDERS:
SQL QUERIES:
+--------------------+-------+-------------+
| count(Customer_id) | Grade | Customer_id |
+--------------------+-------+-------------+
| 1 | 400 | 55 |
+--------------------+-------+-------------+
2. Find the name and numbers of all salesman who had more than one customer.
+-------+--------------------+
| Name | count(Customer_id) |
+-------+--------------------+
| Vinay | 2 |
+-------+--------------------+
3. List all the salesman and indicate those who have and don’t have customers in
their cities (Use UNION operation.)
+-------------+---------+-----------+------------+
| Salesman_id | Name | Cust_Name | Commission |
+-------------+---------+-----------+------------+
| 1000 | Vinay | Savitha | 25 |
| 1000 | Vinay | Poojavan | 25 |
| 1000 | Vinay | Hemanth | 25 |
| 4000 | Smith | no match | 30 |
| 2000 | Ravi | Poojavan | 20 |
| 2000 | Ravi | Hemanth | 20 |
| 2000 | Ravi | Savitha | 20 |
| 3000 | Pavan | no match | 15 |
| 5000 | Mythili | no match | 15 |
+-------------+---------+-----------+------------+
4. Create a view that finds the salesman who has the customer with the highest
order of a day.
+------------+-------------+-------+
| Ord_Date | Salesman_id | Name |
+------------+-------------+-------+
| 2017-05-04 | 1000 | Vinay |
| 2017-01-20 | 2000 | Ravi |
| 2017-02-24 | 3000 | Pavan |
| 2017-04-13 | 2000 | Ravi |
| 2017-03-09 | 2000 | Ravi |
+------------+-------------+-------+
5. Demonstrate the DELETE operation by removing salesman with id 1000. All his
orders must also be deleted.
+--------+--------------+------------+-------------+-------------+
| Ord_No | Purchase_Amt | Ord_Date | Customer_id | Salesman_id |
+--------+--------------+------------+-------------+-------------+
| 92 | 540 | 2017-01-20 | 11 | 2000 |
| 93 | 8999 | 2017-02-24 | 33 | 3000 |
| 94 | 1500 | 2017-04-13 | 44 | 2000 |
| 95 | 599 | 2017-03-09 | 22 | 2000 |
+--------+--------------+------------+-------------+-------------+
Solution:
Entity-Relationship Diagram
Dir_id Dir_Name
Act_id Act_Name
Dir_Phone
Act_Gender Actor Director
1
M
Has
Movie_Cast
N
Role
Rev_Stars
N
Movies
Mov_Lang
Mov_id
Mov_Title Mov_Year
CREATE DATABASE:
TABLE CREATION:
ACTOR:
+------------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+------------+-------------+------+-----+---------+-------+
| act_id | int(11) | NO | PRI | NULL | |
| act_name | varchar(20) | YES | | NULL | |
| act_gender | char(8) | YES | | NULL | |
+------------+-------------+------+-----+---------+-------+
DIRECTOR:
+-----------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-----------+-------------+------+-----+---------+-------+
| dir_id | int(11) | NO | PRI | NULL | |
| dir_name | varchar(20) | YES | | NULL | |
| dir_phone | varchar(10) | YES | | NULL | |
+-----------+-------------+------+-----+---------+-------+
MOVIES:
+-----------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-----------+-------------+------+-----+---------+-------+
| mov_id | int(11) | NO | PRI | NULL | |
| mov_title | varchar(20) | YES | | NULL | |
| mov_year | int(11) | YES | | NULL | |
| mov_lang | varchar(15) | YES | | NULL | |
| dir_id | int(11) | YES | MUL | NULL | |
+-----------+-------------+------+-----+---------+-------+
MOVIE_CAST:
> create table MOVIE_CAST(act_id int,mov_id int,role varchar(20),
-> primary key(act_id,mov_id),
-> foreign key(act_id) references ACTOR(act_id),
-> foreign key(mov_id) references MOVIES(mov_id));
+--------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+--------+-------------+------+-----+---------+-------+
| act_id | int(11) | NO | PRI | NULL | |
| mov_id | int(11) | NO | PRI | NULL | |
| role | varchar(20) | YES | | NULL | |
+--------+-------------+------+-----+---------+-------+
RATING:
+-----------+---------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-----------+---------+------+-----+---------+-------+
| mov_id | int(11) | NO | PRI | NULL | |
| rev_stars | int(11) | YES | | NULL | |
+-----------+---------+------+-----+---------+-------+
ACTOR:
+--------+------------+------------+
| act_id | act_name | act_gender |
+--------+------------+------------+
| 31 | Anushka | F |
| 32 | Ajith | M |
| 33 | Keerthi | F |
| 34 | James | M |
| 35 | Jackiechan | M |
| 36 | Jeremy | M |
+--------+------------+------------+
DIRECTOR:
+--------+------------------+------------+
| dir_id | dir_name | dir_phone |
+--------+------------------+------------+
| 51 | Hitchcock | 9966553322 |
| 52 | Herald | 9988556611 |
| 53 | Rajamouli | 9977558833 |
| 54 | Kishore | 8877995566 |
| 55 | samMendes | 7979808066 |
| 56 | venkat | 7975797588 |
| 57 | steven speilberg | 9900114455 |
+--------+------------------+------------+
MOVIES:
+--------+-------------+----------+----------+--------+
| mov_id | mov_title | mov_year | mov_lang | dir_id |
+--------+-------------+----------+----------+--------+
| 11 | Skyfall | 2012 | English | 55 |
| 12 | NenuShilaja | 2016 | Telugu | 54 |
| 13 | KarateKid | 2010 | English | 52 |
| 14 | Bahubali | 2017 | Telugu | 53 |
| 15 | TheBirds | 1963 | English | 51 |
| 16 | Gambler | 2011 | Tamil | 56 |
| 17 | WarHouse | 2011 | English | 57 |
| 18 | Physco | 1975 | English | 51 |
+--------+-------------+----------+----------+--------+
MOVIE_CAST:
+--------+--------+---------+
| act_id | mov_id | role |
+--------+--------+---------+
| 31 | 14 | Heroine |
| 32 | 16 | Villain |
| 33 | 12 | Heroine |
| 34 | 11 | Hero |
| 34 | 15 | Hero |
| 35 | 13 | Hero |
| 36 | 17 | Hero |
+--------+--------+---------+
RATING:
+--------+-----------+
| mov_id | rev_stars |
+--------+-----------+
| 11 | 4 |
| 12 | 5 |
| 13 | 4 |
| 14 | 4 |
| 15 | 3 |
| 16 | 3 |
| 17 | 4 |
+--------+-----------+
+-----------+
| mov_title |
+-----------+
| TheBirds |
| Physco |
+-----------+
2. Find the movie names where one or more actors acted in two or more movies.
3. List all actors who acted in a movie before 2000 and also in a movie after 2015
(use JOIN
operation).
4. Find the title of movies and number of stars for each movie that has at least one
rating and
find the highest number of stars that movie received. Sort the result by movie title.
Lab Program:4
CREATE DATABASE:
TABLE CREATION:
STUDENT:
SEMSEC:
CLASS:
SUBJECT:
IAMARKS:
STUDENT:
SEMSEC;
CLASS:
SUBJECT:
IAMARKS:
1. List all the student details studying in fourth semester ‘C’ section.
2. Compute the total number of male and female students in each semester
and in each
section.
Changed: 15 Warnings: 0
Entity-Relationship Diagram
SSN Controlled_by
Name N 1
DNO
Salary
DName
1 N
Manages
Employee Department
Address
MgrStartDate
1
Sex 1
N
M Dlocation
Supervisee
N
Hours
PName
Project
PNO PLocation
Lab Program: 5
CREATE DATABASE:
TABLE CREATION:
DEPARTMENT:
desc DEPARTMENT;
+----------------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+----------------+-------------+------+-----+---------+-------+
| DNo | int(11) | NO | PRI | NULL | |
| DName | varchar(20) | YES | | NULL | |
| Mgr_start_date | date | YES | | NULL | |
+----------------+-------------+------+-----+---------+-------+
EMPLOYEE:
desc EMPLOYEE;
+----------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+----------+-------------+------+-----+---------+-------+
| SSN | varchar(10) | NO | PRI | NULL | |
| FName | varchar(20) | YES | | NULL | |
| LName | varchar(20) | YES | | NULL | |
| Address | varchar(20) | YES | | NULL | |
| Sex | varchar(3) | YES | | NULL | |
| Salary | int(11) | YES | | NULL | |
| SuperSSN | varchar(10) | YES | MUL | NULL | |
| DNo | int(11) | YES | MUL | NULL | |
+----------+-------------+------+-----+---------+-------+
After creating DEPARTMENT and EMPLOYEE tables, we must alter department
table to add foreign constraint MGRSSN using sql command.
desc DEPARTMENT;
+----------------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+----------------+-------------+------+-----+---------+-------+
| DNo | int(11) | NO | PRI | NULL | |
| DName | varchar(20) | YES | | NULL | |
| Mgr_start_date | date | YES | | NULL | |
| Mgr_SSN | varchar(10) | YES | | NULL | |
+----------------+-------------+------+-----+---------+-------+
desc DEPARTMENT;
+----------------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+----------------+-------------+------+-----+---------+-------+
| DNo | int(11) | NO | PRI | NULL | |
| DName | varchar(20) | YES | | NULL | |
| Mgr_start_date | date | YES | | NULL | |
| Mgr_SSN | varchar(10) | YES | MUL | NULL | |
+----------------+-------------+------+-----+---------+-------+
DLOCATION:
desc DLOCATION;
+-------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+-------------+------+-----+---------+-------+
| DLoc | varchar(20) | NO | PRI | NULL | |
| DNo | int(11) | NO | PRI | NULL | |
+-------+-------------+------+-----+---------+-------+
PROJECT:
WORKS_ON
desc WORKS_ON;
+-------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+-------------+------+-----+---------+-------+
| SSN | varchar(10) | NO | PRI | NULL | |
| PNo | int(11) | NO | PRI | NULL | |
| Hours | int(11) | YES | | NULL | |
+-------+-------------+------+-----+---------+-------+
EMPLOYEE:
DEPARTMENT:
DLOCATION:
PROJECT:
WORKS_ON:
1. Make a list of all project numbers for projects that involve an employee whose
last name is
‘Scott’, either as a worker or as a manager of the department that controls the
project.
+-----+
| PNo |
+-----+
| 100 |
+-----+
2. Show the resulting salaries if every employee working on the ‘IoT’ project is
given a 10
percent raise.
3. Find the sum of the salaries of all employees of the ‘Accounts’ department, as well as
the
maximum salary, the minimum salary, and the average salary in this department.
4. Retrieve the name of each employee who works on all the projects controlled by
department
number 5 (use NOT EXISTS operator).
5. For each department that has more than five employees, retrieve the department number
and the number of its employees who are making more than Rs. 6, 00,000.
1. What is SQL?
Structured Query Language
2. What is database?
A database is a logically coherent collection of data with some inherent meaning, representing some
aspect of real world and which is designed, built and populated with data for a specific purpose.
3. What is DBMS?
It is a collection of programs that enables user to create and maintain a database. In other words it
is general-purpose software that provides the users with the processes of defining, constructing and
manipulating the database for various applications.
4. What is a Database system?
The database and DBMS software together is called as Database system.
5. Advantages of DBMS?
Redundancy is controlled.
Unauthorized access is restricted.
Providing multiple user interfaces.
Enforcing integrity constraints.
Providing backup and recovery.
6. Disadvantage in File Processing System?
Data redundancy & inconsistency.
Difficult in accessing data.
Data isolation.
Data integrity.
Concurrent access is not possible.
Security Problems.
7. Describe the three levels of data abstraction?
There are three levels of abstraction:
Physical level: The lowest level of abstraction describes how data are stored.
Logical level: The next higher level of abstraction, describes what data are stored in
database and what relationship among those data.
View level:The highest level of abstraction describes only part of entire database.
8. Define the "integrity rules"
There are two Integrity rules.
Entity Integrity:States that ―Primary key cannot have NULLvalue‖
Referential Integrity:States that ―Foreign Key can be either a NULL value or should be
Primary Key value of other relation.
9. What is extension and intension?
Extension - It is the number of tuples present in a table at any instance. This is time dependent.
Intension -It is a constant value that gives the name, structure of table and the constraints laid on
it.
10. What is Data Independence?
Data independence means that ―the application is independent of the storage structure and
access strategy of data‖. In other words, The ability to modify the schema definition in one level should
not affect the schema definition in the next higher level.
Two types of Data Independence:
Physical Data Independence: Modification in physical level should not affect the logical level.
Logical Data Independence: Modification in logical level should affect the view level.
NOTE: Logical Data Independence is more difficult to achieve
11. What is a view? How it is related to data independence?
A view may be thought of as a virtual table, that is, a table that does not really exist in its own
right but is instead derived from one or more underlying base table. In other words, there is no stored file
that direct represents the view instead a definition of view is stored in data dictionary.
Growth and restructuring of base tables is not reflected in views. Thus the view can insulate users
from the effects of restructuring and growth in the database. Hence accounts for logical data
independence.
12. What is Data Model?
A collection of conceptual tools for describing data, data relationships data semantics and
constraints.
13. What is E-R model?
This data model is based on real world that consists of basic objects called entities and of
relationship among these objects. Entities are described in a database by a set of attributes.
14. What is Object Oriented model?
This model is based on collection of objects. An object contains values stored in instance
variables within the object. An object also contains bodies of code that operate on the object. These
bodies of code are called methods. Objects that contain same types of values and the same methods are
grouped together into classes.
15. What is an Entity?
It is an 'object' in the real world with an independent existence.
16. What is an Entity type?
It is a collection (set) of entities that have same attributes.
17. What is an Entity set?
It is a collection of all entities of particular entity type in the database.
18. What is an Extension of entity type?
The collections of entities of a particular entity type are grouped together into an entity set.
19. What is an attribute?
It is a particular property, which describes the entity.
20. What is a Relation Schema and a Relation?
A relation Schema denoted by R(A1, A2, …, An) is made up ofthe relation name
R and the list of attributes Ai that it contains. A relation is defined as a set of tuples. Let r
be the relation which contains set tuples (t1, t2, t3, ...,tn). Each tuple is an ordered list of n- values
t=(v1,v2, ..., vn).
21. What is degree of a Relation?
It is the number of attribute of its relation schema.
22. What is Relationship?
It is an association among two or more entities.
23. What is Relationship set?
The collection (or set) of similar relationships.
24. What is Relationship type?
Relationship type defines a set of associations or a relationship set among a given set of
entity types.
25. What is degree of Relationship type?
It is the number of entity type participating.
26. What is DDL (Data Definition Language)?
A data base schema is specified by a set of definitions expressed by a special
language called DDL.
27. What is VDL (View Definition Language)?
It specifies user views and their mappings to the conceptual schema.
28. What is SDL (Storage Definition Language)?
This language is to specify the internal schema. This language may specify the
mapping between two schemas.
29. What is Data Storage - Definition Language?
The storage structures and access methods used by database system are specified by a
set of definition in a special type of DDL called data storage- definition language.
30. What is DML (Data Manipulation Language)?
This language that enable user to access or manipulate data as organized by appropriate data
model.
Procedural DML or Low level: DML requires a user to specify what data are needed and how to get
those data.
Non-Procedural DML or High level: DML requires a user to specify what data are needed
without specifying how to get those data.
31. What is DML Compiler?
It translates DML statements in a query language into low-level instruction that the
query evaluation engine can understand.
32. What is Relational Algebra?
It is a procedural query language. It consists of a set of operations that take one or
two relations as input and produce a new relation.
33. What is Relational Calculus?
It is an applied predicate calculus specifically tailored for relational databases
proposed by E.F. Codd. E.g. of languages based on it are DSL, ALPHA, QUEL.
34. What is normalization?
It is a process of analyzing the given relation schemas based on their Functional
Dependencies (FDs) and primary key to achieve the properties
Minimizing redundancy
Minimizing insertion, deletion and update anomalies.
35. What is Functional Dependency?
A Functional dependency is denoted by X Y between two sets of attributes X and Y that are
subsets of R specifies a constraint on the possible tuple that can form a relation state r of
R. The constraint is for any two tuples t1 and t2 in r if t1[X] = t2[X] then they have t1[Y] = t2[Y]. This
means the value of X component of a tuple uniquely determines the value of component Y.
36. When is a functional dependency F said to be minimal?
Every dependency in F has a single attribute for its right hand side.
We cannot replace any dependency X A in F with a dependency Y A where Y is a proper subset of X
and still have a set of dependency that is equivalent to F.
We cannot remove any dependency from F and still have set of dependency that is equivalent to F.
37. What is Multivalued dependency?
Multivalued dependency denoted by X Y specified on relation schema R, where X and Y are
both subsets of R, specifies the following constraint on any relation r of R: if two tuples t1 and t2 exist in
r such that t1[X] = t2[X] then t3 and t4 should also exist in r with the following properties
t3[x] = t4[X] = t1[X] = t2[X]
t3[Y] = t1[Y] and t4[Y] = t2[Y]
t3[Z] = t2[Z] and t4[Z] = t1[Z]
where [Z = (R-(X U Y)) ]
38. What is Lossless join property?
It guarantees that the spurious tuple generation does not occur with respect to relation schemas
after decomposition.
39. What is 1 NF (Normal Form)?
The domain of attribute must include only atomic (simple, indivisible) values.
40. What is Fully Functional dependency?
It is based on concept of full functional dependency. A functional dependency X Y is fully
functional dependency if removal of any attribute A from X means that the dependency does not hold any
more.
41. What is 2NF?
A relation schema R is in 2NF if it is in 1NF and every non-prime attribute A in R is fully
functionally dependent on primary key.
42. What is 3NF?
A relation schema R is in 3NF if it is in 2NF and for every FD X A either of the following is true
X is a Super-key of R.
A is a prime attribute of R.
In other words, if every non prime attribute is non-transitively dependent on primary key.
43. What is BCNF (Boyce-Codd Normal Form)?
A relation schema R is in BCNF if it is in 3NF and satisfies additional constraints that for
every FD X A, X must be a candidate key.
44. What is 4NF?
A relation schema R is said to be in 4NF if for every Multivalued dependency X Y
that holds over R, one of following is true
X is subset or equal to (or) XY = R.
X is a super key.
45. What is 5NF?
A Relation schema R is said to be 5NF if for every join dependency {R1, R2, ...,Rn} that
holds R, one the following is true
Ri = R for some i.
The join dependency is implied by the set of FD, over R in which the left side is key of R.
46. What is meant by query optimization?
The phase that identifies an efficient execution plan for evaluating a query that has the least
estimated cost is referred to as query optimization.
23. What is the use of the DROP option in the ALTER TABLE command?
It is used to drop constraints specified on the table.
24.What is the value of ‘comm’ and ‘sal’ after executing the following query if the
initial value of ‘sal’ is 10000?
UPDATE EMP SET SAL = SAL + 1000, COMM = SAL*0.1;
sal = 11000, comm = 1000
25. What is the use of CASCADE CONSTRAINTS?
When this clause is used with the DROP command, a parent table can be dropped
even when a child table exists.