SQL Notes1
SQL Notes1
It
was developed by Donald D. Chamberlin and Raymond F. Boyce at IBM. They
designed it to manage and query data stored in relational database systems
based on the relational model formulated by Edgar F. Codd.
SQL
The first version of SQL was created as part of a project called System R, which
aimed to demonstrate the feasibility of relational databases. Over time, SQL
became the standard for relational database management systems, and today, it
is widely used in applications ranging from small-scale projects to enterprise
systems.
- Scores Table:
student score
_id subject
1 Math 95
2 Science 89
Relationships between these tables (using `student_id`) allow easy queries, such
as retrieving a student’s name and their scores.
- Applications:
- Commonly used in web development (e.g., for storing user information,
orders, and more).
- Works well for both small-scale projects and enterprise-level systems.
For example:
- SUM: Combines values in a column to calculate a total.
- AVG: Computes the average of values in a column.
- COUNT: Counts the number of entries in a column.
- MAX: Identifies the largest value in a column.
- MIN: Finds the smallest value in a column.
JOINs are used in SQL to combine data from two or more tables based
on related columns, making it easier to analyze financial records across
multiple tables.
- INNER JOIN: Returns only matching rows from both tables. For example, if you
have a `Transactions` table and an `Accounts` table, an INNER JOIN will show
transactions that match accounts in both tables.
- LEFT JOIN: Returns all rows from the left table and matching rows from the
right table. If there’s no match in the right table, NULL is displayed for the
unmatched data. For example, you can list all accounts, even if some have no
transactions recorded.
Both are essential for extracting and correlating financial data across tables.