CH 4 - Relational Modelling Flashcards
know how to perfom RESTRICT , CASCADE , NULLIFY, TRIGGERS, draw fk and pk
What is a data model in the context of databases?
A data model is a representation or a way to organize data for databases.
Name three types of data models and briefly describe them.
Hierarchical Data Model: Organizes data as a tree structure where a record is linked to only one parent record.
Network Data Model: Organizes data as a network where a record can be linked to other records in an arbitrary way.
Relational Data Model: Organizes data into sets but appears to the user as tables.
What are the three main concerns of the Relational Model?
Data Structure: How data is represented.
Data Integrity: What data is allowed.
Data Manipulation: What you can do with the data.
What are the three components of a data model?
Data Model = Structure + Rules + Manipulation
Structure: Concepts in the data model available to store data (e.g., tables).
Rules: Constraints applied to maintain data integrity (e.g., primary keys).
Manipulation: Query language used to create, delete, update, and retrieve data (e.g., SQL).
In a relational database, how is data stored and represented?
Data is stored in relations (tables),
where each relation has a scheme (heading) that defines the relation’s attributes (columns).
Data takes the form of tuples (rows).
What are the properties of relations in a relational database?
The tuples (rows) of a relation are unique and unordered.
The number of tuples is called the cardinality of the relation. The attributes (columns) of a relation are unique and unordered. The number of attributes is called the degree of the relation.
What is the role of data integrity in a relational database?
Data integrity controls what data can be in a relation.
ensuring the correctness and consistency of data by enforcing domains, candidate keys, primary keys, and foreign keys.
What is a domain in the context of attributes in a relational database?
A domain is a set of possible values for a specific attribute. Each tuple contains a value for each attribute from the domain of the attribute.
What is a candidate key?
A candidate key is a set of attributes in a relation that uniquely identifies a tuple and has the properties of uniqueness and minimality.
What is a primary key in a relational database?
A primary key is one of the candidate keys chosen to uniquely identify tuples in a relation. It cannot contain NULL values, ensuring entity integrity.
How is missing information represented in a relational database?
Missing or unknown values are represented using NULLs.
What is a foreign key, and what does it enforce?
A foreign key is a set of attributes in one relation (the referencing relation) that matches a candidate key in another relation (the referenced relation), enforcing referential integrity between the two relations.
What is referential integrity, and how can it be violated?
Referential integrity ensures that relationships between tables remain consistent.
It can be violated when a referenced tuple is updated or deleted.
What are the options to handle violations of referential integrity?
RESTRICT: Stop the action that violates integrity.
CASCADE: Let the changes flow on to related records. NULLIFY: Set the problematic values to NULL. Triggers: Use user-defined actions to handle the changes.
What does the RESTRICT option do in the context of referential integrity?
RESTRICT stops any action that would violate referential integrity, preventing updates or deletions that would break relationships between records.