DBMS Flashcards
What is RDBMS (Relational Database Management System)?
Relational Data Base Management Systems (RDBMS) are database management systems that maintain data records and indices in tables.
Relationships may be created and maintained across and among the data and tables.
An RDBMS has the capability to recombine the data items from different files, providing powerful tools for data usage.
How are relationships between data items in a relational database expressed?
In a relational database, relationships between data items are expressed by means of tables and the Inter-dependencies among these tables are expressed by data values rather than by pointers. This allows a high degree of data independence.
What is a Primary Key?
A PRIMARY KEY constraint is a unique identifier for a row within a database table. Every table should have a primary key constraint to uniquely identify each row and only one primary key constraint can be created for each table.
What is a Unique Key
A UNIQUE constraint that enforces the uniqueness of the values in a set of columns, so no duplicate values are entered.
What is a Foreign Key?
A FOREIGN KEY constraint prevents any actions that would destroy links between tables with the corresponding data values. A foreign key in one table points to a primary key in another table. Foreign keys prevent actions that would leave rows with foreign key values when there are no primary keys with that value.
What is a CHECK constraint?
A CHECK constraint is used to limit the values that can be placed in a column.
What is NOT NULL constraint
A NOT NULL constraint enforces that the column will not accept null values.
What does a Primary key enforces?
It enforces entity integrity
What does a Unique Key enforces?
It enforces entity integity
What does a Foreign key enforces?
It enforces referential integrity
What does a CHECK constraint enforces?
It enforces domain integrity
What does a NOT NULL constraint enforces?
It enforces a domain constraint
What is the similarity between a primary key and a unique key?
They both enforce uniqueness of the column on which they are defined
What is the difference between a primary key and a unique key?
- But by default primary key creates a clustered index on the column, where as unique key creates a non-clustered index by default.
- Another major difference is that, primary key doesn’t allow NULLs, but unique key allows one NULL only
What is Normalization
–Database normalization is a data design and organization processes applied to data structures based on rules that help build relational databases.
In relational database design, the process of organizing data to minimize redundancy.
–Normalization usually involves dividing a database into two or more tables and defining relationships between the tables. The objective is to isolate data so that additions, deletions, and modifications of a field can be made in just one table and then propagated through the rest of the database via the defined relationships.
What are the different normalization forms
1NF: Eliminate Repeating Groups. Make a separate table for each set of related attributes, and give each table a primary key. Each field contains at most one value from its attribute domain.
2NF: Eliminate Redundant Data. If an attribute depends on only part of a multi-valued key, remove it to a separate table.
3NF: Eliminate Columns Not Dependent On Key. If attributes do not contribute to a description of the key, remove them to a separate table. All attributes must be directly dependent on the primary key
BCNF: Boyce-Codd Normal Form. If there are non-trivial dependencies between candidate key attributes, separate them out into distinct tables.
What is Stored Procedure
- -A stored procedure is a named group of SQL statements that have been previously created and stored in the server database.
- -Stored procedures accept input parameters so that a single procedure can be used over the network by several clients using different input data. And when the procedure is modified, all clients automatically get the new version.
What are the advantages of a Stored Procedure
Stored procedure can reduced network traffic and latency, boosting application performance.
Stored procedure execution plans can be reused, staying cached in SQL Server’s memory, reducing server overhead.
Stored procedures help promote code reuse.
Stored procedures can encapsulate logic. You can change stored procedure code without affecting clients. Stored procedures provide better security to your data.
What is a trigger?
A trigger is a SQL procedure that initiates an action when an event (INSERT, DELETE or UPDATE) occurs. Triggers are stored in and managed by the DBMS. .
What are triggers used to maintain or enforce
Triggers are used to maintain the referential integrity of data by changing the data in a systematic fashion.
Can a trigger be called or executed? If not then how does it operate?
NO
the DBMS automatically fires the trigger as a result of a data modification to the associated table.
What is the similarity between Triggers and Stored Procedure
They both consist of procedural logic that is stored at the database level
What are the differences between Triggers and Stored Procedure
- -Stored procedures are not event-drive and are not attached to a specific table while triggers are.
- -Stored procedures are explicitly executed by invoking a CALL to the procedure while triggers are implicitly executed.
- -In addition, triggers can also execute stored procedures.
What is a Nested Trigger
A trigger that can also contain INSERT, UPDATE and DELETE logic within itself, so when the trigger is fired because of data modification it can also cause another data modification, thereby firing another trigger. A trigger that contains data modification logic within itself is called a nested trigger.