Mind map
The Relational Model
Map content
The Relational Model
A tuple
- an attribute, or field.
- A domain
- the set of possible values they can take.
- Each element in a tuple
- the components of a room (door, window, etc)
- each attribute has a domain (type of window, color of the door, etc).
- corresponds to a single column in the table
- A domain
- The elements in each tuple are named and not ordered
- so it is easy to access and query specific pieces of information.
- a mathematical concept
- that represents an ordered list of elements.
- often referred to as a single record
- frequently implemented as a row in a table.
- A tuple is like a room
- it has multiple attributes (doors, windows, etc)
- it's ordered.
- corresponds to a single row in the table
- an attribute, or field.
A relation
- A set
- Every relation is a set
- every relation is a mathematical set of ordered elements
- Not every set is a relation
- to qualify as a relation
- a set must also adhere to certain mathematical constraints
- such as the requirement that each tuple in the set have the same number of elements and that the values of those elements be atomic or scalar.
- a set must also adhere to certain mathematical constraints
- to qualify as a relation
- Every relation is a set
- A Table
- a common implementation of a relation
- a table is a physical implementation of a relation.
- Every relation can be perceived as a table
- a relation is often implemented as a table
- in a relational database management system (RDBMS).
- Object-oriented databases (OODBs)
- a type of database management system (DBMS)
- based on the object-oriented programming (OOP) paradigm
- They store and manage data in the form of objects
- which are instances of classes and have attributes and methods
- allow for the modeling of complex relationships and structures
- such as inheritance and polymorphism
- which are not easily represented in relational databases
- such as inheritance and polymorphism
- key features
- Support for encapsulation
- which allows for the hiding of internal details and implementation of an object from the outside world.
- Support for inheritance
- which allows for the creation of new classes based on existing classes.
- Support for polymorphism
- which allows for the use of a single interface to represent multiple types of objects.
- Support for encapsulation
- typically used in applications that require the modeling and manipulation of complex data structures and relationships
- the object identifier (OID).
- The alternative to the primary key used in object-oriented databases
- a unique identifier assigned to an object in an object-oriented database
- It is used to identify and retrieve objects stored in the database
- similar to how a primary key is used to identify and retrieve records in a relational database
- Object-oriented databases (OODBs)
- in a relational database management system (RDBMS).
- a relation is often implemented as a table
- Not every table is a correct perception of a relation
- a table may not adhere to the mathematical constraints of a relation
- such as having duplicate rows or not having unique keys.
- a table may not adhere to the mathematical constraints of a relation
- A candidate key
- a set of one or more columns in a table that can uniquely identify each row in the table
- it is a set of columns that can be used as a primary key
- A candidate key must have the following properties
- Uniqueness
- No two rows can have the same values in the candidate key columns.
- Non-nullability
- The columns in the candidate key cannot contain null values.
- Uniqueness
- The purpose of a candidate key is to ensure that every row in a table can be uniquely identified and to prevent data duplication.
- a set of tuples, or rows
- that are organized in a table.
- A relation is like a floor
- it has multiple rooms (tuples)
- it's organized.
- A set
A schema
- a plan of how data is organized
- it's like a blueprint.
- A schema is like the blueprint of the house
- it shows the overall structure and organization of the house.
- A schema is like the blueprint of the house
- It includes logical constraints
- such as table names, attributes, and entity relations.
- commonly represented visually
- to convey the overall structure of the data.
- Some databases use the term schema interchangeably with the database itself
- for example, MySQL uses schema interchangeably with the database.
three main aspects
- structural
- The data in a relational database is perceived by the user as tables, and nothing but tables.
- the data is organized in a tabular format, with rows and columns, and the user interacts with the data through these tables.
- Structural aspect is like the recipe
- it shows how the ingredients (data) should be organized and presented.
- The data in a relational database is perceived by the user as tables, and nothing but tables.
- manipulation
- The relational model provides a set of operators
- such as SELECT, JOIN, and UPDATE
- can be used to manipulate the data in the tables.
- These operators allow the user to query, update, and modify the data in the tables.
- such as SELECT, JOIN, and UPDATE
- Manipulation aspect is like cooking tools
- it allows the cook to manipulate the ingredients in different ways (query, update, modify) to create different dishes.
- The relational model provides a set of operators
- integrity
- The relational model also includes integrity constraints
- which are rules that ensure the consistency and accuracy of the data in the tables.
- These constraints can include things like unique keys, referential integrity, and domain constraints.
- constraints that maintain referential integrity
- Primary key constraint
- Ensures that each row in a table has a unique identifier
- A Composite Key
- a primary key made up of two or more columns
- It is used when no single column can uniquely identify a record.
- Foreign key constraint
- Enforces referential integrity by ensuring that any value entered into a foreign key column in one table must match a primary key value in the referenced table.
- NOT NULL constraint
- Ensures that a column does not contain null values.
- UNIQUE constraint
- Ensures that no duplicate values can be entered into a specific column or set of columns.
- CHECK constraint
- Allows for the definition of custom rules to validate data input.
- DEFAULT constraint
- Allows for the definition of a default value for a column when no value is specified.
- Primary key constraint
- The integrity aspect of the relational model answers the question of how one can mess up the database if they wanted to.
- Integrity aspect is like hygiene and quality control
- it ensures that the ingredients are fresh and safe to eat, and the dish is cooked correctly.
- The relational model also includes integrity constraints
- structural
proposed in 1969 by Edgar F. Codd
- as a way to organize data in a structured and efficient manner.
includes a set of operators
- such as SELECT, JOIN, and UPDATE
- that can be used to manipulate the data in the relations.
- such as SELECT, JOIN, and UPDATE
SQL (Structured Query Language)
- a practical implementation of the relational concept
- a table as implemented by MySQL is a physical representation of data stored on disk.
- the standard language used to manage relational databases.
- implemented with specific storage engines and have unique features and performance characteristics
- such as the ability to define indexes, partition tables and use of specific data types.
- Data manipulation
- Requesting data
- Inserting data
- Deleting data
- Changing data
- Data definition
- Creating tables
- Deleting tables
- Changing tables
- Data types
- BOOLEAN
- true/false
- INTEGER
- DECIMAL
- exact fixed point number —good for money
- DOUBLE
- 64 bit floating point numbers
- DATE
- DATETIME
- a date plus time —good for creation/modification times
- CHAR(n)
- fixed length character string
- VARCHAR(n)
- variable length character string
- TEXT
- strings of text
- BLOB
- binary storage
- BOOLEAN
- Natural join
- based on matching column names and types
- return only the rows that have matching values in both tables being joined
- Relational model: JOIN is the ‘natural join’
- Inner join
- return only the rows that have matching values in both tables being joined
- uses an explicit join condition specified in the ON clause.
- Cartesian product
- also known as a cross join
- returns every possible combination of rows from both tables being joined
- It does not rely on matching column names or an explicit join condition, but rather returns all possible combinations of rows from the two tables
- This can result in a large number of rows and is typically not desired unless it is the intended outcome.
- SQL: 'JOIN' is the cartesian product of the tables
- a practical implementation of the relational concept
relational databases is like a library.
- A library has books
- which are organized in shelves
- each book has its own specific information
- a librarian uses a catalog system
- to find a specific book
- A library has books
an abstract theory of data management
- such as set theory and predicate logic.
- that is based on sound mathematical principles
It provides a way to organize data
- in a structured and efficient manner.
a relational variable
- a mathematical construct that represents a set of tuples (rows) with a specific set of attributes (columns)
- a pure mathematical construct
- which is independent of any specific implementation
Manipulation
- Three fundamental operators
- Restrict
- Project
- Join
- The result of any of these operations will be a table
- Three fundamental operators
Relational expressions
- Output from each expression is a table
- Output from one expression can form input to another
- Relational expressions can be nested
Optimisation
- Relational languages are declarative languages
- The query optimizer is vital!
Two types of languages
- Procedural
- Series of steps
- Interpreter
- Need to ensure steps produce result
- Declarative
- Describe what you want
- Interpreter figures out the steps
- Optimiser is very important!
- Less code = more productive
- Procedural
the Catalogue
- a table or set of tables that contains metadata about the database
- this includes information about the tables, columns, and constraints in the database, as well as information about the users and their permissions.
- a table or set of tables that contains metadata about the database
Information
- Description
- Mind Map on The Relational Model, created by Sakan Nirattisaykul on 17/01/2023.
- Created by
- Sakan Nirattisaykul
- Views
- 0
- Rating