DBMS Viva Questions Aeraxia - in
DBMS Viva Questions Aeraxia - in
What is DBMS?
Database management system is a collection of interrelated data and a set of
programs to access those data. Collection of data is referred to as a database.
What is database?
A database is an organized collection of data. The data are typically organized to
model
It translates DML statements in a query language into low-level instruction that the
query evaluation engine can understand.
What is Attributes?
Each entity has attributes—the particular properties that describe it.
For example, an employee entity may be described by the employee’s name, age,
address, salary, and job.
Physical level of data abstraction: This s the lowest level of abstraction which
describes how data are actually stored.
Logical level of data abstraction: This level hides what data are actually stored in
the database and what relationship exists among them.
A data model is a collection of concepts that can be used to describe the structure
of a database. Data models can be broadly distinguished into 3 main categories-
Low-level or physical data models It provides concepts that describe the details
of how data is stored in the computer. These concepts are meant for computer
specialist, not for typical end users.
Naive users:
These are the unsophisticated users who interact with the system by invoking
one of the application programs that have been written previously.
Application programmers:
These are computer professionals who write application programs, used to
develop user interfaces.
Sophisticated users:
These users interact with the database using database query language. They submit
their query to the query processor.
Specialized users:
These users write specialized database applications to retrieve data. These
applications can be used to retrieve data with complex data types
What is Entity?
The basic object that the ER model represents is an entity, which is a “thing” in the
real world with an independent existence.
What is Keys?
An important constraint on the entities of an entity type is the key or uniqueness
constraint on attributes. A key is an attribute (also known as column or field) or a
combination of attribute that is used to identify records.
Candidate Key – It can be defined as minimal Super Key or irreducible Super Key.
In other words an attribute or a combination of attribute that identifies the record
uniquely but none of its proper subsets can identify the records uniquely.
Primary Key – A Candidate Key that is used by the database designer for
unique identification of each row in a table is known as Primary Key
Composite Key – If we use multiple attributes to create a Primary Key then that
Primary Key is called Composite Key
Alternate Key – Alternate Key can be any of the Candidate Keys except for the
Primary Key.
Secondary Key – The attributes that are not even the Super Key but can be still
used for identification of records (not unique) are known as Secondary Key.
The DELETE command is used to remove rows from a table. A WHERE clause
can be used to only remove some rows. If no WHERE condition is specified, all
rows will be removed.
TRUNCATE removes all rows from a table. The operation cannot be rolled back
and no triggers will be fired. As such, TRUCATE is faster and doesn’t use as much
undo space as a DELETE.
The DROP command removes a table from the database. All the tables’ rows,
indexes and privileges will also be removed. No DML triggers will be fired. The
operation cannot be rolled back.
DROP and TRUNCATE are DDL commands, whereas DELETE is a DML command.
Therefore DELETE operations can be rolled back (undone), while DROP and
TRUNCATE operations cannot be rolled back.
What is cardinalities?
Mapping cardinalities, or cardinality ratios, express the number of entities to which
another entity can be associated via a relationship set There are three types of
relationships
One to one
One to many
Many to many
What is Participation?
The participation of an entity set E in a relationship set R is said to be total if
every entity in E participates in at least one\ relationship in R.
If only some entities in E participate in relationships in R, the participation of
entity set E in relationship R is said to be partial.
What is Specialization
The process of designating sub groupings within an entity set is called
specialization.
For example, customer entities may be described further by the attribute
customer-id, whereas employee entities may be described further by the
attributes employee-id and salary.
What is Generalization
Generalization defines a is-a-kind of relationship in which one class shares its
structure and/or behavior with one or more other classes.
how to drop a table?
What is View?
A view is a “virtual table” in the database whose contents are defined by a query.
Advantages of VIEW?
Security, Query simplicity, Structural simplicity, Insulation from change, Data integrity
Disadvantages of VIEW?
Performance issue, Update restrictions
What is Joins?
The process of forming pairs of rows by matching the contents of related
columns is called joining the tables.
What is Aggregation
INNER JOIN
Inner join shows matches only when they exist in both tables.
What is trigger
The concept of a trigger is relatively straightforward. For any event that causes a change
in the contents of a table, a user can specify an associated action that the DBMS should
carry out. The three events that can trigger an action are attempts to INSERT, DELETE,
or UPDATE rows of the table.
It guarantees that the spurious tuple generation does not occur with respect to relation
schemas after decomposition.
What is normalization?
This model is based on collection of objects. An object contains values stored in instance
variables with in 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.
What are stand-alone procedures?
Procedures that are not part of a package are known as stand-alone because they
independently defined. A good example of a stand-alone procedure is one written in a
SQL*Forms application. These types of procedures are not available for reference from
other Oracle tools. Another limitation of stand-alone procedures is that they are
compiled at run time, which slows execution.
What is indexing?
A database index is a data structure that improves the speed of data retrieval operations
on a database table at the cost of slower writes and increased storage space. Indices can
be created using one or more columns of a database table, providing the basis for both
rapid random lookups and efficient access of ordered records.
First normal form (1NF) is a relation that has a primary key and in which there
are no repeating groups.
Second normal form (2NF) a relation in first normal form in which every non key
attribute is fully functionally dependent on the primary key.
Third normal form (3NF)a relation that is in second normal form and has no transitive
dependencies.
What is BCNF?
Boyce-Codd normal form (or BCNF or 3.5NF) is a normal form used in database
normalization. It is a slightly stronger version of the third normal form (3NF). A table
is in Boyce-Codd normal form if and only if for every one of its non-trivial
[dependencies] X → Y, X is a superkey—that is, X is either a candidate key or a
superset thereof.
Deferred Update
Updates are not written to the database until after a transaction has reached its
commit point.
Immediate Update
Updates are applied to database as they occur.
Need to redo updates of committed transactions following a failure.
Shadow Paging.
Maintain two page tables during life of a transaction: current page and shadow
page table.
When transaction starts, two pages are the same.
Shadow page table is never changed thereafter and is used to restore database in
event of failure.
Expanding phase (number of locks can only increase): locks Care acquired and
no locks are released.
Shrinking phase: locks are released and no locks are acquired.
What is GRANT privileges?
The GRANT statement is used to grant the privileges on the database objects to
specific users. Normally the GRANT statement is used by owner of the table or
view to give other users access to the data. The GRANT statement includes list of
the privileges to be granted, name of the table to which privileges apply and user id
to which privileges are granted.
In most SQL based databases, the privileges that you have granted with the
GRANT statement can be taken away with the REVOKE statement. The
structure of the REVOKE statement is much similar to that of the GRANT
statement. A REVOKE statement may take away all or some of the privileges
granted to a user id.
What is Serializability?
It is the program module, which tests for the satisfaction of integrity constraint
and checks the authority of user to access data.
PL/SQL uses cursors for all database information accesses statements. The language
supports the use two types of cursors
Implicit
Explicit
Stored procedures are database objects that perform a user defined operation. A
stored procedure can have a set of compound SQL statements. A stored procedure
executes the SQL commands and returns the result to the client.
Stored procedures are used to reduce network traffic.
What is a query?
A query with respect to DBMS relates to user commands that are used to interact
with a data base. The query language can be classified into data definition language
and data manipulation language.
What do you mean by Correlated subquery?
Subqueries, or nested queries, are used to bring back a set of rows to be used by
the parent query. Depending on how the subquery is written, it can be executed
once for the parent query or it can be executed once for each row returned by the
parent query. If the subquery is executed for each row of the parent, this is called a
correlated subquery.
Example: Select * From CUST Where '10/03/1990' IN (Select ODATE From ORDER
Where CUST.CNUM = ORDER.CNUM)
The phase that identifies an efficient execution plan for evaluating a query that has
the least estimated cost is referred to as query optimization.
Once the DBMS informs the user that a transaction has successfully completed, its
effects should persist even if the system crashes before all its changes are reflected
on disk. This property is called durability.
Atomicity: Either all actions are carried out or none are. Users should not have
to worry about the effect of incomplete transactions. DBMS ensures this by
undoing the actions of incomplete transactions.
Aggregation: A concept which is used to model a relationship between a
collection of entities and relationships. It is used when we need to express a
relationship among relationships.
What is 4NF?
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 1.) Ri = R for some i.
2.) The join dependency is implied by the set of FD, over R in which the left side is
key of R.
A relation is said to be in DKNF if all constraints and dependencies that should hold
on the the constraint can be enforced by simply enforcing the domain constraint
and key constraint on the relation.
Indexing is a technique for determining how quickly specific data can be found.
Types: