An introduction to SQL database queries and concepts.
Computers become cost-effective enough for private businesses to use them for data management
E.F. Codd, working for IBM, publishes a paper describing the relational database model.
SQL becomes a technological standard for query languages.
After a period of heavy market saturation, remaining database companies continue to sell their products at high prices.
Interactive applications are created to interact with databases.
A representation of how information is organized in a database.
Database design focus on the data application, instead of logical table structure.
A database schema, or logical organization, is disconnected from how the information is physicaly stored on the computer.
A set is a collection of things
where each thing in the collection is unique.
We write sets as a comma seperated list
inside a pair of curly braces.
The main application of relational algebra is providing a theoretical foundation for relational databases, particularly query languages for such databases, chief among which is SQL. (wikipedia.org/relational_algebra)
The union of two sets A and B
is the set of elements which are
in A, in B, or in both A and B.
The intersection of two sets A and B
is the set that contains all elements of A that also belong to B.
The Cartesian product of sets A and B is the set of all ordered pairs (a, b) where a ∈ A and b ∈ B.Example
A projection is the subset of available columns based on a set of attribute names where attributes not listed in the set have been discarded.
A selection is an operation that returns a subset of the rows in a database.
SELECT column_name, column_name
WHERE column_name operator value;
WHERE Age > 20
AND Age < 30;
SELECT Name, Address
FROM Account, Location;
|email@example.com||24 Main Street||Springfiled||MA|
|firstname.lastname@example.org||208 Innovation Drive||Silicon Valley||CA|
|email@example.com||4 Pine Grove Lane||Ducktrap||ME|
Since we have 3 Accounts and 3 Locations, the cardinality of the cartesian product will be 108.
This is because each tuple in the Account table contains 3 elements and we have 3 Accounts. There is 4 elements in row of the Location table and there is 3 rows. (3 * 3) * (3 * 4) = 108
SELECT Email, Name
WHERE Age < 50;