DBMS Viva
DBMS Viva
DBMS Viva
40. Explain the concept of a candidate key and how it differs from a
primary key.
• A candidate key is a column or a combination of columns that
can uniquely identify each row in a table. Unlike a primary key,
which is chosen as the main identifier for a table, a candidate
key may or may not be selected as the primary key. However,
once a candidate key is chosen as the primary key, it becomes
the main identifier for the table, and other candidate keys
become alternate keys.
41. How do you identify and define foreign keys in a relational
database schema?
• Foreign keys are identified by examining the relationships
between tables in a database schema. A foreign key is typically
defined by specifying a column in a child table that references
the primary key column(s) in a parent table. The foreign key
constraint ensures referential integrity by enforcing that values
in the child table's foreign key column match values in the
parent table's primary key column(s).
42. What is a composite key, and when would you use it in database
design?
• A composite key is a primary key composed of multiple
columns. It is used when a single column cannot uniquely
identify each row in a table, but a combination of columns can.
Composite keys are often used in junction tables (or associative
tables) in many-to-many relationships, where the combination
of foreign key columns forms a unique identifier for each
relationship.
43. Describe the process of entity integrity and referential integrity in
the relational model.
• Entity Integrity ensures that each row in a table is uniquely
identifiable by specifying a Primary Key constraint on one or
more columns. Referential Integrity ensures that relationships
between tables are maintained by specifying Foreign Key
constraints that enforce consistency between related tables.
These constraints prevent orphaned records and maintain the
integrity of data relationships.
44. Discuss the concept of a surrogate key and its use in database
design.
• A surrogate key is a system-generated unique identifier
assigned to each row in a table, typically as a numeric or
alphanumeric value. It is used as an alternative to natural keys
(such as Social Security numbers or employee IDs) to uniquely
identify rows in a table. Surrogate keys simplify database
design, improve performance, and ensure data consistency.
45. Explain the concept of a functional dependency and its relevance
in database normalization.
• A functional dependency exists when the value of one or more
attributes in a table uniquely determines the value of another
attribute. Functional dependencies are crucial in database
normalization as they help identify relationships between
attributes and determine the appropriate normalization level for
a database schema. By eliminating or reducing functional
dependencies, data redundancy and inconsistency can be
minimized.
46. How does normalization reduce redundancy and improve data
integrity?
• Normalization reduces redundancy and improves data integrity
by organizing data into smaller, well-structured tables and
eliminating data anomalies such as insertion, update, and
deletion anomalies. By decomposing tables into smaller entities
and applying normalization rules, data redundancy is
minimized, and data integrity is improved, ensuring that each
piece of data is stored in only one place and is consistent across
the database.
47. Discuss the advantages of using a relational model over other data
models like hierarchical or network.
• The relational model offers several advantages over hierarchical
and network data models, including simplicity, flexibility, data
independence, and ease of use. Relational databases use a
tabular structure, making them easier to understand and
manage. They also support complex relationships between data
entities, ensuring data integrity and consistency. Additionally,
relational databases provide a standardized querying language
(SQL), allowing for efficient retrieval and manipulation of data.
• dependencies, data redundancy and inconsistency can be
minimized.
87. Explain the purpose and usage of group by, having, and
order by clauses in SQL. The GROUP BY clause is used to
group rows that have the same values into summary rows, the
HAVING clause is used to filter groups based on specified
conditions, and the ORDER BY clause is used to sort the result
set. They are used in combination with aggregate functions to
perform group-wise calculations, filter groups based on
specific criteria, and sort the output based on specified
columns or expressions.
92. Explain the purpose and usage of the EXISTS, ANY, and
ALL operators in SQL. The EXISTS operator
107. Explain the purpose and usage of the ANY and ALL
operators in SQL.
• The ANY and ALL operators are used to compare a value with
a set of values returned by a subquery. The ANY operator
returns true if the comparison is true for any value in the set,
while the ALL operator returns true if the comparison is true
for all values in the set. They are useful for performing
conditional comparisons or filtering rows based on specific
criteria.
110. Explain the purpose and usage of the NVL function in SQL.
• Views are virtual tables derived from one or more base tables
in a database. They provide a way to simplify complex queries,
restrict access to sensitive data, and present data in a
customized format. Views can encapsulate complex logic or
frequently used queries, making them easier to manage and
maintain. They are also used to control access to data by
limiting the columns or rows visible to users based on their
privileges, enhancing security and privacy in the database.