In a Relational Database Management System (RDBMS), keys and objects form the foundational architecture that allows data to be accurately stored, linked, and retrieved.
Keys play a crucial role in a relational database because they are used to uniquely identify any record or row of data within a table and to establish and identify relationships between different tables.
The primary types of keys include:
Primary Key: This is a column (or group of columns) that uniquely identifies every row in that table. A primary key has strict properties: it cannot accept duplicate values and it cannot be left blank (Null values are not accepted).
Candidate Key: This is a set of attributes that uniquely identify tuples (rows) in a table. Essentially, a table might have several attributes that could serve as the primary key; these are all candidate keys, defined as super keys with no repeated attributes.
Alternate Key: Out of all available candidate keys, only one is selected to act as the primary key. The remaining candidate keys that were not chosen are known as alternate or secondary keys.
Foreign Key: This is a column that creates a relationship between two tables. It acts as a cross-reference by pointing to the primary key of another table. Its main purpose is to maintain data integrity and allow for smooth navigation between different entities.
Super Key: A super key is a single key or a group of multiple keys that can be used to identify rows in a table.
Composite Key: This is a key that consists of a combination of two or more columns to uniquely identify rows in a table. It is used when a single column is not sufficient to guarantee uniqueness.
Compound Key: Similar to a composite key, it uses two or more attributes to uniquely recognize a specific record, especially in cases where each individual column may not be unique by itself within the database.
Surrogate Key: When a table does not have any natural primary key (no existing unique data), an artificial key is generated to uniquely identify each record, known as a surrogate key.
An RDBMS is a collection of different objects that work together to manage data. The primary objects include:
Tables: Tables are the basic building blocks of a database where all data is stored. They organize data using a grid model consisting of:
Columns (Fields or Attributes): A set of data values of a particular type. The columns define the structure according to which the rows are composed (e.g., FirstName or LastName).
Rows (Records or Tuples): A row represents a single, complete item of related data within the table.
Queries: A query is a question put up to the database to view records that match specific, defined criteria. Queries allow users to filter, view, update, insert, or manipulate selected data from either a single table or multiple related tables simultaneously.
Forms: A form is a graphical interface between the user and the database tables. Instead of working directly in a raw data table, forms provide users with a quick, convenient, and customized layout to view, edit, input, and delete records. They ensure that data is entered into the desired tables correctly.
Reports: A report is a graphical object designed to present data in a formatted, highly readable layout. Reports are used to summarize and compile data in an organized manner, making them ideal for displaying data visually and for printing.
Macros and Code: These are sets of actions or declarations written in a programming language that are created to automate common, repetitive tasks within the database system.