Top Banner
1 SELECT statement
66

1 SELECT statement. 2 Sample database Supplier Part supplies (0,n) colour s# snamep# pname amount citydob price qualitydate.

Dec 26, 2015

Download

Documents

Blaze Riley
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: 1 SELECT statement. 2 Sample database Supplier Part supplies (0,n) colour s# snamep# pname amount citydob price qualitydate.

1

SELECT statementSELECT statement

Page 2: 1 SELECT statement. 2 Sample database Supplier Part supplies (0,n) colour s# snamep# pname amount citydob price qualitydate.

2

SELECT statementSELECT statement

• Sample database• Sample database

Supplier Part

supplies

(0,n) (0,n)

colours# sname p# pnameamount

city dob price qualitydate

Page 3: 1 SELECT statement. 2 Sample database Supplier Part supplies (0,n) colour s# snamep# pname amount citydob price qualitydate.

3

SELECT statementSELECT statement

• Sample database

Supplier( s#, sname, city, dob )

• Sample database

Supplier( s#, sname, city, dob )

primary key

Page 4: 1 SELECT statement. 2 Sample database Supplier Part supplies (0,n) colour s# snamep# pname amount citydob price qualitydate.

4

SELECT statementSELECT statement

• Sample database

Supplier( s#, sname, city, dob )

Part( p#, pname, colour, weight, quality )

• Sample database

Supplier( s#, sname, city, dob )

Part( p#, pname, colour, weight, quality )

primary key

primary key

Page 5: 1 SELECT statement. 2 Sample database Supplier Part supplies (0,n) colour s# snamep# pname amount citydob price qualitydate.

5

SELECT statementSELECT statement

• Sample database

Supplier( s#, sname, city, dob )

SP( s#, p#, sdate, amount )

Part( p#, pname, colour, weight, quality )

• Sample database

Supplier( s#, sname, city, dob )

SP( s#, p#, sdate, amount )

Part( p#, pname, colour, weight, quality )

primary key

primary key

primary key

Page 6: 1 SELECT statement. 2 Sample database Supplier Part supplies (0,n) colour s# snamep# pname amount citydob price qualitydate.

6

SELECT statementSELECT statement

• Sample database

Supplier( s#, sname, city, dob )

SP( s#, p#, sdate, amount )

Part( p#, pname, colour, weight, quality )

• Sample database

Supplier( s#, sname, city, dob )

SP( s#, p#, sdate, amount )

Part( p#, pname, colour, weight, quality )

primary key

primary key

primary key

foreign key

foreign key

Page 7: 1 SELECT statement. 2 Sample database Supplier Part supplies (0,n) colour s# snamep# pname amount citydob price qualitydate.

7

SELECT statementSELECT statement

• Sample database

Supplier( s#, sname, city, dob )

SP( s#, p#, sdate, amount )

Part( p#, pname, colour, weight, quality )

• Sample database

Supplier( s#, sname, city, dob )

SP( s#, p#, sdate, amount )

Part( p#, pname, colour, weight, quality )

Page 8: 1 SELECT statement. 2 Sample database Supplier Part supplies (0,n) colour s# snamep# pname amount citydob price qualitydate.

8

SELECT statementSELECT statement

• SELECT statement template• SELECT statement template

Page 9: 1 SELECT statement. 2 Sample database Supplier Part supplies (0,n) colour s# snamep# pname amount citydob price qualitydate.

9

SELECT statementSELECT statement

• SELECT statement template

SELECT < names of attributes >

• SELECT statement template

SELECT < names of attributes >

Page 10: 1 SELECT statement. 2 Sample database Supplier Part supplies (0,n) colour s# snamep# pname amount citydob price qualitydate.

10

SELECT statementSELECT statement

• SELECT statement template

SELECT <names of attributes>

FROM <names of relational tables>

• SELECT statement template

SELECT <names of attributes>

FROM <names of relational tables>

Page 11: 1 SELECT statement. 2 Sample database Supplier Part supplies (0,n) colour s# snamep# pname amount citydob price qualitydate.

11

SELECT statementSELECT statement

• SELECT statement template

SELECT <names of attributes>

FROM <names of relational tables>

WHERE <condition>

• SELECT statement template

SELECT <names of attributes>

FROM <names of relational tables>

WHERE <condition>

Page 12: 1 SELECT statement. 2 Sample database Supplier Part supplies (0,n) colour s# snamep# pname amount citydob price qualitydate.

12

SELECT statementSELECT statement

• Basic query• Basic query

Page 13: 1 SELECT statement. 2 Sample database Supplier Part supplies (0,n) colour s# snamep# pname amount citydob price qualitydate.

13

SELECT statementSELECT statement

• Basic query

“Find full information about all suppliers”

• Basic query

“Find full information about all suppliers”

Page 14: 1 SELECT statement. 2 Sample database Supplier Part supplies (0,n) colour s# snamep# pname amount citydob price qualitydate.

14

SELECT statementSELECT statement

• Basic query

“Find full information about all suppliers”

SELECT s#, sname, city, dob

FROM Supplier

or

• Basic query

“Find full information about all suppliers”

SELECT s#, sname, city, dob

FROM Supplier

or

Page 15: 1 SELECT statement. 2 Sample database Supplier Part supplies (0,n) colour s# snamep# pname amount citydob price qualitydate.

15

SELECT statementSELECT statement

• Basic query

“Find full information about all suppliers”

SELECT s#, sname, city, dob

FROM Supplier

or

SELECT *

FROM Supplier;

• Basic query

“Find full information about all suppliers”

SELECT s#, sname, city, dob

FROM Supplier

or

SELECT *

FROM Supplier;

Page 16: 1 SELECT statement. 2 Sample database Supplier Part supplies (0,n) colour s# snamep# pname amount citydob price qualitydate.

16

SELECT statementSELECT statement

• Projection query• Projection query

Page 17: 1 SELECT statement. 2 Sample database Supplier Part supplies (0,n) colour s# snamep# pname amount citydob price qualitydate.

17

SELECT statementSELECT statement

• Projection query

“Find the numbers, names, and prices of all parts”

• Projection query

“Find the numbers, names, and prices of all parts”

Page 18: 1 SELECT statement. 2 Sample database Supplier Part supplies (0,n) colour s# snamep# pname amount citydob price qualitydate.

18

SELECT statementSELECT statement

• Projection query

“Find the numbers, names, and prices of all parts”

SELECT p#, pname, price

FROM Part;

• Projection query

“Find the numbers, names, and prices of all parts”

SELECT p#, pname, price

FROM Part;

Page 19: 1 SELECT statement. 2 Sample database Supplier Part supplies (0,n) colour s# snamep# pname amount citydob price qualitydate.

19

SELECT statementSELECT statement

• Projection query with duplicates• Projection query with duplicates

Page 20: 1 SELECT statement. 2 Sample database Supplier Part supplies (0,n) colour s# snamep# pname amount citydob price qualitydate.

20

SELECT statementSELECT statement

• Projection query with duplicates

“Find the numbers of all suppliers that shipped at least one part”

• Projection query with duplicates

“Find the numbers of all suppliers that shipped at least one part”

Page 21: 1 SELECT statement. 2 Sample database Supplier Part supplies (0,n) colour s# snamep# pname amount citydob price qualitydate.

21

SELECT statementSELECT statement

• Projection query with duplicates

“Find the numbers of all suppliers that shipped at least one part”

SELECT s#

FROM SP;

• Projection query with duplicates

“Find the numbers of all suppliers that shipped at least one part”

SELECT s#

FROM SP;

Page 22: 1 SELECT statement. 2 Sample database Supplier Part supplies (0,n) colour s# snamep# pname amount citydob price qualitydate.

22

SELECT statementSELECT statement

• Projection query with no duplicates• Projection query with no duplicates

Page 23: 1 SELECT statement. 2 Sample database Supplier Part supplies (0,n) colour s# snamep# pname amount citydob price qualitydate.

23

SELECT statementSELECT statement

• Projection query with no duplicates

“Find the numbers of all suppliers that shipped at least one part”

• Projection query with no duplicates

“Find the numbers of all suppliers that shipped at least one part”

Page 24: 1 SELECT statement. 2 Sample database Supplier Part supplies (0,n) colour s# snamep# pname amount citydob price qualitydate.

24

SELECT statementSELECT statement

• Projection query with no duplicates

“Find the numbers of all suppliers that shipped at least one part”

SELECT DISTINCT s#

FROM SP;

• Projection query with no duplicates

“Find the numbers of all suppliers that shipped at least one part”

SELECT DISTINCT s#

FROM SP;

Page 25: 1 SELECT statement. 2 Sample database Supplier Part supplies (0,n) colour s# snamep# pname amount citydob price qualitydate.

25

SELECT statementSELECT statement

• Queries with standard functions• Queries with standard functions

Page 26: 1 SELECT statement. 2 Sample database Supplier Part supplies (0,n) colour s# snamep# pname amount citydob price qualitydate.

26

SELECT statementSELECT statement

• Queries with standard functions

“Find the total number of shipments”

• Queries with standard functions

“Find the total number of shipments”

Page 27: 1 SELECT statement. 2 Sample database Supplier Part supplies (0,n) colour s# snamep# pname amount citydob price qualitydate.

27

SELECT statementSELECT statement

• Queries with standard functions

“Find the total number of shipments”

SELECT count(*)

FROM SP;

• Queries with standard functions

“Find the total number of shipments”

SELECT count(*)

FROM SP;

Page 28: 1 SELECT statement. 2 Sample database Supplier Part supplies (0,n) colour s# snamep# pname amount citydob price qualitydate.

28

SELECT statementSELECT statement

• Queries with standard functions

“Find the total number of all parts shipped”

• Queries with standard functions

“Find the total number of all parts shipped”

Page 29: 1 SELECT statement. 2 Sample database Supplier Part supplies (0,n) colour s# snamep# pname amount citydob price qualitydate.

29

SELECT statementSELECT statement

• Queries with standard functions

“Find the total number of all parts shipped”

SELECT sum(quantity)

FROM SP;

• Queries with standard functions

“Find the total number of all parts shipped”

SELECT sum(quantity)

FROM SP;

Page 30: 1 SELECT statement. 2 Sample database Supplier Part supplies (0,n) colour s# snamep# pname amount citydob price qualitydate.

30

SELECT statementSELECT statement

• Queries with standard functions

“Find an average price of all parts”

• Queries with standard functions

“Find an average price of all parts”

Page 31: 1 SELECT statement. 2 Sample database Supplier Part supplies (0,n) colour s# snamep# pname amount citydob price qualitydate.

31

SELECT statementSELECT statement

• Queries with standard functions

“Find an average price of all parts”

SELECT avg(price)

FROM Part;

• Queries with standard functions

“Find an average price of all parts”

SELECT avg(price)

FROM Part;

Page 32: 1 SELECT statement. 2 Sample database Supplier Part supplies (0,n) colour s# snamep# pname amount citydob price qualitydate.

32

SELECT statementSELECT statement

• Queries with standard functions

“Find the highest and the lowest price”

• Queries with standard functions

“Find the highest and the lowest price”

Page 33: 1 SELECT statement. 2 Sample database Supplier Part supplies (0,n) colour s# snamep# pname amount citydob price qualitydate.

33

SELECT statementSELECT statement

• Queries with standard functions

“Find the highest and the lowest price”

SELECT max(price), min(price)

FROM Part;

• Queries with standard functions

“Find the highest and the lowest price”

SELECT max(price), min(price)

FROM Part;

Page 34: 1 SELECT statement. 2 Sample database Supplier Part supplies (0,n) colour s# snamep# pname amount citydob price qualitydate.

34

SELECT statementSELECT statement

• Queries with elementary condition• Queries with elementary condition

Page 35: 1 SELECT statement. 2 Sample database Supplier Part supplies (0,n) colour s# snamep# pname amount citydob price qualitydate.

35

SELECT statementSELECT statement

• Queries with elementary condition

“Find the names and numbers of all gold parts”

• Queries with elementary condition

“Find the names and numbers of all gold parts”

Page 36: 1 SELECT statement. 2 Sample database Supplier Part supplies (0,n) colour s# snamep# pname amount citydob price qualitydate.

36

SELECT statementSELECT statement

• Queries with elementary condition

“Find the names and numbers of all gold parts”

SELECT p#, pname

FROM Part

WHERE colour = ‘gold’;

• Queries with elementary condition

“Find the names and numbers of all gold parts”

SELECT p#, pname

FROM Part

WHERE colour = ‘gold’;

Page 37: 1 SELECT statement. 2 Sample database Supplier Part supplies (0,n) colour s# snamep# pname amount citydob price qualitydate.

37

SELECT statementSELECT statement

• Queries with elementary condition

“Find the names and dates of birth of all suppliers born before 1960”

• Queries with elementary condition

“Find the names and dates of birth of all suppliers born before 1960”

Page 38: 1 SELECT statement. 2 Sample database Supplier Part supplies (0,n) colour s# snamep# pname amount citydob price qualitydate.

38

SELECT statementSELECT statement

• Queries with elementary condition

“Find the names and dates of birth of all suppliers born before 1960”

SELECT sname, dob

FROM Supplier

WHERE dob < ‘1-Jan-1960’;

• Queries with elementary condition

“Find the names and dates of birth of all suppliers born before 1960”

SELECT sname, dob

FROM Supplier

WHERE dob < ‘1-Jan-1960’;

Page 39: 1 SELECT statement. 2 Sample database Supplier Part supplies (0,n) colour s# snamep# pname amount citydob price qualitydate.

39

SELECT statementSELECT statement

• Queries with elementary condition

“Find full information about all suppliers living in Paris “

• Queries with elementary condition

“Find full information about all suppliers living in Paris “

Page 40: 1 SELECT statement. 2 Sample database Supplier Part supplies (0,n) colour s# snamep# pname amount citydob price qualitydate.

40

SELECT statementSELECT statement

• Queries with elementary condition

“Find full information about all suppliers living in Paris “

SELECT *

FROM Supplier

WHERE city = ‘Paris’;

• Queries with elementary condition

“Find full information about all suppliers living in Paris “

SELECT *

FROM Supplier

WHERE city = ‘Paris’;

Page 41: 1 SELECT statement. 2 Sample database Supplier Part supplies (0,n) colour s# snamep# pname amount citydob price qualitydate.

41

SELECT statementSELECT statement

• Queries with elementary condition

“Find full information about all suppliers whose name starts from letter ‘J’ “

• Queries with elementary condition

“Find full information about all suppliers whose name starts from letter ‘J’ “

Page 42: 1 SELECT statement. 2 Sample database Supplier Part supplies (0,n) colour s# snamep# pname amount citydob price qualitydate.

42

SELECT statementSELECT statement

• Queries with elementary condition

“Find full information about all suppliers whose name starts from letter ‘J’ “

SELECT *

FROM Supplier

WHERE sname LIKE ‘J%’;

• Queries with elementary condition

“Find full information about all suppliers whose name starts from letter ‘J’ “

SELECT *

FROM Supplier

WHERE sname LIKE ‘J%’;

Page 43: 1 SELECT statement. 2 Sample database Supplier Part supplies (0,n) colour s# snamep# pname amount citydob price qualitydate.

43

SELECT statementSELECT statement

• Queries with elementary condition

“Find full information about all shipments done between 1990 and 1996”

• Queries with elementary condition

“Find full information about all shipments done between 1990 and 1996”

Page 44: 1 SELECT statement. 2 Sample database Supplier Part supplies (0,n) colour s# snamep# pname amount citydob price qualitydate.

44

SELECT statementSELECT statement

• Queries with elementary condition

“Find full information about all shipments done between 1990 and 1996”

SELECT *

FROM SP

WHERE sdate BETWEEN ‘01-Jan-1990’ AND

31-Dec-1996’;

• Queries with elementary condition

“Find full information about all shipments done between 1990 and 1996”

SELECT *

FROM SP

WHERE sdate BETWEEN ‘01-Jan-1990’ AND

31-Dec-1996’;

Page 45: 1 SELECT statement. 2 Sample database Supplier Part supplies (0,n) colour s# snamep# pname amount citydob price qualitydate.

45

SELECT statementSELECT statement

• Queries with Boolean expression• Queries with Boolean expression

Page 46: 1 SELECT statement. 2 Sample database Supplier Part supplies (0,n) colour s# snamep# pname amount citydob price qualitydate.

46

SELECT statementSELECT statement

• Queries with Boolean expression

“Find the prices of all bolts that cost more than 50.0”

• Queries with Boolean expression

“Find the prices of all bolts that cost more than 50.0”

Page 47: 1 SELECT statement. 2 Sample database Supplier Part supplies (0,n) colour s# snamep# pname amount citydob price qualitydate.

47

SELECT statementSELECT statement

• Queries with Boolean expression

“Find the prices of all bolts that cost more than 50.0”

SELECT price

FROM Part

WHERE (pname = ‘bolt’) AND

(price > 50.0);

• Queries with Boolean expression

“Find the prices of all bolts that cost more than 50.0”

SELECT price

FROM Part

WHERE (pname = ‘bolt’) AND

(price > 50.0);

Page 48: 1 SELECT statement. 2 Sample database Supplier Part supplies (0,n) colour s# snamep# pname amount citydob price qualitydate.

48

SELECT statementSELECT statement

• Queries with Boolean expression

“Find the prices of all gold or silver bolts”

• Queries with Boolean expression

“Find the prices of all gold or silver bolts”

Page 49: 1 SELECT statement. 2 Sample database Supplier Part supplies (0,n) colour s# snamep# pname amount citydob price qualitydate.

49

SELECT statementSELECT statement

• Queries with Boolean expression

“Find the prices of all gold or silver bolts”

SELECT price

FROM Part

WHERE (pname = ‘bolt’) AND

( (colour = ‘gold’) OR

(colour = ‘silver’));

• Queries with Boolean expression

“Find the prices of all gold or silver bolts”

SELECT price

FROM Part

WHERE (pname = ‘bolt’) AND

( (colour = ‘gold’) OR

(colour = ‘silver’));

Page 50: 1 SELECT statement. 2 Sample database Supplier Part supplies (0,n) colour s# snamep# pname amount citydob price qualitydate.

50

SELECT statementSELECT statement

• Queries with Boolean expression

“Find the prices of all gold or silver bolts”

SELECT price

FROM Part

WHERE (pname = ‘bolt’) AND

(colour in (‘gold’, ‘silver’));

• Queries with Boolean expression

“Find the prices of all gold or silver bolts”

SELECT price

FROM Part

WHERE (pname = ‘bolt’) AND

(colour in (‘gold’, ‘silver’));

Page 51: 1 SELECT statement. 2 Sample database Supplier Part supplies (0,n) colour s# snamep# pname amount citydob price qualitydate.

51

SELECT statementSELECT statement

• Queries with Boolean expression

“Find the prices of all bolts except gold and silver”

• Queries with Boolean expression

“Find the prices of all bolts except gold and silver”

Page 52: 1 SELECT statement. 2 Sample database Supplier Part supplies (0,n) colour s# snamep# pname amount citydob price qualitydate.

52

SELECT statementSELECT statement

• Queries with Boolean expression

“Find the prices of all bolts except gold and silver”

SELECT price

FROM Part

WHERE (pname = ‘bolt’) AND

(colour NOT IN (‘gold’, ‘silver’));

• Queries with Boolean expression

“Find the prices of all bolts except gold and silver”

SELECT price

FROM Part

WHERE (pname = ‘bolt’) AND

(colour NOT IN (‘gold’, ‘silver’));

Page 53: 1 SELECT statement. 2 Sample database Supplier Part supplies (0,n) colour s# snamep# pname amount citydob price qualitydate.

53

SELECT statementSELECT statement

• Queries with Boolean expression

“Find the prices of all parts except silver bolts”

• Queries with Boolean expression

“Find the prices of all parts except silver bolts”

Page 54: 1 SELECT statement. 2 Sample database Supplier Part supplies (0,n) colour s# snamep# pname amount citydob price qualitydate.

54

SELECT statementSELECT statement

• Queries with Boolean expression

“Find the prices of all parts except silver bolts”

SELECT price

FROM Part

WHERE NOT( (pname = ‘bolt’) AND

(colour = ‘silver’) );

• Queries with Boolean expression

“Find the prices of all parts except silver bolts”

SELECT price

FROM Part

WHERE NOT( (pname = ‘bolt’) AND

(colour = ‘silver’) );

Page 55: 1 SELECT statement. 2 Sample database Supplier Part supplies (0,n) colour s# snamep# pname amount citydob price qualitydate.

55

SELECT statementSELECT statement

• Queries with Boolean expression

“Find the prices of all parts except silver bolts”

SELECT price

FROM Part

WHERE (pname <> ‘bolt’) OR

(colour <> ‘silver’);

• Queries with Boolean expression

“Find the prices of all parts except silver bolts”

SELECT price

FROM Part

WHERE (pname <> ‘bolt’) OR

(colour <> ‘silver’);

Page 56: 1 SELECT statement. 2 Sample database Supplier Part supplies (0,n) colour s# snamep# pname amount citydob price qualitydate.

56

SELECT statementSELECT statement

• Sorting• Sorting

Page 57: 1 SELECT statement. 2 Sample database Supplier Part supplies (0,n) colour s# snamep# pname amount citydob price qualitydate.

57

SELECT statementSELECT statement

• Sorting

“Find all suppliers sorted by names in ascending order

• Sorting

“Find all suppliers sorted by names in ascending order

Page 58: 1 SELECT statement. 2 Sample database Supplier Part supplies (0,n) colour s# snamep# pname amount citydob price qualitydate.

58

SELECT statementSELECT statement

• Sorting

“Find all suppliers sorted by names in ascending order

SELECT *

FROM Supplier

ORDER BY sname ASC;

• Sorting

“Find all suppliers sorted by names in ascending order

SELECT *

FROM Supplier

ORDER BY sname ASC;

Page 59: 1 SELECT statement. 2 Sample database Supplier Part supplies (0,n) colour s# snamep# pname amount citydob price qualitydate.

59

SELECT statementSELECT statement

• Sorting

“Find all parts sorted by prices in descending order”

• Sorting

“Find all parts sorted by prices in descending order”

Page 60: 1 SELECT statement. 2 Sample database Supplier Part supplies (0,n) colour s# snamep# pname amount citydob price qualitydate.

60

SELECT statementSELECT statement

• Sorting

“Find all parts sorted by prices in descending order”

SELECT *

FROM Part

ORDER BY price DESC;

• Sorting

“Find all parts sorted by prices in descending order”

SELECT *

FROM Part

ORDER BY price DESC;

Page 61: 1 SELECT statement. 2 Sample database Supplier Part supplies (0,n) colour s# snamep# pname amount citydob price qualitydate.

61

SELECT statementSELECT statement

• Queries with NULL values• Queries with NULL values

Page 62: 1 SELECT statement. 2 Sample database Supplier Part supplies (0,n) colour s# snamep# pname amount citydob price qualitydate.

62

SELECT statementSELECT statement

• Queries with NULL values

“Find full information about all suppliers with unknown date of birth”

• Queries with NULL values

“Find full information about all suppliers with unknown date of birth”

Page 63: 1 SELECT statement. 2 Sample database Supplier Part supplies (0,n) colour s# snamep# pname amount citydob price qualitydate.

63

SELECT statementSELECT statement

• Queries with NULL values

“Find full information about all suppliers with unknown date of birth”

SELECT *

FROM Supplier

WHERE dob IS NULL;

• Queries with NULL values

“Find full information about all suppliers with unknown date of birth”

SELECT *

FROM Supplier

WHERE dob IS NULL;

Page 64: 1 SELECT statement. 2 Sample database Supplier Part supplies (0,n) colour s# snamep# pname amount citydob price qualitydate.

64

SELECT statementSELECT statement

• Queries with NULL values

“Find full information about all suppliers with known date of birth”

• Queries with NULL values

“Find full information about all suppliers with known date of birth”

Page 65: 1 SELECT statement. 2 Sample database Supplier Part supplies (0,n) colour s# snamep# pname amount citydob price qualitydate.

65

SELECT statementSELECT statement

• Queries with NULL values

“Find full information about all suppliers with known date of birth”

SELECT *

FROM Supplier

WHERE dob IS NOT NULL;

• Queries with NULL values

“Find full information about all suppliers with known date of birth”

SELECT *

FROM Supplier

WHERE dob IS NOT NULL;

Page 66: 1 SELECT statement. 2 Sample database Supplier Part supplies (0,n) colour s# snamep# pname amount citydob price qualitydate.

66

SELECT statementSELECT statement

• Bibliography

R. K. Stephens, et al. Teach Yourself SQL in 21 Days, day 9, week 2

P. O’Neil, Database - Principles, Programming, Performance, chapter 3.3

R. Elmasri, S.B. Navathe, Fundamentals of Database Systems, chapter .2

• Bibliography

R. K. Stephens, et al. Teach Yourself SQL in 21 Days, day 9, week 2

P. O’Neil, Database - Principles, Programming, Performance, chapter 3.3

R. Elmasri, S.B. Navathe, Fundamentals of Database Systems, chapter .2