DBMS Interview Questions
DBMS Interview Questions
What is a database?
A database is a single repository of logically related data. All the data inside a
database can be used to interpret a real-life scenario. There are various kinds of
databases namely relational and NoSQL databases.
Self defining nature of a database refers to the customization of the logical schema
of a database whereas in a file system, the flexibility is defining the schema is not
supported.
In a database, the program and the data are separated from each other. Changing
one won’t affect the other. This refers to program data independence.
Difference between a query and a transaction
A query is a SQL code that is implemented to retrieve data from the database
whereas a transaction is a SQL code that causes some data to be read and written
into the database.
Consistency refers to the satisfaction of all defined constraints before and after a
transaction.
The changes made to a database are written to the storage. This ensures that the
database is durable even in case of system failure.
Referential integrity constraint refers to a condition that the tables in a database must
be related to each other and it is achieved using a foreign key.
Uniqueness constraint refers to the condition where the records in a table must be
unique.
There are three levels of data abstraction - on the physical level, logical level and
View level.
What’s the 3 schema architecture?
Internal schema is a physical data model that describes the access paths for the
database.
Conceptual schema describes the structure of the database without describing the
implementation details.
External schema describes the part of the database that a user group is interested
in.
The capacity to change the schema at one level of the database system without
having to change the schema at the higher level is called data independence.
There are 2 types of data independence. They are physical data independence and
logical data independence.
There are 4 types of DBMS languages. They are Data definition language (DDL),
Data Manipulation language (DML), Data Control Language(DCL) and Transaction
Control Language(TCL).
DDL is used to define schemas. DML is used to perform database operations.. DCL
is used to grant or revoke privileges and TCL is used to manage transactions.
‘DD-MON-YYYY’
DELETE is used to delete the records in a database and the schema remains intact
but the deleted records are restorable whereas TRUNCATE is used to delete records
permanently and to keep the schema intact whereas DROP permanently removes
the existence of the database object along with the records in it.
Attributes are the columns in a relational database. They represent the properties of
an entity in a real world scenario. Following are the various classifications of
attributes:
– Simple vs composite
– Single valued vs multi valued
– Stored vs derived
– NULL attribute
Intension refers to the schema of the database whereas extension refers to the
cardinality of the database at any given point.
What is an ER model?
ER model stands for Entity relationship model. It is a high-level model that is used to
describe the conceptual schema of the database using entity types, attributes and
relationships among the entities. It doesn’t discuss the implementation of the
database.
What are the various set and multiset operations of relational algebra?
UNION, INTERSECT and EXCEPT are the set operations and UNION ALL,
INTERSECT ALL and EXCEPT ALL are the multiset operations.
What is meant by mapping cardinalities?
Mapping cardinality refers to the number of entities to which another entity can be
linked with through a certain relation set.
Joins are used to combine data from two or more tables based on common
attributes. There are 2 types of joins. They’re inner and outer joins.
Inner Joins are further classified into natural join/equijoin and theta join.
Outer Joins are further classified into left outer join, right outer join and full outer join.
Define Normalisation.
Normalisation is the process of dividing a larger table into smaller tables to
minimise redundancy and insertion and deletion anomalies. It’s a top down
approach.
Following are the normal forms: 1NF, 2NF, 3NF, BCNF.
Normal form of a table is the highest normal form to which it can be normalised.
What is lossless and lossy decomposition?
Degree refers to the number of attributes in the table and cardinality refers to the
number of tuples in the table.
Relational data model stores data in rows and columns. Data can be found by
directly accessing the tables. A parent can have many children and a child can have
many parents.
Network data model stores data in graph format. Data is stored in nodes. A child can
have many parents and a child can have many parents. Searching begins from the
root node.
Hierarchical data model stores data in tree format. Data is stored in nodes. A parent
can have many children but a child can’t have multiple parents. Searching begins
from the root node.
What is 1NF?
What is 2NF?
What is 3NF?
What is BCNF?
What is PL/SQL?
What is a shared lock and an exclusive lock?