Sql success ch01

Post on 29-Nov-2014

186 Views

Category:

Education

0 Downloads

Preview:

Click to see full reader

DESCRIPTION

An SQL course

Transcript

1

SQL Success

Chapter 1 slides

Stéphane Faroult

2

DATABASE

3

Benjamin Franklin

Milk Street, Boston

Philadelphia

4

Benjamin Franklin

Milk Street, Boston

$100

Philadelphia

5

Benjamin Franklin

Milk Street, Boston

$100

17-JAN-1706

17-APR-1790 Philadelphia

6

Benjamin Franklin

Milk Street, Boston

$100

17-JAN-1706

17-APR-1790 Philadelphia

7

Benjamin Franklin

Milk Street, Boston

$100

17-JAN-1706

17-APR-1790 Philadelphia

8

Flickr:Ed Kohler,Rocksee,Kiwanja,Walmart Stores,Christopher Rose, FrankBlackNoir

9

10

DBMS DBMS DBMS

11

DBMS DBMS DBMS

12

DBMS DBMS DBMS

13

DBMS DBMS DBMS

14

CONTROL changes

15

CONTROL changes

RETRIEVE data

16

Edgar F. Codd 1923 - 2003

17

18

Surname

19

Surname Firstname

20

Surname Firstname Birthdate

21

Surname Firstname Birthdate Picture

22

23

Surname Firstname Birthdate Picture

24

OPERATEOPERATE on relations

25

26

27

28

29

30

31

32

33

Birth year

34

35

IS KEYKEY GOOD MODELLING

36

37

38

39

Movie Title Country Year Director Starring

Citizen Kane US 1941 welles, o. Orson Welles, Joseph Cotten

La règle du jeu FR 1939 Renoir, J. Roland Toutain, Nora Grégor, Marcel Dalio, Jean Renoir

North By Northwest US 1959 HITCHCOCK, A. Cary Grant, Eva Marie Saint, James Mason

Singin' in the Rain US 1952 Donen/Kelly Gene Kelly, Debbie Reynolds, Donald O'Connor

Rear Window US 1954 HITCHCOCK, A. James Stewart, Grace Kelly

40

Movie Title Director Country Year Starring

Citizen Kane welles, o. US 1941 Orson Welles, Joseph Cotten

La règle du jeu Renoir, J. FR 1939 Roland Toutain, Nora Grégor, Marcel Dalio, Jean Renoir

North By Northwest HITCHCOCK, A. US 1959 Cary Grant, Eva Marie Saint, James Mason

Singin' in the Rain Donen/Kelly US 1952 Gene Kelly, Debbie Reynolds, Donald O'Connor

Rear Window HITCHCOCK, A. US 1954 James Stewart, Grace Kelly

41

Movie Title Director Country Year Starring

Singin' in the Rain Donen/Kelly US 1952 Gene Kelly, Debbie Reynolds, Donald O'Connor

Citizen Kane welles, o. US 1941 Orson Welles, Joseph Cotten

Rear Window HITCHCOCK, A. US 1954 James Stewart, Grace Kelly

La règle du jeu Renoir, J. FR 1939 Roland Toutain, Nora Grégor, Marcel Dalio, Jean Renoir

North By Northwest HITCHCOCK, A. US 1959 Cary Grant, Eva Marie Saint, James Mason

42

Movie Title Director Country Year Starring

Singin' in the Rain Donen/Kelly US 1952 Gene Kelly, Debbie Reynolds, Donald O'Connor

Citizen Kane welles, o. US 1941 Orson Welles, Joseph Cotten

Rear Window HITCHCOCK, A. US 1954 James Stewart, Grace Kelly

La règle du jeu Renoir, J. FR 1939 Roland Toutain, Nora Grégor, Marcel Dalio, Jean Renoir

North By Northwest HITCHCOCK, A. US 1959 Cary Grant, Eva Marie Saint, James Mason

43

Movie Title Director Country Year Starring

Singin' in the Rain Donen/Kelly US 1952 Gene Kelly, Debbie Reynolds, Donald O'Connor

Citizen Kane welles, o. US 1941 Orson Welles, Joseph Cotten

Rear Window HITCHCOCK, A. US 1954 James Stewart, Grace Kelly

La règle du jeu Renoir, J. FR 1939 Roland Toutain, Nora Grégor, Marcel Dalio, Jean Renoir

North By Northwest HITCHCOCK, A. US 1959 Cary Grant, Eva Marie Saint, James Mason

44

Movie Title Director Country Year Starring

Singin' in the Rain Donen/Kelly US 1952 Gene Kelly, Debbie Reynolds, Donald O'Connor

Citizen Kane welles, o. US 1941 Orson Welles, Joseph Cotten

Rear Window HITCHCOCK, A. US 1954 James Stewart, Grace Kelly

La règle du jeu Renoir, J. FR 1939 Roland Toutain, Nora Grégor, Marcel Dalio, Jean Renoir

North By Northwest HITCHCOCK, A. US 1959 Cary Grant, Eva Marie Saint, James Mason

45

Movie Title Director Country Year Starring

Singin' in the Rain Donen/Kelly US 1952 Gene Kelly, Debbie Reynolds, Donald O'Connor

Citizen Kane welles, o. US 1941 Orson Welles, Joseph Cotten

Rear Window HITCHCOCK, A. US 1954 James Stewart, Grace Kelly

La règle du jeu Renoir, J. FR 1939 Roland Toutain, Nora Grégor, Marcel Dalio, Jean Renoir

North By Northwest HITCHCOCK, A. US 1959 Cary Grant, Eva Marie Saint, James Mason

46 Flickr: Micky

47

Surname Firstname Birthdate Picture

48

Surname Firstname Birthdate Picture

49

Surname Firstname Birthdate Picture

50

Surname Firstname Birthdate Picture

51

Movie Title Director Country Year Starring

Singin' in the Rain Donen/Kelly US 1952 Gene Kelly, Debbie Reynolds, Donald O'Connor

Citizen Kane welles, o. US 1941 Orson Welles, Joseph Cotten

Rear Window HITCHCOCK, A. US 1954 James Stewart, Grace Kelly

La règle du jeu Renoir, J. FR 1939 Roland Toutain, Nora Grégor, Marcel Dalio, Jean Renoir

North By Northwest HITCHCOCK, A. US 1959 Cary Grant, Eva Marie Saint, James Mason

52

Movie Title Director Country Year Starring

Singin' in the Rain Donen/Kelly US 1952 Gene Kelly, Debbie Reynolds, Donald O'Connor

Citizen Kane welles, o. US 1941 Orson Welles, Joseph Cotten

Rear Window HITCHCOCK, A. US 1954 James Stewart, Grace Kelly

La règle du jeu Renoir, J. FR 1939 Roland Toutain, Nora Grégor, Marcel Dalio, Jean Renoir

North By Northwest HITCHCOCK, A. US 1959 Cary Grant, Eva Marie Saint, James Mason

53

54

Movie Title Director Country Year Starring

Singin' in the Rain Donen/Kelly US 1952 Gene Kelly, Debbie Reynolds, Donald O'Connor

Citizen Kane welles, o. US 1941 Orson Welles, Joseph Cotten

Rear Window HITCHCOCK, A. US 1954 James Stewart, Grace Kelly

La règle du jeu Renoir, J. FR 1939 Roland Toutain, Nora Grégor, Marcel Dalio, Jean Renoir

North By Northwest HITCHCOCK, A. US 1959 Cary Grant, Eva Marie Saint, James Mason

55

56

Movie Title Director Country Year Starring

Singin' in the Rain Donen/Kelly US 1952 Gene Kelly, Debbie Reynolds, Donald O'Connor

Citizen Kane welles, o. US 1941 Orson Welles, Joseph Cotten

Rear Window HITCHCOCK, A. US 1954 James Stewart, Grace Kelly

La règle du jeu Renoir, J. FR 1939 Roland Toutain, Nora Grégor, Marcel Dalio, Jean Renoir

North By Northwest HITCHCOCK, A. US 1959 Cary Grant, Eva Marie Saint, James Mason

57

58

59

Movie Title Director Country Year Starring

Singin' in the Rain Donen/Kelly US 1952 Gene Kelly, Debbie Reynolds, Donald O'Connor

Citizen Kane welles, o. US 1941 Orson Welles, Joseph Cotten

Rear Window HITCHCOCK, A. US 1954 James Stewart, Grace Kelly

La règle du jeu Renoir, J. FR 1939 Roland Toutain, Nora Grégor, Marcel Dalio, Jean Renoir

North By Northwest HITCHCOCK, A. US 1959 Cary Grant, Eva Marie Saint, James Mason

60 Flickr: Micky

Primary KeyPrimary Key

61

Movie Title :

Director :

Actor:

Actor:

Actor:

Search

HITCHCOCK, A.

Search

62

Enter number Enter name

JHON

63

Movie Title Director Country Year Starring

North By Northwest HITCHCOCK, A. US 1959 Cary Grant, Eva Marie Saint, James Mason

Rear Window HITCHCOCK, A. US 1954 James Stewart, Grace Kelly

64

Movie Title Director Country Year Starring

North By Northwest Hitchcock, A. US 1959 Cary Grant, Eva Marie Saint, James Mason

Rear Window Hitchcock, A. US 1954 James Stewart, Grace Kelly

Strangers on a Train Alfred Hitchcock US 1951 Farley Granger, Robert Walker

Movie Title Director Country Year Starring

North By Northwest HITCHCOCK, A. US 1959 Cary Grant, Eva Marie Saint, James Mason

Rear Window HITCHCOCK, A. US 1954 James Stewart, Grace Kelly

65

Director _Firstname Director_Surname

Alfred HITCHCOCK

orson welles

66

Director _Firstname Director_Surname

Alfred HITCHCOCK

orson welles

Director _Firstname Director_Surname

Alfred Hitchcock

Orson Welles

67

68

Surname

Hitchcock

Welles

Directors

Firstname

Alfred

Orson

69

Surname

Hitchcock

Welles

Born

1899

1915

Died

1980

1985

Directors

Firstname

Alfred

Orson

70

Surname

Hitchcock

Welles

Born

1899

1915

Died

1980

1985

Directors

Firstname

Alfred

Orson

71

Surname

Hitchcock

Welles

Born

1899

1915

Died

1980

1985

Id

1

2

Directors

Firstname

Alfred

Orson

72

Surname

Hitchcock

Welles

Born

1899

1915

Died

1980

1985

Id

1

2

Directors

Firstname

Alfred

Orson

73

Movies

74

Directors

Movies

75

Directors

Movies

76

Directors

Movies

77

78

Movie Title Directorid1 Directorid2 Country …

79

80

81

… Year Actorid1 Actorid2 Actorid3

82

83

84

Movie Title Country Year

North By Northwest US 1959

Rear Window US 1954

Strangers on a Train US 1951

Citizen Kane US 1941

The Magnificent Ambersons

US 1942

Singin' in the Rain US 1952

Movies

85

Movie Title Country Year

North By Northwest US 1959

Rear Window US 1954

Strangers on a Train US 1951

Citizen Kane US 1941

The Magnificent Ambersons

US 1942

Singin' in the Rain US 1952

Movies

MovieId

1

2

3

4

5

6

86

Movies

Directors

87

Movies

Directors

88

Movies

Directors Singin' In The Rain

Donen Kelly

89

Movies

Directors Singin' In The Rain

Donen Kelly

90

Movies

Directors Singin' In The Rain

Donen Kelly

91

Movies

Directors Singin' In The Rain

Charade

Hello, Dolly!

Donen Kelly

Directed_By

92

Movie Title Directorid Country Year Actorid1 Actorid2 Actorid3

North By Northwest 1 US 1959 11 14 16

Rear Window 1 US 1954 17 15

Strangers on a Train 1 US 1951 9 20

Citizen Kane 2 US 1941 19 18

The Magnificent Ambersons

2 US 1942 18 12 10

Movies

93

MovieId Movie Title Country Year

1 North By Northwest US 1959

2 Rear Window US 1954

3 Strangers on a Train US 1951

4 Citizen Kane US 1941

5 The Magnificent Ambersons

US 1942

Movies

94

MovieId Movie Title Country Year

1 North By Northwest US 1959

2 Rear Window US 1954

3 Strangers on a Train US 1951

4 Citizen Kane US 1941

5 The Magnificent Ambersons

US 1942

Id Firstname Surname Born Died

1 Alfred Hitchcock 1899 1980

2 Orson Welles 1915 1985

Movies

Directors

95

MovieId Movie Title Country Year

1 North By Northwest US 1959

2 Rear Window US 1954

3 Strangers on a Train US 1951

4 Citizen Kane US 1941

5 The Magnificent Ambersons

US 1942

Id Firstname Surname Born Died

1 Alfred Hitchcock 1899 1980

2 Orson Welles 1915 1985

MovieId DirectorId

1 1

2 1

3 1

4 2

5 2

Movies

Directors

Directed_By

96

MovieId Movie Title Country Year

Id Firstname Surname Born Died

MovieId ActorId

Movies

Actors

Played_In

97

98

99

100

101

directors actors

102

directors actors

103

directors actors

104

directors actors

105

people

106

107

MovieId Movie Title Country Year

2 Rear Window US 1954

4 Citizen Kane US 1941

Id Firstname Surname Born Died

1 Alfred Hitchcock 1899 1980

2 Orson Welles 1915 1985

3 James Stewart 1908 1997

4 Grace Kelly 1929 1982

5 Joseph Cotten 1905 1994

Movies

People

108

MovieId Movie Title Country Year

2 Rear Window US 1954

4 Citizen Kane US 1941

Id Firstname Surname Born Died

1 Alfred Hitchcock 1899 1980

2 Orson Welles 1915 1985

3 James Stewart 1908 1997

4 Grace Kelly 1929 1982

5 Joseph Cotten 1905 1994

MovieId PersonId

2 1

2 3

2 4

4 2

4 2

4 5

Movies

People

Credits

109

MovieId Movie Title Country Year

2 Rear Window US 1954

4 Citizen Kane US 1941

Id Firstname Surname Born Died

1 Alfred Hitchcock 1899 1980

2 Orson Welles 1915 1985

3 James Stewart 1908 1997

4 Grace Kelly 1929 1982

5 Joseph Cotten 1905 1994

MovieId PersonId

2 1

2 3

2 4

4 2

4 2

4 5

Movies

People

Credits

Credited

D

A

A

D

A

A

110

MovieId Movie Title Country Year

2 Rear Window US 1954

4 Citizen Kane US 1941

Id Firstname Surname Born Died

1 Alfred Hitchcock 1899 1980

2 Orson Welles 1915 1985

3 James Stewart 1908 1997

4 Grace Kelly 1929 1982

5 Joseph Cotten 1905 1994

MovieId PersonId

2 1

2 3

2 4

4 2

4 2

4 5

Movies

People

Credits

Credited

D

A

A

D

A

A

111

A bit of

Formalism

112

Cardinality (1, n)

MovieId Movie Title Country Year

2 Rear Window US 1954

4 Citizen Kane US 1941

5 The Third Man GB 1949

113

Cardinality (1, n)

MovieId Movie Title Country Year

2 Rear Window US 1954

4 Citizen Kane US 1941

5 The Third Man GB 1949

Country Name

US United States

GB United Kingdom

114

Cardinality (1, n)

MovieId Movie Title Country Year

2 Rear Window US 1954

4 Citizen Kane US 1941

5 The Third Man GB 1949

Country Name

US United States

GB United Kingdom

115

Cardinality (1, n) (0, n)

116

Cardinality (1, n) (0, n) (m, n)

117

Cardinality (1, n) (0, n) (m, n)

118

119

MovieId Movie Title Country Year

2 Rear Window US 1954

4 Citizen Kane US 1941

Id Firstname Surname Born Died

1 Alfred Hitchcock 1899 1980

2 Orson Welles 1915 1985

3 James Stewart 1908 1997

4 Grace Kelly 1929 1982

5 Joseph Cotten 1905 1994

MovieId PersonId Credited

2 1 D

2 3 A

2 4 A

4 2 D

4 2 A

4 5 A

Movies

People

Credits

120

Normalization

Simple attributes

121

Every non key attributeattribute must provide a factfact about the keykey,

122

Every non key attributeattribute must provide a factfact about the keykey, the whole keywhole key,

123

Every non key attributeattribute must provide a factfact about the keykey,

William Kent (1936 – 2005)

the whole keywhole key, and nothing but the keynothing but the key.

124

DBMS products are programs that manage data

125

DBMS products are programs that manage data Codd's relational model stores data in tables and lets you operate on them.

126

DBMS products are programs that manage data Codd's relational model stores data in tables and lets you operate on them. To design a database:

127

DBMS products are programs that manage data Codd's relational model stores data in tables and lets you operate on them. To design a database:

•keys uniquely identify rows in a table

128

DBMS products are programs that manage data Codd's relational model stores data in tables and lets you operate on them. To design a database:

•keys uniquely identify rows in a table •columns (attributes) describe simple facts

129

DBMS products are programs that manage data Codd's relational model stores data in tables and lets you operate on them. To design a database:

•keys uniquely identify rows in a table •columns (attributes) describe simple facts •how many facts relate to the key (cardinality) is very important and determines how many tables you need.

130

DBMS products are programs that manage data Codd's relational model stores data in tables and lets you operate on them. To design a database:

•keys uniquely identify rows in a table •columns (attributes) describe simple facts •how many facts relate to the key (cardinality) is very important and determines how many tables you need.

" Each attribute that doesn't belong to the key is a fact related to the key, the whole key, and nothing but the key"

top related