Document 1
Document 1
Answer: DBMS, commonly known as Database Management System, is an application system whose
main purpose revolves around the data. This is a system that allows its user to store the data, define
it, retrieve it and update the information about the data inside the database.
Answer: In simple terms, Database is a collection of data in some organized way to facilitate its
user’s to easily access, manage and upload the data.
Q #3) Why is the use of DBMS recommended? Explain by listing some of its major advantages.
Answer: Normalization is the process of analyzing the relational schemas which are based on their
respective functional dependencies and the primary keys in order to fulfill certain properties.
Q #5) What are the different types of languages that are available in the DBMS?
Answer: Basically, there are 3 types of languages in the DBMS as mentioned below:
• DDL: DDL is Data Definition Language which is used to define the database and schema
structure by using some set of SQL Queries like CREATE, ALTER, TRUNCATE, DROP and
RENAME.
• DCL: DCL is Data Control Language which is used to control the access of the users inside the
database by using some set of SQL Queries like GRANT and REVOKE.
• DML: DML is Data Manipulation Language which is used to do some manipulations in the
database like Insertion, Deletion, etc. by using some set of SQL Queries like SELECT, INSERT,
DELETE and UPDATE.
Answer: Primary Key is used to uniquely identify the records in a database table while Foreign Key is
mainly used to link two or more tables together, as this is a particular field(s) in one of the database
tables which are the primary key of some other table.
Example: There are 2 tables – Employee and Department. Both have one common field/column as
‘ID’ where ID is the primary key of the Employee table while this is the foreign key for the
Department table.
Q #8) What are the main differences between Primary key and Unique Key?
• The main difference between the Primary key and Unique key is that the Primary key can
never have a null value while the Unique key may consist of null value.
• In each table, there can be only one primary key while there can be more than one unique
key in a table.
Answer: Sub-query is basically the query which is included inside some other query and can also be
called as an inner query which is found inside the outer query.
Q #10) What is the use of DROP command and what are the differences between DROP,
TRUNCATE and DELETE commands?
Answer: DROP command is a DDL command which is used to drop/delete the existing table,
database, index or view from the database.
The major difference between DROP, TRUNCATE and DELETE commands are:
DROP and TRUNCATE commands are the DDL commands which are used to delete tables from the
database and once the table gets deleted, all the privileges and indexes that are related to the table
also get deleted. These 2 operations cannot be rolled back and so should be used only when
necessary.
DELETE command, on the other hand, is a DML Command which is also used to delete rows from the
table and this can be rolled back.
Note: It is recommended to use the ‘WHERE’ clause along with the DELETE command else the
complete table will get deleted from the database.
Q #11) What is the main difference between UNION and UNION ALL?
Answer: UNION and UNION ALL are used to join the data from 2 or more tables but UNION removes
duplicate rows and picks the rows which are distinct after combining the data from the tables
whereas UNION ALL does not remove the duplicate rows, it just picks all the data from the tables.
• Atomicity: This is based on the concept of “either all or nothing” which basically means that
if any update occurs inside the database then that update should either be available to all
the others beyond user and application program or it should not be available to anyone
beyond the user and application program.
• Consistency: This ensures that the consistency is maintained in the database before or after
any transaction that takes place inside the database.
• Isolation: As the name itself suggests, this property states that each transaction that occurs
is in isolation with others i.e. a transaction which has started but not yet completed should
be in isolation with others so that the other transaction does not get impacted with this
transaction.
• Durability: This property states that the data should always be in a durable state i.e. any
data which is in the committed state should be available in the same state even if any failure
or restart occurs in the system.
Answer: A Subquery is also known as a nested query i.e. a query written inside some query. When a
Subquery is executed for each of the rows of the outer query then it is termed as a Correlated
Subquery.
SELECT * from EMP WHERE ‘RIYA’ IN (SELECT Name from DEPT WHERE
EMP.EMPID=DEPT.EMPID);
Here, the inner query is not executed for each of the rows of the outer query.
Answer:
Entity is an object, place or thing which has its independent existence in the real world and about
which data can be stored in a database. For Example, any person, book, etc.
Entity Type is a collection of entities that have the same attributes. For Example, the STUDENT table
contains rows in which each row is an entity holding the attributes like name, age, and id of the
students, hence STUDENT is an Entity Type which holds the entities having the same attributes.
Entity Set is a collection of entities of the same type. For Example, A collection of the employees of a
firm.
They include:
• Physical Level: This is the lowest level of the data abstraction which states how the data is
stored in the database.
• Logical Level: This is the next level of the data abstraction which states the type of the data
and the relationship among the data that is stored in the database.
• View Level: This is the highest level in the data abstraction which shows/states only a part of
the database.
Answer: There are 2 major integrity rules that exist in the DBMS.
They are:
• Entity Integrity: This states a very important rule that value of a Primary key can never have
a NULL value.
• Referential Integrity: This rule is related to the Foreign key which states that either the
value of a Foreign key is a NULL value or it should be the primary key of any other relation.
Answer: E-R model is known as an Entity-Relationship model in the DBMS which is based on the
concept of the Entities and the relationship that exists among these entities.
Answer: This is basically a constraint which is useful in describing the relationship among the
different attributes in a relation.
Example: If there is some relation ‘R1’ which has 2 attributes as Y and Z then the functional
dependency among these 2 attributes can be shown as Y->Z which states that Z is functionally
dependent on Y.
This is the easiest form of the normalization process which states that the domain of an attribute
should have only atomic values. The objective of this is to remove the duplicate columns that are
present in the table.
Any table is said to have in the 2NF if it satisfies the following 2 conditions:
Any table is said to have in the 3NF if it satisfies the following 2 conditions:
Any table is said to have in the BCNF if it satisfies the following 2 conditions:
Answer: This is used with the SQL queries to fetch specific data as per the requirements on the basis
of the conditions that are put in the SQL. This is very helpful in picking the selective records from the
complete set of the records.
For Example, There is a query which has WHERE condition or the query with the HAVING clause.
Q #24) How can you get the alternate records from the table in the SQL?
Answer: If you want to fetch the odd numbers then the following query can be used:
Answer: With the help of the LIKE operator, pattern matching is possible in the SQL.’%’ is used with
the LIKE operator when it matches with the 0 or more characters and ‘_’ is used to match the one
particular character.
Example:
Answer: A Join is one of the SQL statements which is used to join the data or the rows from 2 or
more tables on the basis of a common field/column among them.
• Inner Join: This type of join is used to fetch the data among the tables which are common in
both the tables.
• Left Join: This returns all the rows from the table which is on the left side of the join but only
the matching rows from the table which is on the right side of the join.
• Right Join: This returns all the rows from the table which is on the right side of the join but
only the matching rows from the table which is on the left side of the join.
• Full Join: This returns the rows from all the tables on which the join condition has put and
the rows which do not match hold null values.
Answer: Trigger is one of the very important codes or programs which get executed automatically in
response to the events that occur in a table or a view. For Example, If a new record is inserted in an
employee database then the data gets created automatically in the related tables like salary,
department and roles tables.
Answer: Stored Procedure is a group of SQL statements in the form of a function that has some
unique name and is stored in relational database management systems(RDBMS) and can be
accessed whenever required.
Answer: RDBMS is the Relational Database Management System which contains data in the form of
the tables and data is accessed on the basis of the common fields among the tables.
• One-to-One: This basically states that there should be a one-to-one relationship between
the tables i.e. there should be one record in both the tables. Example: Among a married
couple, both wife and husband can have only one spouse.
• One-to-Many: This states that there can be many relationships for one i.e. a primary key
table hold only one record which can have many, one or none records in the related table.
Example: A Mother can have many children.
• Many-to-Many: This states that both the tables can be related to many other tables.
Example: One can have many siblings and so do they have.