WebFund 2014W Lecture 7: Difference between revisions
No edit summary |
No edit summary |
||
Line 4: | Line 4: | ||
* [http://dl.cuol.ca/capture/Anil.Somayaji/COMP_2406_2014W_Lecture_7_-_20140129_143752_27.mp4 Original from CUOL] | * [http://dl.cuol.ca/capture/Anil.Somayaji/COMP_2406_2014W_Lecture_7_-_20140129_143752_27.mp4 Original from CUOL] | ||
Databases | == Databases == | ||
why? | why? | ||
* Persistence - You want to stick around (vs. RAM) | * Persistence - You want to stick around (vs. RAM) | ||
Line 20: | Line 20: | ||
* columns (fields) | * columns (fields) | ||
== Example == | |||
Table: People | Table: People | ||
Line 55: | Line 54: | ||
* Simplest: sorts specific fields in a table (create secondary keys) | * Simplest: sorts specific fields in a table (create secondary keys) | ||
Secondary key Primary key | |||
======== ======= | |||
First Name ID | |||
--------- -- | |||
Anil 1 | |||
Dana 2 | |||
Annie 3 | |||
* sort the names Alphabetically. | |||
Transactions: | Transactions: |
Revision as of 16:59, 13 March 2014
The video from the lecture given on January 29, 2014 is available:
Databases
why?
- Persistence - You want to stick around (vs. RAM)
- Concurrency in writes - (vs. files)
- Search - (vs. files)
- Dynamic data should NOT be stored in files.
SQL(Structured Query Language) vs. NoSQL
- SQL makes queries to databases, assuming queries are highly structured.
- for relational databases.
What is a structure of a relational database? e.g. Tables - relations connect fields between tables
- rows (records)
- columns (fields)
Example
Table: People
ID First Name Last Name Phone Email 1 Anil Somayaji 555-1212 soma@scs.carleton.ca 2 Dana Somayaji 555-1212 dana@example.ca (should check whether it is a valid address)
Validation Problem:
- Where to check for bad data?
- Can do on:
- Web client (helpful)
- Web server (must)
- Database (useful)
Example continued:
Table: Invoices
Inv. ID Description Amount Customer 1 iPad $700 1 <- Which is Anil in the People table) 2
- One relation: Invoice = Customer ID -> People ID
Could ask for simple queries:
- All records in People with first name == Anil
- Which customer has spent the most in our store?
- Sum of all invoices for each customer
- find max
Indexing:
- Simplest: sorts specific fields in a table (create secondary keys)
Secondary key Primary key
== =
First Name ID
--
Anil 1 Dana 2 Annie 3
- sort the names Alphabetically.
Transactions:
- What if I want to change records in multiple tables in a coordinated fashion?
- Airline example
- Reserve seat
- Pay
- Commit: check that payment and reservation both worked first
NoSQL Databases: No transactions, no real relations