-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcs50 week 7 notes.txt
72 lines (50 loc) · 1.32 KB
/
cs50 week 7 notes.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
cs50 SQL notes
Spreadsheets strengths and weaknesses:
Strengths:
Good at sorting
Common to use
visual
Weaknesses:
Limits on amount of data you can use
Static schema
flat-file database:
single, 1-file database. commonly CSV
Lambda functions: One-line functions
Lambda functions are anonymous (nameless) functions
Still takes arguments, returns a value.
of the form:
lambda <arg>: <expression or value to return>
ex:
lamba x: x**2, takes x, returns x^2
relational databases:
SQLite
uses a single binary file to store all data
to interact with that blob, use sqlite3, a cli tool
loading data onto a sqlite db:
load via sqlite3
or, load via python
.mode (ex: .mode csv, or .mode xls, tsv (tab sep val))
.import <filename> <table name>
SQL: Structured Query Language, a language to maniuplate data
CRUD: Create, Read, Update, Delete
corresponding SQL commands for crud:
CREATE, INSERT (initialize table+data vs add data)
SELECT (in for read)
UPDATE
DELETE
sqlite3 commands start with a .
.mode <filetype>
.import <filename> <table name>
.schema: returns the CREATE TABLE command used
SQLite has 5 major datatypes:
blob ("Binary Large OBject")
integer (typically 32 bits)
numeric (Formatted numbers, like datetimes or bools)
real
text
Also has:
NOT NULL
UNIQUE
Primary and Foreign keys
Using Python and SQLite together:
import sqlite3