Overview of Structured Query Language (SQL)

Nov 20, 2024

Introduction to Structured Query Language (SQL)

Definition

  • SQL stands for Structured Query Language.
  • It is the gold standard for communicating with relational database management systems (RDBMS).

Popular SQL Databases

  • Examples include:
    • MySQL
    • PostgreSQL
    • Microsoft SQL Server
    • Oracle

History

  • Developed in the early 1970s.
  • Initially created for IBM's System R database.
  • Standardized by 1986, maintaining a popular syntax.

Relational Database Structure

Organization of Data

  • Data is organized into tables (similar to Excel spreadsheets).
  • Columns: Contain attributes or types of data.
  • Rows: Represent individual records or data points with a unique identifier known as the primary key.

Relationships

  • Establish relationships between data points using:
    • Foreign Key: The unique ID from one row stored in another table.
    • Example:
      • Teams Table: Team ID as the primary key.
      • Players Table: Team ID as the foreign key indicating which players belong to which team.
  • This structure reduces duplication and redundancy in the database.

Functions of SQL

Basic Operations

  • SQL is used to:
    • Read data
    • Create data
    • Update data
    • Delete data

Joining Data

  • SQL can also join data based on established relationships.

SQL Syntax Overview

Components of a SQL Statement

  • Statement: A piece of code that performs an action (e.g., reading, writing).
  • Keywords: Special terms that manipulate the database.
    • SELECT: Used to query specific columns from a table.
    • FROM: Indicates the table to query data from.
    • WHERE: Filters results to include only records meeting certain conditions.
    • JOIN: Connects data from different tables by matching primary keys to foreign keys.

Execution

  • SQL statements can be executed on various databases that support SQL.

Conclusion

  • SQL provides a structured way to manage and manipulate relational data efficiently.
  • Encouragement to like and subscribe for a full SQL tutorial.