Fundamentals of databases
Last edited time @October 1, 2023 10:47 AM
Status Done
Relational databases
Relational database → A form of database that links tables of related data together. Each
table has a relationship with another in the database.
Table → A method for implementing on entity and attributes as a group of related data.
Entity → An object that stores data. A table contains a list of entities.
Attribute → A characteristic or piece of information about a specific entity within the database.
For example, a football player’s shoe size. These are stored as fields within a database.
Record → A record an element of a table that stores information about a specific objects. It is
important to note that a record is not an entity. This is because entities can be treated as
types of records whereas a record is the specific data itself.
Relationships
Entity relationship diagram → A visual method for showing the relationship between
entities within a relational database.
There are three different kinds of relationship that entities can have within a database.
These are:
One-to-one
One-to-many
Many-to-many
These each describe different situations and have respective ways of drawing them, these
are shown below:
Fundamentals of databases 1
, Keys and identifiers
Primary key → An attribute that uniquely identifies every record (individual item) within a
table.
Entity Identifier → An attribute that can uniquely identify each instance of an entity. This
finds a specific entity of type <entity>
Foreign key → An attribute in a table that is a primary key within another table. This is the
function that links tables together and recalls all information from all tables about a specific
record. Foreign keys are also used for one-to-many relationships. As you can have a key
that links the events together.
Standard notation
When writing out databases there is a standard notation that is used for tables, attributes
and the primary key. This goes as follows:
The name of the table is shown in capitals.
All the attributes are placed between brackets.
primary keys are underlined.
For example this creates → CUSTOMER (CustomerID, CustomerName, Address)
Normalisation
Normalisation → The process of adjusting a relational database according to a set of rules
to make its structure as efficient as possible.
A database is normalised when the there is no redundant data and when each item of
data is stored in the correct table and at an atomic level.
When the rules below are followed then a database is said to be normalised:
Redundant data occurs when the same field in unnecessarily duplicated in two or
more tables.
Storing the same data multiple time can also lead to the problem of data
inconsistency. This is because data can change within the database.
Storing data at an atomic level means that they cannot be further decomposed.
First normal form (1NF)
First normal form is when attributes and groups are not repeated. All of the data must be
atomic within the database.
Repeating group → A group of values is stored within one cell in the database instead of a
single value.
To fix repeating groups, they should be replaced by creating one record for each
combination of the group.
Fundamentals of databases 2