SQL

Structured Query Language, is also known as Relational Database

Keywords

Why SQL is called Relational Database?

A relational database is one that stores data in tables. The relationship between each data point is clear and searching through those relationships is relatively easy.

The relationship between tables and field types is called a schema. For relational databases, the schema must be clearly defined

Relationships are established through Primary and Foreign keys

What is normalisation?

Database design technique that reduces data redundancy and eliminates undesirable characteristics like Insertion, Update and Deletion Anomalies.

Normalisation rules divides larger tables into smaller tables and links them using relationships.

The purpose of Normalisation in SQL is to eliminate redundant (repetitive) data and ensure data is stored logically.

What is a key?

A value used to identify a record in a table uniquely.

A KEY could be a single column or combination of multiple columns

  • Primary Key:

    A primary key is a single column value used to identify a database record uniquely

    • A primary key cannot be NULL

    • A primary key value must be unique

    • The primary key values should rarely be changed

    • The primary key must be given a value when a new record is inserted

  • Composite Key: is a primary key composed of multiple columns used to identify a record uniquely

  • Foreign Key:

    A foreign key is references the primary key of another Table

    • A foreign key can have a different name from its primary key

    • It ensures rows in one table have corresponding rows in another

    • Unlike the Primary key, they do not have to be unique. Most often they aren't

    • Foreign keys can be null even though primary keys can not

Schema and Queries Use Case?

  • How normalisation is used?

  • How multiple tables are used to store data?

  • How concepts of primary and foreign keys are used to retrieve data and presented as per requirement?

All this concepts can be understood by looking at one use case of Stack Overflow data, go through the "Use Cases" page link as attached, to understand it better

Use Cases

SQL Database Properties

ACID Property

References for Further Reading

There are multiple lectures, go through all the topics; very informative

Last updated

Was this helpful?