Dbms Practical Viva Answers
Dbms Practical Viva Answers
Dbms Practical Viva Answers
Note : All these Answers are Copied from Notes (which was provided by Rahila Ma’am) and
some answers which are not in notes are copied from site geeks for geeks
1. What is data?
Ans :
Data
• Data is nothing but facts and figures that can be recorded in
system and have some special meaning assigned to it.
• In the context of computer science, it refers to information that
has been translated into a form that is efficient for movement or
processing.
• For example- name, age, address, account _no. etc,
2. What is Information?
Ans :
Information
• Information is the result of processing and organizing data to give it
context and meaning.
• It is data that has been analyzed, interpreted or structured in a way
that makes it useful and meaningful to users.
• Information provides insights, knowledge or understanding based
on the data presented.
3. What is a database?
Ans :
Database
• A Database is a collection of information or facts that is organized
so that it can be easily processed, managed, controlled, accessed or
updated.
• In a banking application, data is the whole collection of bank
4. Define DBMS?
Ans :
Database Management System
• Database Management System (DBMS) is a collection of
interrelated data and set of programs to access those data. DBMS
provides a way to store and retrieve database information that is both
convenient and efficient.
• It allows users to store, process and analyze data easily. DBMS also
provides protection and security to the databases. It also maintains
data consistency in case of multiple users.
• DBMS provides us with an interface or a tool, to perform various
operations like creating database, storing data in it, updating data,
creating tables in the database and a lot more.
• Here are some examples of popular DBMS used these days: MySQL,
Oracle, IBM DB2, PostgreSQL, MongoDB, Hadoop, Amazon Simple DB
(cloud based) etc.
Ans :
Ans :
Advantages of DBMS over file System –
• To provide data sharing
• Reduction of Data Redundancy
• Avoiding Inconsistency
• Transactional Support
• Maintaining Integrity
• Enforcement of Security
7. Disadvantages of Database?
Ans :
• Complexity
• Cost
• High Hardware Cost
• Performance
• Database Failure
• Huge Size
• Frequency Upgrade / Replacement Cycles
• Security
Ans :
Entity
• An entity can be a real-world object, either animate or inanimate,
that can be easily identifiable.
• For example, in a school database, students, teachers, classes, and
courses offered can be considered as entities. All these entities have
some attributes or properties that give them their identity.
• An entity set is a collection of similar types of entities. An entity set
may contain entities with attribute sharing similar values.
• For example, a Students set may contain all the students of a
school; likewise a Teachers set may contain all the teachers of a
Ans :
Ans :
Structure Query Language
•SQL stands for Structured Query Language. It is used for storing and managing
data in relational database management system (RDMS).
Ans :
•SQL is easy to learn.
•SQL is used to access data from relational database management systems.
•SQL can execute queries against the database.
•SQL is used to describe the data.
•SQL is used to define the data in the database and manipulate it when needed.
•SQL is used to create and drop the database and table.
•SQL is used to create a view, stored procedure, function in a database.
•SQL allows users to set permissions on tables, procedures, and views.
Ans :
Redundancy means having multiple copies of the same data in the
database. This problem arises when a database is not normalized.
Ans :
Data duplication is a computational technique that removes multiple copies
of data that repeat. If the method is successfully used, storage utilization
may be increased, which might save capital cost because less storage media
would be needed overall to fulfill storage capacity requirements.
Ans :
•Normalization is the process of organizing the data in the database.
•Normalization is used to minimize the redundancy from a relation or
set of relations. It is also used to eliminate undesirable characteristics
like Insertion, Update, and Deletion Anomalies.
•Normalization divides the larger table into smaller and links them
using relationships.
•The normal form is used to reduce redundancy from the database
table.
Ans :
Normal forms: 1NF, 2NF, 3NF
Ans :
1. Primary key
•It is the first key used to identify one and only one instance of an entity uniquely.
An entity can contain multiple keys, as we saw in the PERSON table. The key
which is most suitable from those lists becomes a primary key.
2. Candidate key
•A candidate key is an attribute or set of attributes that can uniquely identify a
tuple.
For example: In the EMPLOYEE table, id is best suited for the primary key. The
rest of the attributes, like SSN, Passport_Number, License_Number, etc.,
are considered a candidate key.
3. Super Key
Super key is an attribute set that can uniquely identify a tuple. A super key is a
superset of a candidate key.
For example: In the below EMPLOYEE table, for(EMPLOEE_ID, EMPLOYEE_NAME),
the name of two employees can be the same, but their EMPLYEE_ID can't be the
4. Foreign key
•Foreign keys are the column or attributes of the table used to point to
the primary key of another table.
5. Alternate key
There may be one or more attributes or a combination of attributes that uniquely
identify each tuple in a relation. These attributes or combinations of the
attributes are called the candidate keys. One key is chosen as the primary key
from these candidate keys, and the remaining candidate key, if it exists, is termed
the alternate key. In other words, the total number of the alternate keys is the
total number of candidate keys minus the primary key. The alternate key may or
may not exist, if there is only one candidate key in a relation.
For example, employee relation has two attributes, Employee_Id and PAN_No,
that act as candidate keys. In this relation, Employee_Id is chosen as the primary
key, so the other candidate key, PAN_No, acts as the Alternate key.
6. Composite key
Whenever a primary key consists of more than one attribute, it is known as a
composite key. This key is also known as Concatenated Key.
For example, in employee relations, we assume that an employee may be
assigned multiple roles, and an employee may work on multiple projects
simultaneously. So the primary key will be composed of all three attributes,
namely Emp_ID, Emp_role, and Proj_ID in combination. So these attributes
act as a composite key since the primary key comprises more than one attribute.
SELF JOIN
The SELF JOIN allows you to join a table to itself. This implies that each row of the
table is combined with itself and with every other row of the table. The SELF JOIN
can be viewed as a join of two copies of the same table. The table is not actually
copied, but SQL performs the command as though it were. This is accomplished
by using table name aliases to give each instance of the table a separate name. It
is most useful for extracting hierarchical data or comparing rows within the same
table.
Ans :
Ans :
Ans :
Components of DBMS are broadly classified as follows :
1.Users:
(a)Naïve User
(b)Application User
(c)Sophisticated User
(d)Database Administrator
2. Query Processor :
(a) DML Compiler
(b) Embedded DML pre-compiler
(c) DDL Interpreter
(d) Query Evaluation Engine
3. Storage Manager :
(a) Authorization and Integrity Manager
(b) Transaction Manager
(c) File Manager
(d) Buffer Manager
4. Data Structure :
(a) Data Files
(b) Data Dictionary
Ans :
Data Abstraction
Database systems are made-up of complex data structures. To ease the user
interaction with database, the developers hide internal irrelevant details from
users. This process of hiding irrelevant details from user is called data
abstraction.
Ans :
• E-R Model-An entity relationship model, also called an
Entity-Relationship Diagram (ERD), is a graphical representation of entities and
their relationships to each other.
• An entity is a piece of data - an “object” or a “thing” in real world that is
distinguishable from other objects.
• ERD can express the overall logical structure of database graphically.
Ans :
A Data Model is a logical structure of Database. It describes the design of
database to reflect entities, attributes, relationship among data, constrains etc.
Types of Data Models:
a) Object based logical Models – Describe data at the conceptual and view levels.
• E-R Model
b) Record based logical Models – Like Object based model, they also describe
data at the conceptual and view levels. These models specify logical structure of
database with records fields and attributes.
• Relational Model
• Hierarchical Model
• Network Model
c) Physical Data Models – These models describe data at the lowest level of
abstraction.
Ans :
Ans :
Rule 0: Foundation Rule - A system must qualify as a relational database
management system (RDBMS).
Rule 1: Information Rule - All information in the database must be
represented in tables.
Rule 2: Guaranteed Access Rule - Each piece of data must be accessible with
a combination of table name, primary key, and column name.
Rule 3: Systematic Treatment of Null Values - Null values must be supported
and treated systematically.
Ans :
DDL Commands
Data Definition Language (DDL)
•DDL changes the structure of the table like creating a table, deleting a table,
altering a table, etc.
•All the command of DDL are auto-committed that means it permanently save all
the changes in
the database.
Here are some commands that come under DDL:
•CREATE
•ALTER
•DROP
•TRUNCATE
b. DROP: It is used to delete both the structure and record stored in the table.
Syntax
DROP TABLE table_name;
Example
DROP TABLE EMPLOYEE;
c. ALTER: 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));
d. TRUNCATE: 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;
a. INSERT: The INSERT statement is a SQL query. It is used to insert data into
the row of a table.
Syntax:
INSERT INTO TABLE_NAME
(col1, col2, col3,.... col N)
VALUES (value1, value2, value3, .... valueN);
Or
INSERT INTO TABLE_NAME
VALUES (value1, value2, value3, .... valueN);
For example:
INSERT INTO javatpoint (Author, Subject) VALUES ("Sonoo", "DBMS");
DCL Commands
Data Control Language
DCL commands are used to grant and take back authority from any database user.
Here are some commands that come under DCL:
create user user_name identified by admin_password;
Create user Rahila identified by 1234;
a. Grant: It is used to give user access privileges to a database.
Syntax:
grant privilege_name on object_name to {user_name | public | role_name}
Example
GRANT SELECT, UPDATE ON MY_TABLE TO SOME_USER, ANOTHER_USER;
b. Revoke: It is used to take back permissions from the user.
Syntax:
revoke privilege_name on object_name from { user_name | public | role_name}
Example
REVOKE SELECT, UPDATE ON MY_TABLE FROM USER1, USER2;
DQL Commands
Data Query Language
DQL is used to fetch the data from the database.
It uses only one command:
•SELECT
a. SELECT: This is the same as the projection operation of relational algebra. It is
used to
select the attribute based on the condition described by WHERE clause.
Syntax:
SELECT expressions FROM TABLES WHERE conditions;
For example:
SELECT emp_name FROM employee WHERE age > 20;
Ans :
Types of Operators in SQL
Different types of operators in SQL are:
• Arithmetic operator
Ans :
There are two types of functions in SQL:
• Aggregate Functions
• Scalar Functions (in built functions)
Ans :
A view in SQL is a saved SQL query that acts as a virtual table. It can fetch
data from one or more tables and present it in a customized format.
Ans :
Indexing improves database performance by minimizing the number of disc
visits required to fulfill a query. It is a data structure technique used to
locate and quickly access data in databases. Several database fields are
used to generate indexes.
Ans :
A SYNONYM provides another name for database object, referred to as
original object, that may exist on a local or another server. A synonym
belongs to schema, name of synonym should be unique. A synonym cannot
be original object for an additional synonym and synonym cannot refer to
user-defined function.
Ans :
• A sequence is a database object that generates and produces integer
values in sequential order.
• It automatically generates the primary key and unique key values.
• It may be in ascending or descending order.
• It can be used for multiple tables.
Ans :
1.Integration with SQL
2.Procedural Language Features
3.Performance
4.Scalability
5. Security
6. Error Handling
7. Data Manipulation
8. Integration with External Programs
33.Define PL/SQL
Ans :
PL/SQL is an extension of SQL language that combines the data manipulation
power of SQL with the processing power of procedural language to create super
powerful SQL queries. PL/SQL ensures seamless processing of SQL statements by
enhancing the security, portability, and robustness of the Database.
PL/SQL means instructing the compiler ‘what to do’ through SQL and ‘how to do’
through its procedural way. Similar to other database languages, it gives more
control to the programmers by the use of loops, conditions and object-oriented
concepts. The PL/SQL Full form is “Procedural Language extensions to SQL”.
Ans :
PL/SQL Control Structures are used to control flow of execution. PL/SQL provides
different kinds of statements to provide such type of procedural capabilities.
These statements are almost same as that of provided by other languages.
Ans :
An Exception is an error situation, which arises during program execution. When
an error occurs exception is raised, normal execution is stopped and control
transfers to exception handling part. Exception handlers are routines written to
Ans :
A cursor is a pointer to the work area or context area, used by the oracle engine
for executing SQL statements. Such a work area is privately used for SQL
operations by the oracle engine. When the oracle engine executes an SQL
statements, the row of data returned is stored in cursor and is called active data
set. And the cursor occupies memory size required to hold the number of rows in
the active dataset. Cursor containing the values retrieved from a table are opened
in the predefined area of the main memory by oracle engine. This data is then
transferred to the client machine via network.
Ans :
The stored procedure in PL/SQL is a program block that performs specific tasks.
It can be considered a function or a method. But the procedure does not return a
value directly like functions. It can be invoked by triggers or other procedures etc.
It reduces the network traffic and increases performance because the commands
in the stored procedure are executed as a single batch of code.
Ans :
The functions are similar to procedures in PL/SQL except for the fact that it has
the ability to return a value (specified with keyword RETURN) and performs
computation tasks. It has a unique name and acts as an independent block of
code. The data type of a function is set at the time of the creation of function. A
function may contain a nested block or describe inside other packages or blocks.
A function can return values with the help of the RETURN keyword and OUT
parameter.
Ans :
Ans :
Triggers are statements that are executed automatically in order of occurrence of
any event. Triggers are automatically and repeatedly called upon by oracle engine
on satisfying certain condition. Triggers can be activated or deactivated
depending on the requirements. If triggers are activated then they are executed
implicitly by oracle engine and if triggers are deactivated then they are executed
explicitly by oracle engine.
Ans :
Database security refers to the protection of a database system from
unauthorized access, malicious activities, and data breaches. It involves
implementing various security measures to ensure the confidentiality, integrity,
and availability of the data stored in the database. Database security is essential
as databases often contain sensitive information, such as personal data, financial
records, and proprietary business information.
Ans :
Access Control
Encryption
Auditing and Logging
Backup and Recovery
Ans :
The transaction is a set of logically related operation. It contains a group of tasks.
A transaction is an action or series of actions. It is performed by a single user to
perform operations for accessing the contents of the database.
Ans :
Atomicity: This principle states that database transactions must be all or nothing.
If the transaction fails, the entire transaction is rolled back. Atomicity prevents
partial and incomplete transactions.
Consistency: According to this property, only valid data is written to the database.
Consistency enforces integrity constraints to maintain the accuracy and
correctness of data.
Isolation: Running transactions independently is the core of isolation. Changes in
one transaction will not impact others until committed. Isolation maintains data
integrity across concurrent transactions.
Durability: Durability guarantees that all committed transactions are permanently
recorded in the database. They persist even after system failure. Durability
provides recoverability.
Ans :
Database backup basically means that a duplicate of the database information
and data is created and stored in backup server just to be on the safe side.
Transaction logs are also stored in the backup along with the database data
because without them, the data would be useless.
Ans :
There are mainly two types of recovery techniques used in DBMS
•Rollback/Undo Recovery Technique
•Commit/Redo Recovery Technique
Ans :
A Data Warehouse is a centralized repository that stores large amounts of data
collected from different sources for reporting and analysis. It is designed to
facilitate querying and data analysis rather than transaction processing. Data
warehouses are crucial for businesses to analyze trends, perform business
intelligence, and support decision-making.
Ans :
Big data refers to large, diverse sets of information that grow at ever-increasing
rates. The term encompasses the volume of information, the velocity or speed at
which it is created and collected, and the variety or scope of the data points being
covered (commonly known as the "Three V's" of big data). Big data provides the
raw material used in data mining.
Ans :
A data lake is a central location that holds a large amount of data in its native,
raw format. Compared to a hierarchical data warehouse, which stores data in
files or folders, a data lake uses a flat architecture and object storage to store
the data. Object storage stores data with metadata tags and a unique identifier,
which makes it easier to locate and retrieve data across regions, and improves
performance. By leveraging inexpensive object storage and open formats, data
lakes enable many applications to take advantage of the data. Data lakes typically
contain a massive amount of data stored in its raw, native format. This data is
made available on-demand, as needed; when a data lake is
queried, a subset of data is selected based on the query’s criteria and presented
for analysis.
Ans :
This question is repeated you will find the answer above…….
Ans :
Ans :
Study All Syntax From the Notes……………
Thank You