commiting before merge conflicts

This commit is contained in:
shockrahwow
2018-09-12 20:54:17 -07:00
17 changed files with 32920 additions and 23 deletions

View File

@@ -3,12 +3,12 @@
## Relational Algebra and its relation to SQL
### SELECT
Used to select rows from some table.
Used to select columns from some table.
> Relational symbol: sigma
### Projection
Picks out the columns of a (set of) table(s)
Picks out the rows of a (set of) table(s)
> Relational symbol: pi

15
cst363/lec/lec4.md Normal file
View File

@@ -0,0 +1,15 @@
# lec4
## Lab*
This lecture has some lab questions in the `lab/` dircory named `table1.pdf` *and* some example data called `patients.sql`.
`table1.pdf` will have some exercises to learn the basic commands of sqlite and `patients.sql` should have some example data which _table1_ asks you to query.
## Serverless
Instead of having listen server listen for requests to perform actions upon these requests we simply have some databse held on a machina and we perform all of our sql commands on that machine.
For now we'll be dealing with small test db's so that we can practice the commands and observe each one's behavior; this will give you a good feeling of what does what in sqlite3.

39
cst363/lec/lec5.md Normal file
View File

@@ -0,0 +1,39 @@
# lec5
## Lab
This lecture will have a lab activity in `cst366/lab/1994-census-summary.sql` with instructions found in `single-table-queries-2-lab.pdf`.
## Distinct Values
> Mininum - min(field)
Finds the smallest value in the given filed
> Maximum - max(field)
Find the largest value in th given field
Say we have a column where we know there are duplicate values but we want to konw what the distinct values in the column may be.
SQLite3 has a function for that: `select distinct field, ... from table;`
> select substr(field, startIndex, length) ...
_Note_: the start index starts counting at `1` so keep in mind we are offset `+1`.
## Joins
Now we want to join to tables together to associate their respective data.
Important to note that a simple join does not necessarily take care of duplicate fields.
If we have duplicate fields we must denote them as `target.field`.
Here target is the table with the desired table and field is the desired field.
## Type Casting
If we have say `56` we can use a cast to turn it into an integer.
> cast(targetString as integer)
This will return with an error if a non number character is given as input to the cast function, here in this example we denote it with `targetString`.