Databases Flashcards
Data inconsistency
Data held in more than one place in the database that could be changed in one place but not in the other
Can be a waste of disk space
Data redundancy
Data held in more than one place in the database
The data doesn’t need to be held more than once so the data becomes redundant
Wastes processing time to update different copies
Data independence
Data acts as a repository or pool of data, separate from the applications that deal with it
Keeping the data separate from the applications that use it is known as data independence
Can create applications without changing the way data is stored
Flat file databases
Very basic systems that can have multiple tables but they aren’t linked
Useful if simple information is being recorded
What are the potential problems with flat file databases
Potential inconsistency
Potential redundancy (wasting space as same information stored more than once
Takes longer to enter information as it has to be entered more than once
Potential loss of data
What are the advantages of relational databases over flat file
A relational database allows data to be held in multiple tables that can have relationships between them
A well designed (normalised) database will not gave any of the problems associated with flat file databases (redundancy, inconsistency, etc.)
By splitting the single table into multiple tables it is possible to hold the exact same information without the problems of a flat file (redundancy, inconsistency etc.)
Define a primary key
A field in a table which uniquely identifies a record, e.g. a pin uniquely identifies a student
Composite primary key
More than one field is needed to uniquely identify a record
Surrogate primary key
A record identifier automatically generated by the database management system e.g. CustomerID, SalesID, etc.
Foreign key
A field in a table that is a primary key in another table used to form a link between the two
Indexes
Allows searches to be performed much more quickly
A table can have several indexes if required
Downsides of indexes
More memory is required to hold each index and every time a record is added or deleted the index needs to be updated which can add a slight delay
Therefore only fields which are regularly used in searches should be indexed
Three types of relationship in ERD
Many to many -> create a new entity in the middle to make two one to Many relationships
Many to one
One to many
Rule of ERDS
If you have a one to many relationship, copy the primary key from the entity at the ‘one’ end of the relationship to the ‘many’ end to become the foreign keys
Data normalisation
A database design technique which tries to ensure that a database in designed correctly, avoiding the various problems we have seen with inconsistency and redundancy