Database Flashcards
What are functional dependencies?
These are database rules that help us group data in a database based on the relationship between them, It helps us find other pieces of data, using another piece of data.
Basically, a functional dependency is typically a relationship between a primary key and other none-keys on a table.
What is redundancy in a Database?
It is a phenomenon that occurs when the same piece of identical data in a database occurs multiple times within that database. This could be empirical or atomic data, attributes etc.
What are the existing Database anomalies? Explain them with detailed examples.
Acronym: DUI
1. Deletion anomaly:
This is a database anomaly that occurs when deleting a record causes and unintentional loss of some other data in the database.
2. Update anomaly:
This is a database anomaly that occurs when information in the database is updated wrongly or when we have to change information in the database to the correct information.
3. Insertion anomaly:
This is a database anomaly that occurs when inserting a new record into the database is not possible without also inserting some piece of unrelated data.
How can we avoid database anomalies?
This can be done by normalizing all the tables in the database, and this can only be done by understanding functional dependencies, as functional dependences ensure every attribute on a table truly belongs to that table, hence helping us to reduce anomalies and redundancy in our database tables.
What is a Determiner and A dependent in a functional dependency relationship? Explain with examples.
The determiner is the attribute on a table that maps on to another attribute(dependent) on the table. For example, a primary key, maps on to the none-keys in a table, meaning the none-keys depend on the primary key.
Explain Full, Partial, and Transitive Dependencies, each with an example.
-> Full dependency occurs when an attribute on a table entirely depends another attribute on the table usually the primary key, this means that using one attribute (the pk) we can find the information about the dependent attribute with absolute certainty
-> Partial dependency occurs when an attribute on a table is dependent on one part of a coposite key (usually a composite key)
-> Transitive dependency occurs when one none-key attribute depends on another none-key attribute.
What the different normal forms that exists in database?
The first to 5th normal form and The Boyce Codd normal form.
Explain the first to third normal form.
1NF:
This normal form makes sures that each attribute in a table contains just 1 value
2NF:
This normal form ensures that every attribute in a table is fully dependent on the primary key.
3NF:
This normal aims at eliminating transitive dependences, by making sure that no none key depends on another none-key.
What are database constraints? Explain with an example.
Database constraints are the rules in the database that ensure that data being stored in the database satisfies certain conditions
Name the database constraints that exist.
Acronym: DECREB
-> Domain Integrity constrain
-> Entity Integrity constraints
-> Referencial Integrity constraints
-> Enterprise Constraints
-> Business Rules
-> Cardinality and connectivity constraints
What is the Domain integrity constraint? Please give an example using a table.
The Domain Integrity Constraints are rules that ensure that the data being stored in a column or attribute of a table in the database is valid, meaning it is of the same data type as the attribute, it should follow the specified format, and it should follow any specified constraints put in place.
What is an entity Integrity constraint? Please give an example using a table
This is a database rule that ensures that every table in a database contains a primary key attribute and every entry under said primary key attribute should be unique and cannot be null.
What is the referential integrity constraint?
This is a data database rule that ensures that every foreign key in one table should have a corresponding primary key. This is done to avoid the occurrence of any orphan records.
What is an orphan record?
It is a record that contains a foreign key, whose corresponding primary does not exist.
What are enterprise or semantics constraints?
These are rules in the database that are specified by the database user or the database administrator e.g The entity “TEACHER” can not teach more than 3 courses(Its Course attribute cannot hold and integer value greater than 3) .