Fundamentals of SQL Flashcards
SQL
Structured Query Language. Special purpose programming language. Built to manipulate relational databases. Declarative language.Contains both a data definition syntax as well as a data manipulation syntax.
Database
Container that helps us organize data in a way that makes the data useful or constructive. Useful when you have some threshold amount of data. 500 excel spreadsheets instead of 5. Putting all of the data in one place makes it easy to query data, update data, insert new data, and delete old data. One source of truth rather than many sources of truth. Many types: relational, object-oriented, document-based.
Relational
Data and relationship between data entities. The pure Relational Model is math all the way down. Based on relational algebra and tuple relational calculus.
Table
In a relational database, data is stored in a construct known as a Table. Name, and a collection of Columns.
Column
Has a name. Has a restriction that restricts the size and category of data that can be stored in that Column.
Required Columns
row contains data. Data not required is referred as null.
Rows
Rows can be retrieved by asking questions of the data. Put data in a database to get it out and find answers to questions. Questions will related to values stored in those columns. “Who are all my contacts that have a phone number that starts with 310?” Asking such questions with SQL is known as querying.
Keys
Belong to tables. Each table should/must have one column that uniquely identify a row. This column is known as the Primary Key. If more than one table uses the same primary key, you can then merge those two tables together.
Foreign Key
Table can also have a column that is classified as foreign. This key links that table to another Table’s Primary Key. Allows rows from each table to be linked together.
Natural Keys
Like an ISBN number for a book - unique across all published books on the planet.
Invented Keys
Usually an integer is sufficient. Often a database will add this data in each row automatically for you - often called an identity column.
Normalization
The design process in database design.
SQL Statement
A valid SQL statement is made up of an actionable set of valid words. Some of the words are defined by SQL, some are defined by you. SQL is english-based so it is readable. Not case-sensitive.
Clause
Most parts of a SQL statement can be broken down into clauses. SQL component parts.
Valid SQL Statement
A valid SQL statement has a semi-colon(;) at the end of the statement.