What Is A Database
What Is A Database
What is a Database
company
compname sales assets netincome empls indcode yr
...
42 pharmaceuticals
44 computers
...
2
Page 1
Information is in tables
z Also called (base) relations
Page 2
from tables
SELECT *
FROM company;
Page 3
Choose Columns
allied -279000 85
boeing 292000 82
...
Choose Rows
Page 4
Compute Columns
Sorting
10
Page 5
Aggregates
12
Page 6
More examples
13
Joins
Combine rows from one table with rows
from another
Usually join on some common column
z Don't combine rows unless their value in the
common column is the same
z Where clause says the common column must be
same in each table
14
Page 7
company
compname sales assets netincome empls indcode yr
...
42 pharmaceuticals
44 computers
...
15
SQL Summary
from tables
16
Page 8
Meaningful tables
17
Meaningful Tables
18
Page 9
19
Key: a set of columns that picks out a unique row from the
table
z Last name not a key
z First name not a key
z First + middle + last may be a key
- Social security number may be a more reliable key
20
Page 10
21
22
Page 11
23
Page 12