Skip to content

Instantly share code, notes, and snippets.

@bayendor
Last active August 29, 2015 14:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bayendor/28349d301a4ef9f22cb0 to your computer and use it in GitHub Desktop.
Save bayendor/28349d301a4ef9f22cb0 to your computer and use it in GitHub Desktop.
Intro to SQL Notes

#What are database tables, column, and rows? What's the purpose of each?

Table is a collection of columns and rows

Column is a particular datatype, named with lowercase_separated_with_underscores

Row is a collection of data elements in a table each represented by a column, synonym for record

#How's a database similar and different from a spreadsheet?

Both contain rows and columns with particular datatypes, but a full database has more querying and relationship data.

Multiple users can access a database but not so for a spreadsheet.

Data storage is more efficient in a database.

Queries and reports are easier to run and refer to in a database.

Data backup and recovery is more robust.

Database is much stricter on data validation and typing.

#What's the meaning and purpose of SELECT? What about WHERE?

SELECT, TABLE, WITH -- retrieve rows from a table or view

WHERE is the condition to be satisfied in a query

#What's a foreign key? What's it used for?

Used to link tables with related data (e.g. has_many, has_one, etc.)

#SQL Queries

SQL is a declarative language: Issue a statement, get back results

SELECT, INSERT, DELETE

#Foreign Key

A convention for connecting one record to another or many records.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment