Fundamentals of Databases Flashcards
What is a field?
A column in a database
What is a record?
A row in a database
What is a primary key?
A unique field in a database table which indexes a record
Identified by an underline
What are the three entity-relationships?
One-to-one
Many-to-many
One-to-many
What is a foreign key?
A foreign key is a column in a database table that links to the primary key of another table, establishing a connection between the two tables.
Why are databases normalised?
Database normalization is done to reduce data redundancy and improve data integrity, ensuring consistency and efficient use of storage.
What is First Normal Form?
Contains only atomic values; each column has only one value.
A column should only contain values of the same type.
Each row holds a unique set of data; doesn’t have repeating field names.
It doesn’t matter what order the data is in; we can fetch it from anywhere using a query.
What is Second Normal Form?
To be in second normal form, it must be in first normal form and not contain any partial dependency.
What is Partial Dependency?
When a primary key is made up of two columns, and an attribute depends on only one of these columns.
How do you remove Partial Dependency?
Move it to another table where it can be dependent on one key.
What is Third Normal Form?
Where there’s no transitive dependency and it’s in 2nd and 1st normal form.
What is Transitive Dependency?
A condition in which an attribute is dependent on another attribute that isn’t a part of the primary key.
How do you remove Transitive Dependency?
Split the fields which had the transitive dependency into new tables.
SELECT Command
Used to retrieve data from a database table
SELECT <column> FROM <table> WHERE <condition> ORDER BY <column><ASC/DESC></column></condition></column>
The ORDER BY is optional
- Defaults to ASC
UPDATE command
Used to modify the attributes of an existing entity
UPDATE <table> SET <column> = <value>
WHERE <column> = <value></value></column></value></column>