Databases Flashcards
Flat file DB
One single table contains all the information.
Relational DB
Several linked tables, each representing an entity in the system. Each piece of data stored only once and then looked up via links from other tables. Tables and relationships between them are managed by a DBMS (DataBase Management System).
Relational (v.s. Flat File)
Avoids data redundancy (storing same data item in more than one place) and inconsistency (two versions may be different).
Advantages of ff
Simple to construct.
Disadvantages of ff
Tedious duplicate entry of data, data redundancy, inconsistency, less integrity, hard sharing data, less control over user access
Advantages of relational
Reduced data duplication and data redundancy. Improves data consistency, data integrity and security. Control access to data.
Disadvantages of relational
More complex to set up than flat file. Need a good DBMS to ensure users only see the data relevant to them.
Entity
A thing about which data is stored e.g. customer, employee, stock).
Relationship
A link between two entities (1-1, 1-many…).
Normalisation
Resolves many to many relationships and ensures data is stored in one place and in the best place.
1NF
First Normal Form requires that there be no multivalued / repeating attributes.
2NF
Second Normal Form requires that any non-key attribute be dependent on the entire key.
3NF
The rule of Third Normal Form (3NF) states that no non-key attribute can be dependent on another non-key attribute.
Showing table design
CAPITAL letters for the name of the table, Underline the key field, Overline the foreign keys.
e.g. PATIENTS (-PatientID-, Surname, Forename, Disease, WardID ).
Primary key
A unique identifier in a table. Can consist of one or more fields. If more than one field it is known as a composite primary key.
Composite key
2 or more attributes that uniquely identify an entity occurrence.
Secondary key
An attribute which can be used to search for information or allows records to be sorted (accessed in a different order).
Secondary keys are indexed which allows for fast searching of the data in a database.
Foreign key
Is a primary key from one table used as an attribute in another to link the tables. They represent many to one relationships.
DBMS
SW handling the complexities of managing a database. May provide a user interface and use SQL to communicate with other programs. It provides different views of the data for different users.
Tasks performed by DBMS
Finds data, adds new data, updates data, maintains indexes, enforces data integrity rule, manages access rights.
DBMS Access rights
Controls what data each user is allowed to see. Also controls what they are allowed to do with the data (view, update etc).
Database schema
Is the structure of the database that defines the objects in the database.
Data dictionary
A file containing descriptions of data in a database, used by database managers when altering database structure, uses metadata to define the tables.
Data dictionary - examples
Names of tables, characteristics (length, data type…), restrictions of values in columns, meaning of data columns, relationships between data, which programs can access the data. Identifies: primary and foreign keys, indexes and defines access rights.