Relational Databases and SQL
86 Relational Database Concepts
86 Relational Database Concepts
Overview 📘
A database is a way of storing data (information) on a computer in an organised way, so it can be easily searched, sorted, and updated. It is especially useful when we need to store lots of related data, like customer details, school records, or product lists.
-----------------------------------------
Databases can be flat-file or relational:
A flat-file database stores all the data in a single table.
A relational database uses multiple tables that are linked together by key fields.
-----------------------------------------
A table in a database is made up of:
Fields (also called columns) – These are the categories of data (e.g. Name, Age).
Records (also called rows) – These are individual pieces of data (e.g. one student’s details).
Each table should have a primary key, which is a unique value that identifies each record (e.g. Student ID).
-----------------------------------------
Relational databases use foreign keys to connect different tables together.
For example:
A Student table might link to a Class table using a class ID.
This reduces data repetition and keeps the database efficient and accurate.
-----------------------------------------
Databases store data in tables with fields and records.
Flat-file databases have one table; relational ones have several linked tables.
SQL is used to manage and search data in databases.
Primary and foreign keys help organise and connect data.