Junior
What are relational databases made of?
sobes.tech AI
Answer from AI
Relational databases consist of the following main elements:
- Tables (Relations): The primary components for storing data. Each table is a set of rows (tuples) and columns (attributes).
- Rows (Records / Tuples): A single entry in a table containing data about one instance of an entity.
- Columns (Fields / Attributes): Represent a specific data type or characteristic of the entity described by the table. Each column has a name and a data type.
- Keys: Used to establish relationships between tables and ensure data integrity. Main types of keys:
- Primary Key: Uniquely identifies each row in a table. Cannot be NULL.
- Foreign Key: A reference to the primary key of another table, establishing a relationship between them. Can be NULL if not specified otherwise.
- Unique Key: Ensures the uniqueness of values in a column or a group of columns, but can contain one NULL value.
- Indexes: Structures that allow faster search and sorting of data in tables.
- Relationships: Links between tables established using foreign keys. Types of relationships:
- "one-to-one"
- "one-to-many"
- "many-to-many"
- Integrity Constraints: Rules that ensure the accuracy and consistency of data. Examples: NOT NULL, UNIQUE, CHECK, PRIMARY KEY, FOREIGN KEY.
- Schemas: Logical structure of the database describing tables, columns, data types, constraints, and relationships.
- Views: Virtual tables based on the result of an SQL query. They do not store data physically but represent a specific set of data from one or more tables.
- Triggers: Procedures that automatically execute in response to certain events (e.g., INSERT, UPDATE, DELETE) in a table.
- Stored Procedures: Sets of SQL operators that are compiled and stored in the database. They execute as a single unit.