Sql success ch01

255 views
164 views

Published on

An SQL course

Published in: Education, Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
255
On SlideShare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
9
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Sql success ch01

  1. 1. SQL Success Chapter 1 slides Stéphane Faroult 1
  2. 2. DATABASE 2
  3. 3. Benjamin Franklin Milk Street, Boston Philadelphia 3
  4. 4. Benjamin Franklin Milk Street, Boston Philadelphia $100 4
  5. 5. Benjamin Franklin Milk Street, Boston Philadelphia 17-JAN-1706 17-APR-1790 $100 5
  6. 6. Benjamin Franklin Milk Street, Boston Philadelphia 17-JAN-1706 17-APR-1790 $100 6
  7. 7. Benjamin Franklin Milk Street, Boston Philadelphia 17-JAN-1706 17-APR-1790 $100 7
  8. 8. Flickr:Ed Kohler,Rocksee,Kiwanja,Walmart Stores,Christopher Rose, FrankBlackNoir 8
  9. 9. 9
  10. 10. DBMS 10
  11. 11. DBMS 11
  12. 12. DBMS 12
  13. 13. DBMS 13
  14. 14. CONTROL changes 14
  15. 15. CONTROL changes RETRIEVE data 15
  16. 16. Edgar F. Codd 1923 - 2003 16
  17. 17. 17
  18. 18. Surname 18
  19. 19. Surname Firstname 19
  20. 20. Surname Firstname Birthdate 20
  21. 21. Picture Surname Firstname Birthdate 21
  22. 22. 22
  23. 23. Picture Surname Firstname Birthdate 23
  24. 24. OPERATE on relations 24
  25. 25. 25
  26. 26. 26
  27. 27. 27
  28. 28. 28
  29. 29. 29
  30. 30. 30
  31. 31. 31
  32. 32. 32
  33. 33. Birth year 33
  34. 34. 34
  35. 35. GOOD MODELLING IS KEY 35
  36. 36. 36
  37. 37. 37
  38. 38. 38
  39. 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 Rear Window US 1954 HITCHCOCK, A. James Stewart, Grace Kelly Gene Kelly, Debbie Reynolds, Donald O'Connor 39
  40. 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 40
  41. 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 41
  42. 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 42
  43. 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 43
  44. 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 44
  45. 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 45
  46. 46. Flickr: Micky 46
  47. 47. Picture Surname Firstname Birthdate 47
  48. 48. Picture Surname Firstname Birthdate 48
  49. 49. Picture Surname Firstname Birthdate 49
  50. 50. Picture Surname Firstname Birthdate 50
  51. 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 51
  52. 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 52
  53. 53. 53
  54. 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 54
  55. 55. 55
  56. 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 56
  57. 57. 57
  58. 58. 58
  59. 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 59
  60. 60. Primary Key Flickr: Micky 60
  61. 61. Movie Title : Director : HITCHCOCK, A. Actor: Actor: Actor: Search 61
  62. 62. Enter number Enter name JHON 62
  63. 63. Movie Title Director Country Year Starring North By Northwest HITCHCOCK, A. US 1959 Cary Grant, Eva Marie Saint, James Mason Rear Window US 1954 James Stewart, Grace Kelly HITCHCOCK, A. 63
  64. 64. Movie Title Director Country Year Starring North By Northwest Hitchcock, A.A. HITCHCOCK, US 1959 Cary Grant, Eva Marie Saint, James Mason Rear Window HITCHCOCK, Hitchcock, A.A. US 1954 James Stewart, Grace Kelly Strangers on a Train Alfred Hitchcock US 1951 Farley Granger, Robert Walker 64
  65. 65. Director _Firstname Director_Surname Alfred HITCHCOCK orson welles 65
  66. 66. Director _Firstname Director_Surname Alfred Hitchcock HITCHCOCK Orson orson Welles welles 66
  67. 67. 67
  68. 68. Directors Firstname Surname Alfred Hitchcock Orson Welles 68
  69. 69. Directors Firstname Surname Born Died Alfred Hitchcock 1899 1980 Orson Welles 1915 1985 69
  70. 70. Directors Firstname Surname Born Died Alfred Hitchcock 1899 1980 Orson Welles 1915 1985 70
  71. 71. Directors Id Firstname Surname Born Died 1 Alfred Hitchcock 1899 1980 2 Orson Welles 1915 1985 71
  72. 72. Directors Id Firstname Surname Born Died 1 Alfred Hitchcock 1899 1980 2 Orson Welles 1915 1985 72
  73. 73. Movies 73
  74. 74. Movies Directors 74
  75. 75. Movies Directors 75
  76. 76. Movies Directors 76
  77. 77. 77
  78. 78. Movie Title Directorid1 Directorid2 Country … 78
  79. 79. 79
  80. 80. 80
  81. 81. … Year Actorid1 Actorid2 Actorid3 81
  82. 82. 82
  83. 83. 83
  84. 84. Movies 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 84
  85. 85. Movies 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 6 Singin' in the Rain US 1952 85
  86. 86. Movies Directors 86
  87. 87. Movies Directors 87
  88. 88. Movies Directors Singin' In The Rain Donen Kelly 88
  89. 89. Movies Directors Singin' In The Rain Donen Kelly 89
  90. 90. Movies Directors Singin' In The Rain Donen Kelly 90
  91. 91. Movies Directors Donen Kelly Directed_By Singin' In The Rain Charade Hello, Dolly! 91
  92. 92. Movies Movie Title Directorid Country Year Actorid1 Actorid2 Actorid3 16 North By Northwest 1 US 1959 11 14 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 92
  93. 93. Movies 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 93
  94. 94. Movies 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 Directors Id Firstname Surname Born Died 1 Alfred Hitchcock 1899 1980 2 Orson Welles 1915 1985 94
  95. 95. Movies MovieId Movie Title Country Year 1 Directed_By MovieId DirectorId 1 1 2 2 5 2 2 Rear Window US 1954 3 Strangers on a Train US 1951 4 Citizen Kane US 1941 5 The Magnificent Ambersons US 1942 1 4 1959 1 3 North By Northwest US Directors Id Firstname Surname Born Died 1 Alfred Hitchcock 1899 1980 2 Orson Welles 1915 1985 95
  96. 96. Movies MovieId Movie Title Country Year Born Died Played_In MovieId ActorId Actors Id Firstname Surname 96
  97. 97. 97
  98. 98. 98
  99. 99. 99
  100. 100. 100
  101. 101. directors actors 101
  102. 102. directors actors 102
  103. 103. directors actors 103
  104. 104. directors actors 104
  105. 105. people 105
  106. 106. 106
  107. 107. Movies MovieId Movie Title Country Year 2 Rear Window US 1954 4 Citizen Kane US 1941 People 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 107
  108. 108. Movies MovieId MovieId 2 1 2 3 2 4 4 2 4 2 4 5 Year Rear Window US 1954 4 PersonId Country 2 Credits Movie Title Citizen Kane US 1941 People 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 108
  109. 109. Movies MovieId MovieId Credited 2 1 D 2 3 A 2 4 A 4 2 D 4 2 A 4 5 A Year Rear Window US 1954 4 PersonId Country 2 Credits Movie Title Citizen Kane US 1941 People 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 109
  110. 110. Movies MovieId MovieId Credited 2 1 D 2 3 A 2 4 A 4 2 D 4 2 A 4 5 A Year Rear Window US 1954 4 PersonId Country 2 Credits Movie Title Citizen Kane US 1941 People 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 110
  111. 111. A bit of Formalism 111
  112. 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 112
  113. 113. Cardinality (1, n) Country Name US United States GB United Kingdom MovieId Movie Title Country Year 2 Rear Window US 1954 4 Citizen Kane US 1941 5 The Third Man GB 1949 113
  114. 114. Cardinality (1, n) Country Name US United States GB United Kingdom MovieId Movie Title Country Year 2 Rear Window US 1954 4 Citizen Kane US 1941 5 The Third Man GB 1949 114
  115. 115. Cardinality (1, n) (0, n) 115
  116. 116. Cardinality (1, n) (0, n) (m, n) 116
  117. 117. Cardinality (1, n) (0, n) (m, n) 117
  118. 118. 118
  119. 119. Movies MovieId PersonId Credited 2 1 D 2 3 A 2 4 A 4 2 D 4 2 A 4 5 A Year Rear Window US 1954 4 MovieId Country 2 Credits Movie Title Citizen Kane US 1941 People 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 119
  120. 120. Normalization Simple attributes 120
  121. 121. Every non key attribute must provide a fact about the key key, 121
  122. 122. Every non key attribute must provide a fact about the key key, the whole key key, 122
  123. 123. Every non key attribute must provide a fact about the key key, the whole key key, and nothing but the key key. William Kent (1936 – 2005) 123
  124. 124. DBMS products are programs that manage data 124
  125. 125. DBMS products are programs that manage data Codd's relational model stores data in tables and lets you operate on them. 125
  126. 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: 126
  127. 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 127
  128. 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 128
  129. 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. 129
  130. 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" 130

×