Databases store and organize data. So, think of relational databases (RDB) as a type of database that organizes data into tables and establishes the relationships between these tables.
But the goal of having a database is more than just to store data.
You'd also need to access the stored data and perform various operations. That's where SQL comes in. Structured Query Language allows you to manage and manipulate the data stored in a relational database.
It's no wonder why relational databases are also called SQL databases.
In a RDB, tables are like smaller containers that hold similar pieces of information. For example, you could have a customer management database containing two tables. The first table stores customer information, and the second stores order info.
Every table has columns and rows (similar to spreadsheets). Columns contain specific information about the data. In our customer example, columns could be name, contact info, or address.
Rows contain all the information about a specific record or customer. In order to retrieve a record or row in our table, we need a primary key. As a result, a primary key has to be unique for every record in a table.
To link these tables in a RDB together, we use foreign keys.
A foreign key is a field in one table that references the primary key of another table. In this case, the orders table would have a foreign key referencing the customer table's primary key.
Top comments (0)