Dbms Question Bank
Dbms Question Bank
SQL is the standard language for Relation Database System. All relational database
management systems like MySQL, MS Access, Oracle, Sybase, Informix, postgres and
SQL Server use SQL asstandard database language.
➢ Allows users to define the data in database and manipulate that data.
➢ Allows to embed within other languages using SQL modules, libraries & pre-
compilers.
❖ CREATE
It is used to create a new table in the database.
Syntax:
CREATE TABLE TABLE_NAME (COLUMN_NAME DATATYPES[,....]);
INTYRODUCTION TO DBMS (DBMS) (03606207)
Example:
CREATE TABLE EMPLOYEE
(Name VARCHAR2(20), Email VARCHAR2(100), DOB DATE);
❖ DROP TABLE
It is used to delete both the structure and record stored in the table.
Syntax:
DROP TABLE table_name;
Example:
DROP TABLE EMPLOYEE;
❖ ALTER TABLE
It is used to alter the structure of the database.
This change could be either to modify the characteristics of an existing
attribute or probably to add a new attribute.
Syntax:
To add a new column in the table
ALTER TABLE table_name ADD column_name COLUMN-definition;
To modify existing column in the table:
ALTER TABLE table_name MODIFY(column_definitions....);
Example:
ALTER TABLE STU_DETAILS ADD(ADDRESS VARCHAR2(20));
ALTER TABLE STU_DETAILS MODIFY (NAME VARCHAR2(20));
❖ TRUNCATE TABLE
It is used to delete all the rows from the table and free the space containing the table.
Syntax:
TRUNCATE TABLE table_name;
Example:
TRUNCATE TABLE EMPLOYEE
DML commands are used to modify the database. It is responsible for all form of
changes in the database.
The command of DML is not auto-committed that means it can't permanently save all
the changes in the database. They can be rollback.
❖ INSERT TABLE
The INSERT statement is a SQL query. It is used to insert data into the row of a table.
Syntax:
INSERT INTO TABLE_NAME
PIET DS
INTYRODUCTION TO DBMS (DBMS) (03606207)
Example:
❖ UPDATE TABLE
This command is used to update or modify the value of a column in the table.
Syntax:
UPDATE table_name SET [column_name1= value1,...column_nameN = valueN] [
WHERE CONDITION]
Example:
UPDATE students
SET User_Name = 'Sonoo'
WHERE Student_Id = '3'
❖ DELETE TABLE
It is used to remove one or more row from a table.
Syntax:
DELETE FROM table_name [WHERE condition];
Example:
DELETE FROM javatpoint
WHERE Author="Sonoo";
❖ GRANT
It is used to give user access privileges to a database.
Example:
❖ REVOKE
It is used to take back permissions from the user.
Example:
REVOKE SELECT, UPDATE ON MY_TABLE FROM USER1, USER2;
13) Explain TCL commands with example. .[2 MARKS PER EACH
COMMAND]
PIET DS
INTYRODUCTION TO DBMS (DBMS) (03606207)
TCL commands can only use with DML commands like INSERT, DELETE and
UPDATE only.
These operations are automatically committed in the database that's why they cannot
be used while creating tables or dropping them.
❖ COMMIT
Commit command is used to save all the transactions to the database.
Syntax:
COMMIT;
Example:
DELETE FROM CUSTOMERS
WHERE AGE = 25;
COMMIT;
❖ ROLLBACK
Rollback command is used to undo transactions that have not already been saved to the
database.
Syntax:
ROLLBACK;
Example:
DELETE FROM CUSTOMERS
WHERE AGE = 25;
ROLLBACK;
❖ SAVEPOINT
It is used to roll the transaction back to a certain point without rolling back the entire
transaction.
Syntax:
SAVEPOINT SAVEPOINT_NAME;
14) Explain DQL Select Query with Where clause. .[3 MARKS]
PIET DS
INTYRODUCTION TO DBMS (DBMS) (03606207)
PIET DS
UNIT-3-WORKING WITH SQL FUNCTIONS AND OPERATOR
PIET DS
DATABASE MANAGEMENT SYSTEM (DBMS) (03606207)
PIET DS
DATABASE MANAGEMENT SYSTEM (DBMS) (03606207)
The ORDER BY command sorts the result set in ascending order by default. To
sort the records in descending order, use the DESC keyword.
The following SQL statement selects all the columns from the "Customers"
table, sorted by the "CustomerName" column:
Example:
SELECT * FROM Customers
ORDER BY CustomerName;
ASC
The ASC command is used to sort the data returned in ascending order.
The following SQL statement selects all the columns from the "Customers"
table, sorted by the "CustomerName" column:
Example
SELECT * FROM Customers
ORDER BY CustomerName ASC;
DESC
The DESC command is used to sort the data returned in descending order.
The following SQL statement selects all the columns from the "Customers"
table, sorted descending by the "CustomerName" column:
Example
SELECT * FROM Customers
ORDER BY CustomerName DESC;
3. Explain Character functions with example. (3)
LOWER : This function converts alpha character values to lowercase.
LOWER will actually return a fixed-length string if the incoming string is fixed-
length.
LOWER will not change any characters in the string that are not letters, since
case is irrelevant for numbers and special characters, such as the dollar sign ( $ )
or modulus ( % ).
PIET DS
DATABASE MANAGEMENT SYSTEM (DBMS) (03606207)
Syntax:
LOWER(string)
Input1: SELECT LOWER('HELLO') FROM DUAL;
Output1: hello
UPPER : This function converts alpha character values to uppercase.
Also UPPER function too, will actually return a fixed-length string if the
incoming string is fixed-length. UPPER will not change any characters in the
string that are not letters, since case is irrelevant for numbers and special
characters, such as the dollar sign ( $ ) or modulus ( % ).
Syntax:
UPPER(string)
Input1: SELECT UPPER(' hello ') FROM DUAL;
Output1: HELLO
INITCAP : This function converts alpha character values to uppercase for
the first letter of each word and all others in lowercase.
The words in the string is must be separated by either # or _ or space.
Syntax:
INITCAP (string)
Input1: SELECT INITCAP ('web port is a computer science portal') FROM
DUAL;
Output1: Web Port Is A Computer Science Portal
PIET DS
DATABASE MANAGEMENT SYSTEM (DBMS) (03606207)
Output1: computerscience
LENGTH : This function returns the length of the input string.
If the input string is NULL, then LENGTH function returns NULL and not
Zero. Also, if the input string contains extra spaces at the start, or in between or
at the end of the string, then the LENGTH function includes the extra spaces too
and returns the complete length of the string.
Syntax:
LENGTH(Column|Expression)
Input1: SELECT LENGTH('Learning Is Fun') FROM DUAL;
Output1: 15
LPAD and RPAD : These functions return the strings padded to the left or
right ( as per the use ) ;
hence the “L” in “LPAD” and the “R” in “RPAD” ; to a specified length, and
with a specified pad string.
If the pad string is not specified, then the given string is padded on the left or
right ( as per the use ) with spaces.
Syntax:
LPAD(Column|Expression, n, 'String')
Syntax: RPAD(Column|Expression, n, 'String')
LPAD Input1: SELECT LPAD('100',5,'*') FROM DUAL;
LPAD Output1: **100
RPAD Input1: SELECT RPAD('5000',7,'*') FROM DUAL;
RPAD Output1: 5000***
TRIM : This function trims the string input from the start or end (or both).
If no string or char is specified to be trimmed from the string and there exists
some extra space at start or end of the string, then those extra spaces are trimmed
off.
Syntax:
TRIM(Leading|Trailing|Both, trim_character FROM trim_source)
PIET DS
DATABASE MANAGEMENT SYSTEM (DBMS) (03606207)
PIET DS
DATABASE MANAGEMENT SYSTEM (DBMS) (03606207)
FLOOR(): It returns the largest integer value that is less than or equal to a
number.
Syntax: SELECT FLOOR(25.75);
Output: 2
GREATEST(): It returns the greatest value in a list of expressions.
Syntax: SELECT GREATEST(30, 2, 36, 81, 125);
Output: 125
LEAST(): It returns the smallest value in a list of expressions.
Syntax: SELECT LEAST(30, 2, 36, 81, 125);
Output: 2
LN(): It returns the natural logarithm of a number.
Syntax: SELECT LN(2);
Output: 0.6931471805599453
MOD(): It returns the remainder of n divided by m.
Syntax: SELECT MOD(18, 4);
Output: 2
PI(): It returns the value of PI displayed with 6 decimal places.
Syntax: SELECT PI();
Output: 3.141593
POW(): It returns m raised to the nth power.
Syntax: SELECT POW(4, 2);
Output: 16
ROUND(): It returns a number rounded to a certain number of decimal
places.
Syntax: SELECT ROUND(5.553);
Output: 6
SIN(): It returns the sine of a number.
Syntax: SELECT SIN(2);
Output: 0.9092974268256817
PIET DS
DATABASE MANAGEMENT SYSTEM (DBMS) (03606207)
PIET DS
DATABASE MANAGEMENT SYSTEM (DBMS) (03606207)
EXAMPLE :
SELECT last_name, hire_date
FROM employees
WHERE hire_date = TO_DATE(’May 24, 1999’, ’fxMonth DD, YYYY’);
OUTPUT :
LASTNAME HIREDATE
Kumar 24-MAY-99
6. List Aggregate function and explain with example. (4)
Count():
Count(*): Returns total number of records .i.e 6.
Count(salary): Return number of Non Null values over the column salary. i.e 5.
Count(Distinct Salary): Return number of distinct Non Null values over the
column salary .i.e 4
Example:
Select count(total_sal) from employee;
Output: 5
Sum():
sum(salary): Sum all Non Null values of Column salary i.e., 310
sum(Distinct salary): Sum of all distinct Non-Null values i.e., 250.
Example:
Select sum(total_sal) from employee;
Output: 456000
Avg():
Avg(salary) = Sum(salary) / count(salary) = 310/5
Avg(Distinct salary) = sum(Distinct salary) / Count(Distinct Salary) = 250/4
Example:
Select avg(total_sal) from employee;
Output: 50.56
Min():
PIET DS
DATABASE MANAGEMENT SYSTEM (DBMS) (03606207)
Min(salary): Minimum value in the salary column except NULL i.e., 40.
Max(salary): Maximum value in the salary i.e., 80.
Example:
Select max(total_sal) from employee;
Output: 50000
Select min(total_sal) from employee;
Output: 20000
7. Explain types of joins with example. (4)
INNER JOIN
The INNER JOIN keyword selects all rows from both the tables as long as the
condition is satisfied.
This keyword will create the result-set by combining all rows from both the
tables where the condition satisfies i.e value of the common field will be the
same.
Syntax:
SELECT table1.column1,table1.column2,table2.column1,....
FROM table1
INNER JOIN table2
ON table1.matching_column = table2.matching_column;
Example Queries(INNER JOIN)
SELECT StudentCourse.COURSE_ID, [Link], [Link] FROM
Student
INNER JOIN StudentCourse
ON Student.ROLL_NO = StudentCourse.ROLL_NO;
PIET DS
DATABASE MANAGEMENT SYSTEM (DBMS) (03606207)
Output:
LEFT JOIN
This join returns all the rows of the table on the left side of the join and matches
rows for the table on the right side of the join.
For the rows for which there is no matching row on the right side, the result-set
will contain null. LEFT JOIN is also known as LEFT OUTER JOIN.
Syntax:
SELECT table1.column1,table1.column2,table2.column1,....
FROM table1
LEFT JOIN table2
ON table1.matching_column = table2.matching_column;
Example Queries(LEFT JOIN):
SELECT [Link],StudentCourse.COURSE_ID
FROM Student
LEFT JOIN StudentCourse
ON StudentCourse.ROLL_NO = Student.ROLL_NO;
Output:
PIET DS
DATABASE MANAGEMENT SYSTEM (DBMS) (03606207)
RIGHT JOIN
RIGHT JOIN is similar to LEFT JOIN. This join returns all the rows of the table
on the right side of the join and matching rows for the table on the left side of the
join.
For the rows for which there is no matching row on the left side, the result-set
will contain null. RIGHT JOIN is also known as RIGHT OUTER JOIN.
Syntax:
SELECT table1.column1,table1.column2,table2.column1,....
FROM table1
RIGHT JOIN table2
ON table1.matching_column = table2.matching_column;
Example Queries(RIGHT JOIN):
SELECT [Link],StudentCourse.COURSE_ID
FROM Student
RIGHT JOIN StudentCourse
ON StudentCourse.ROLL_NO = Student.ROLL_NO;
Output:
FULL JOIN
FULL JOIN creates the result-set by combining results of both LEFT JOIN and
RIGHT JOIN.
The result-set will contain all the rows from both tables. For the rows for which
there is no matching, the result-set will contain NULL values.
PIET DS
DATABASE MANAGEMENT SYSTEM (DBMS) (03606207)
Syntax:
SELECT table1.column1,table1.column2,table2.column1,....
FROM table1
FULL JOIN table2
ON table1.matching_column = table2.matching_column;
Example Queries(FULL JOIN):
SELECT [Link],StudentCourse.COURSE_ID
FROM Student
FULL JOIN StudentCourse
ON StudentCourse.ROLL_NO = Student.ROLL_NO;
Output:
PIET DS
DATABASE MANAGEMENT SYSTEM (DBMS) (03606207)
For example, the below query creates a table Student with the fields ID and
NAME as NOT NULL.
That is, we are bound to specify values for these two fields every time we wish
to insert a new row.
EXAMPLE:
CREATE TABLE Student
(
ID int(6) NOT NULL,
NAME varchar(10) NOT NULL,
ADDRESS varchar(20)
);
UNIQUE
This constraint helps to uniquely identify each row in the table. i.e. for a
particular column, all the rows should have unique values.
We can have more than one UNIQUE columns in a table.
For example, the below query creates a table Student where the field ID is
specified as UNIQUE. i.e, no two students can have the same ID. Unique
constraint in detail.
Example:
CREATE TABLE Student
(ID int(6) NOT NULL UNIQUE,
NAME varchar(10),
ADDRESS varchar(20)
);
PRIMARY KEY
Primary Key is a field which uniquely identifies each row in the table.
If a field in a table as primary key, then the field will not be able to contain
NULL values as well as all the rows should have unique values for this field.
PIET DS
DATABASE MANAGEMENT SYSTEM (DBMS) (03606207)
So, in other words we can say that this is combination of NOT NULL and
UNIQUE constraints.
A table can have only one field as primary key. Below query will create a table
named Student and specifies the field ID as primary key.
Example:
CREATE TABLE Student
(ID int(6) NOT NULL UNIQUE,
NAME varchar(10),
ADDRESS varchar(20),
PRIMARY KEY(ID)
);
FOREIGN KEY
Foreign Key is a field in a table which uniquely identifies each row of a another
table.
That is, this field points to primary key of another table. This usually creates a
kind of link between the tables.
Consider the two tables as shown below:
C_ID NAME ADDRESS
1 RAMESH DELHI
2 SURESH NOIDA
3 DHARMESH GURGAON
As we can see clearly that the field C_ID in Orders table is the primary key in
Customers table, i.e. it uniquely identifies each row in the Customers table.
Therefore, it is a Foreign Key in Orders table.
Query:
CREATE TABLE Orders
(O_ID int NOT NULL,
ORDER_NO int NOT NULL,
C_ID int,
PIET DS
DATABASE MANAGEMENT SYSTEM (DBMS) (03606207)
PIET DS
DATABASE MANAGEMENT SYSTEM (DBMS) (03606207)
PIET DS
UNIT-4- Introduction to various Data Model
Example:
➢ Student has attributes like name, age, roll number, and many more. To uniquely identify
the student, we use the primary key as a roll number as it is not repeated. Attributes can
also be subdivided into another set of attributes.
➢ There are five such types of attributes: Simple, Composite, Single-valued, Multi-valued,
and Derived attribute. One more attribute is their, i.e. Complex Attribute, this is the
rarely used attribute.
Simple attribute :
➢ An attribute that cannot be further subdivided into components is a simple attribute.
Example:
➢ The roll number of a student, the id number of an employee.
Composite attribute :
➢ An attribute that can be split into components is a composite attribute.
Example:
➢ The address can be further split into house number, street number, city, state, country,
and pin code, the name can also be split into first name middle name, and last name.
Single-valued attribute :
➢ The attribute which takes up only a single value for each entity instance is a single-
valued attribute.
Example:
➢ The age of a student.
Multi-valued attribute :
➢ The attribute which takes up more than a single value for each entity instance is a multi-
valued attribute.
INTYRODUCTION TO DBMS (DBMS) (03606207)
Example:
➢ Phone number of a student: Landline and mobile.
Derived attribute :
➢ An attribute that can be derived from other attributes is derived attributes.
Example:
➢ Total and average marks of a student.
Complex attribute :
➢ Those attributes, which can be formed by the nesting of composite and multi-valued
attributes, are called “Complex Attributes”. These attributes are rarely used in
DBMS(DataBase Management System). That’s why they are not so popular.
Example:
➢ Let us consider a person having multiple phone numbers, emails, and an address.
➢ Here, phone number and email are examples of multi-valued attributes and address is an
example of the composite attribute, because it can be divided into house number, street,
city, and state.
PIET DS
INTYRODUCTION TO DBMS (DBMS) (03606207)
➢ An entity set is a collection or set of all entities of a particular entity type at any point in
time. The type of all the entities should be the same.
Example :
➢ The collection of all the students from the student table at a particular instant of time is
an example of an entity set.
➢ The collection of all the employees from the employee table at a particular instant of time
is an example of an entity set.
26) What is relationship? Explain degree of relationship.[MARK-4]
Degree of Relationship
➢ In DBMS, a degree of relationship represents the number of entity types that associate in
a relationship.
For example:
➢ We have two entities, one is a student and the other is a bag and they are connected with
the primary key and foreign key. So, here we can see that the degree of relationship is 2
as 2 entities are associating in a relationship.
Types of degree
➢ Now, based on the number of linked entity types, we have 4 types of degrees of
relationships.
1) Unary
2) Binary
3) Ternary
4) N-ARY
Unary
➢ In this type of relationship, both the associating entity type are the same.
➢ So, we can say that unary relationships exist when both entity types are the same and we
call them the degree of relationship is 1. Or in other words, in a relation only one entity
set is participating then such type of relationship is known as a unary relationship.
Example:
➢ In a particular class, we have many students, there are monitors too. So, here class
monitors are also students. Thus, we can say that only students are participating here.
➢ So the degree of such type of relationship is 1.
PIET DS
INTYRODUCTION TO DBMS (DBMS) (03606207)
Binary (degree 2)
➢ In a Binary relationship, there are two types of entity associates. So, we can say that a
Binary relationship exists when there are two types of entity and we call them a degree of
relationship is 2.
➢ Or in other words, in a relation when two entity sets are participating then such type of
relationship is known as a binary relationship.
➢ This is the most used relationship and one can easily be converted into a relational table.
Example:
➢ We have two entity types ‘Student’ and ‘ID’ where each ‘Student’ has his ‘ID’. So, here
two entity types are associating we can say it is a binary relationship.
➢ Also, one ‘Student’ can have many ‘daughters’ but each ‘daughter’ should belong to only
one ‘father. We can say that it is a one-to-many binary relationship.
Ternary(degree 3)
➢ In the Ternary relationship, there are three types of entity associates. So, we can say that
a Ternary relationship exists when there are three types of entity and we call them a
degree of relationship is 3.
➢ Since the number of entities increases due to this, it becomes very complex to turn E-R
into a relational table. Now let’s understand with the examples.
Example:
➢ We have three entity types ‘Teacher’, ‘Course’, and ‘Class’. The relationship between
these entities is defined as the teacher teaching a particular course, also the teacher
teaches a particular class.
PIET DS
INTYRODUCTION TO DBMS (DBMS) (03606207)
➢ So, here three entity types are associating we can say it is a ternary relationship.
N-ARY (n degree)
➢ In the N-ary relationship, there are n types of entity that associates. So, we can say that
an N-ary relationship exists when there are n types of entities.
➢ There is one limitation of the N-ary relationship, as there are many entities so it is very
hard to convert into an entity, rational table.
➢ So, this is very uncommon, unlike binary which is very much popular.
Example:
➢ We have 5 entities Teacher, Class, Location, Salary, Course. So, here five entity types
are associating we can say an n-ary relationship is 5.
PIET DS
INTYRODUCTION TO DBMS (DBMS) (03606207)
Example:
➢ Each customer can purchase as many kinds of flyrods as they want (a constraint on
Purchased), but can have only one favorite flyrod/fly combination (a constraint on Fave-
Combo).
➢ A binary relationship set is a relationship set on two entity sets. Mapping cardinalities on
binary relationship sets are simplest.
➢ Consider a binary relationship set R on entity sets A and B. There are four possible
mapping cardinalities in this case:
One-to-one:
➢ An entity in A is related to at most one entity in B, and an entity in B is related to at
most one entity in A.
One-to-many:
➢ an entity in A is related to any number of entities in B, but an entity in B is related to at
most one entity in A.
Many-to-one:
➢ An entity in A is related to at most one entity in B, but an entity in B is related to any
number of entities in A
PIET DS
INTYRODUCTION TO DBMS (DBMS) (03606207)
Many-to-many:
➢ An entity in A is related to any number of entities in B, but an entity in B is related to any
number of entities in A.
Attribute
➢ An attribute describes the property of an entity. An attribute is represented as Oval
in an ER diagram. There are four types of attributes:
[Link] attribute
2. Composite attribute
3. Multivalued attribute
4. Derived attribute
1. Key attribute:
PIET DS
INTYRODUCTION TO DBMS (DBMS) (03606207)
➢ For example, student roll number can uniquely identify a student from a set of
students. Key attribute is represented by oval same as other attributes however
the text of key attribute is underlined.
2. Composite attribute:
3. Multivalued attribute:
PIET DS
INTYRODUCTION TO DBMS (DBMS) (03606207)
➢ For example – A person can have more than one phone numbers so the phone
number attribute is multivalued.
4. Derived attribute:
➢ A derived attribute is one whose value is dynamic and derived from another
attribute.
PIET DS
INTYRODUCTION TO DBMS (DBMS) (03606207)
PIET DS
UNIT-2- Functional Dependency and Normalization)
31) Explain various normal forms of DBMS.[3 MARKS PER EACH NF]
Ans: Normalization
NormalFor Description
m
A relation will be in 4NF if it is in Boyce Codd normal form and has no multi-
4NF
valued dependency.
INTYRODUCTION TO DBMS (DBMS) (03606207)
Each attribute must contain only a single value from its pre-defined domain.
❖ Second Normal Form
Before we learn about the second normal form, we need to understand the following −
• Prime attribute − An attribute, which is a part of the candidate-key, is known as a prime
attribute.
• Non-prime attribute − An attribute, which is not a part of the prime-key, is said to be a non-
prime attribute.
If we follow second normal form, then every non-prime attribute should be fully functionally
dependent on prime key attribute. That is, if X → A holds, then there should not be any proper
subset Y of X, for which Y → A also holds true.
PIET DS
INTYRODUCTION TO DBMS (DBMS) (03606207)
In Student_Project relation that the prime key attributes are Stu_ID and Proj_ID. According to the
rule, non-key attributes, i.e. Stu_Name and Proj_Name must be dependent upon both and not on
any of the prime key attribute individually. But we find that Stu_Name can be identified by Stu_ID
and Proj_Name can be identified by Proj_ID independently. This is called partial dependency,
which is not allowed in Second Normal Form.
broke the relation in two as depicted in the above picture. So there exists no partial
dependency.
❖ Third Normal Form
For a relation to be in Third Normal Form, it must be in Second Normal form and the following
must satisfy −
o X is a superkey or,
o A is prime attribute.
Find that in the above Student_detail relation, Stu_ID is the key and only prime key attribute.
We find that City can be identified by Stu_ID as well as Zip itself. Neither Zip is a superkey
nor is City a prime attribute. Additionally, Stu_ID → Zip → City, so there exists transitive
dependency.
To bring this relation into third normal form, we break the relation into two relations as
follows −
PIET DS
INTYRODUCTION TO DBMS (DBMS) (03606207)
Example:
roll_no name dept_name dept_building
42 abc CO A4
43 pqr IT A3
44 xyz CO A4
PIET DS
INTYRODUCTION TO DBMS (DBMS) (03606207)
45 xyz IT A3
46 mno EC B2
47 jkl ME B2
From the above table we can conclude some valid functional dependencies:
➢ roll_no→{name,dept_name,dept_building},→Here,roll_nocandeterminevaluesoff
ields name, dept_name and dept_building, hence a valid Functional dependency
➢ roll_no→dept_name,Since,roll_nocandeterminewholesetof{name,dept_name,dep
t_building}, it can determine its subset dept_name also.
➢ dept_name→dept_building,Dept_namecanidentifythedept_buildingaccurately,sin
cedepartments with different dept_name will also have a different dept_building
➢ Morevalidfunctionaldependencies:roll_no→name,{roll_no,name}⇢{dept_name,
dept_building}, etc.
➢ name → dept_name Students with the same name can have different dept_name,
hence thisis not a valid functional dependency.
➢ dept_building → dept_nameThere can be multiple departments in the same
building, Forexample, in the above table departments ME and EC are in the same
building B2, hencedept_building → dept_name is an invalid functional
dependency.
➢ More invalid functional dependencies: name → roll_no, {name, dept_name} →
roll_no,dept_building → roll_no, etc.
33) List and explain various Inference Rules. [3 MARKS PER EACH IR]
Ans:
PIET DS
INTYRODUCTION TO DBMS (DBMS) (03606207)
IfX⊇Ythen X→Y
Example:
1.X = {a, b, c, d, e}
2.Y = {a, b, c}
If X →Y then XZ→ YZ
Example:
In the transitive rule, if X determines Y and Y determine Z, then X must also determine Z.
Union rule says, if X determines Y and X determines Z, then X must also determine Y and Z.
If X →Y and X →Z then X→ YZ
Proof:
X → Y (given)
X → Z (given)
PIET DS
INTYRODUCTION TO DBMS (DBMS) (03606207)
Decomposition rule is also known as project rule. It is the reverse of union rule.
This Rule says, if X determines Y and Z, then X determines Y and X determines Z separately.
If X → YZ then X → Y and X→ Z
Proof:
X → YZ (given)
YZ → Y (using IR1Rule)
X → Y (using IR3on 1 and 2)
If X→ Y and YZ → W then XZ → W
Proof:
X → Y (given)
WY → Z (given)
WX → WY (using IR2on 1 by augmenting with W)
WX → Z (using IR3on 3 and 2)
PIET DS