Databases and Software Development Flashcards
Database
Organised collection of data that is structured in a way to facilitate efficient retrieval, updating and analysis of data
Data model
Describes data, its structure, its relationships and constraints for a given system
Factors to consider when modelling entity relationships
- Data needed to be stored
- What real-world entities this data relates to
- Relationships between entities
- Constraints on data
Entity
Object about which data is being stored
Entity representation in databases
As tables
Attribute
Property of an entity
Attribute representation in databases
As fields/columns
Instance
Details of a particular occurence of an entity
Instance representation in databases
As records/columns
Relationship types
- One-to-one (e.g. a school has one headteacher; a headteacher only has one school)
- One-to-many
- Many-to-one
- Many-to-many (resolved by creating two one-to-many relationships)
Relational database
Type of database where:
* Separate table created for each entity
* Where relationship exists, foreign key links two tables
Entity identifier
(Collection of) attributes that uniquely identifies each instance of an entity
Primary key
Practical implementation of entity identifier
Foreign key
Attribute that creates a join between two tables (is primary key of another table)
Entity descriptions
Entity(Primary key, Attribute2 …)
Entity relationship diagrams
- Diagrammatic way of representing the relationships between the entities in a database
- Crow’s feet = many side
Problem with many-to-many relations
Storing multiple foreign keys per instance -> Unnormalised entity -> Inefficiency
Resolving many-to-many relations
- Composite/link entity created
- Each instance represents each relation by storing both foreign keys
- Create two one-to-many relations
Composite primary key
Consists of more than one attribute
Relation
Entity that is linked to other entities
Tuple
Row within relation (represents instance)
Normalisation
Process of structuring data in a relational database to reduce redundancy, increase accuracy and increase efficiency
Key features of normalisation
- No redundant data
- Each relation represents a single concept
- Data is stored at its atomic level (can’t be decomposed further)
Redundant data
Unnecessarily duplicated data
Why is redundant data bad?
- Redundant data → Wasted space and slower searching → Inefficiency
- Redundant data → ↑ Chance of incorrect copying → Inconsistent and inaccurate data
Atomic-level data
Data has been fully decomposed into multiple attributes
Levels of normal form
- First normal form (1NF)
- Second normal form (2NF)
- Third normal form (3NF)
First normal form (1NF)
Data is fully atomic and doesn’t have multiple values for any attributes (repeating groups)