DBMS Theory
DBMS Theory
3 tier arch: physical(where data stored), conceptual(logical schema like tables and
their relationships), external(data abstraction-viewing data and tables for each
user)
this type or arch helps in scalability, readability, etc.
Types of keys?
A super key is a set of attributes of a relation schema upon which all attributes
of the schema are functionally dependent. No two rows can have the same value of
super key attributes. can be null
A Candidate key is a minimal superkey, i.e., no proper subset of Candidate key
attributes can be a superkey. can be null. can have multiple candidate keys but one
primary key. A candidate key, of a relational database is any set of columns that
have a unique combination of values in each row, with the additional constraint
that removing any column could produce duplicate combinations of values
A Primary Key is one of the candidate keys. One of the candidate keys is selected
as most important and becomes the primary key. There cannot be more than one
primary key in a table. cant be null
A Foreign key is a field (or collection of fields) in one table that uniquely
identifies a row of another table.
superkey ka subset candidate and candidate ka subset primary
What is a Trigger?
A special type of stored procedure for insert, delete and update.
What is the difference between Trigger and Stored Procedure?
Stored Procedures are explicitly called and used for complex operations, while
Triggers are automatically invoked in response to specific database events to
enforce rules or automate actions.
Stored Procedures offer better control over execution and can be reused, but
Triggers provide automation and ensure consistency across database operations.
What is Identity?
Identity (or AutoNumber) is a column that automatically generates numeric values. A
start and increment value can be set, but most DBA leave these at 1. A GUID column
also generates numbers; the value of this cannot be controlled. Identity/GUID
columns do not need to be indexed.
What is BCNF?
BCNF is the Boyce Codd Normal Form which is stricter than the 3NF.
2 conditions:
A table is in the 3NF.
For each of the functional dependencies X->Y that exists, X is the super key of a
table.
What is QBE?
Query-by-example represents a visual/graphical approach for accessing information
in a database through the use of query templates called skeleton tables.
What are the main differences between Primary key and Unique Key?
The main difference between the Primary key and the Unique key is that the Primary
key can never have a null value while the Unique key may consist of a null value.
In each table, there can be only one primary key while there can be more than one
unique key in a table.