internals.ps
上传用户:blenddy
上传日期:2007-01-07
资源大小:6495k
文件大小:626k
源码类别:

数据库系统

开发平台:

Unix_Linux

  1. %!PS-Adobe-2.0
  2. %%Creator: dvipsk 5.58f Copyright 1986, 1994 Radical Eye Software
  3. %%Title: diplarb.dvi
  4. %%Pages: 117
  5. %%PageOrder: Ascend
  6. %%BoundingBox: 0 0 596 842
  7. %%DocumentFonts: Times-Roman Courier Times-Bold Times-Italic
  8. %%DocumentPaperSizes: A4
  9. %%EndComments
  10. %DVIPSCommandLine: dvips diplarb.dvi
  11. %DVIPSParameters: dpi=360, comments removed
  12. %DVIPSSource:  TeX output 1998.11.29:1121
  13. %%BeginProcSet: tex.pro
  14. /TeXDict 250 dict def TeXDict begin /N{def}def /B{bind def}N /S{exch}N
  15. /X{S N}B /TR{translate}N /isls false N /vsize 11 72 mul N /hsize 8.5 72
  16. mul N /landplus90{false}def /@rigin{isls{[0 landplus90{1 -1}{-1 1}
  17. ifelse 0 0 0]concat}if 72 Resolution div 72 VResolution div neg scale
  18. isls{landplus90{VResolution 72 div vsize mul 0 exch}{Resolution -72 div
  19. hsize mul 0}ifelse TR}if Resolution VResolution vsize -72 div 1 add mul
  20. TR[matrix currentmatrix{dup dup round sub abs 0.00001 lt{round}if}
  21. forall round exch round exch]setmatrix}N /@landscape{/isls true N}B
  22. /@manualfeed{statusdict /manualfeed true put}B /@copies{/#copies X}B
  23. /FMat[1 0 0 -1 0 0]N /FBB[0 0 0 0]N /nn 0 N /IE 0 N /ctr 0 N /df-tail{
  24. /nn 8 dict N nn begin /FontType 3 N /FontMatrix fntrx N /FontBBox FBB N
  25. string /base X array /BitMaps X /BuildChar{CharBuilder}N /Encoding IE N
  26. end dup{/foo setfont}2 array copy cvx N load 0 nn put /ctr 0 N[}B /df{
  27. /sf 1 N /fntrx FMat N df-tail}B /dfs{div /sf X /fntrx[sf 0 0 sf neg 0 0]
  28. N df-tail}B /E{pop nn dup definefont setfont}B /ch-width{ch-data dup
  29. length 5 sub get}B /ch-height{ch-data dup length 4 sub get}B /ch-xoff{
  30. 128 ch-data dup length 3 sub get sub}B /ch-yoff{ch-data dup length 2 sub
  31. get 127 sub}B /ch-dx{ch-data dup length 1 sub get}B /ch-image{ch-data
  32. dup type /stringtype ne{ctr get /ctr ctr 1 add N}if}B /id 0 N /rw 0 N
  33. /rc 0 N /gp 0 N /cp 0 N /G 0 N /sf 0 N /CharBuilder{save 3 1 roll S dup
  34. /base get 2 index get S /BitMaps get S get /ch-data X pop /ctr 0 N ch-dx
  35. 0 ch-xoff ch-yoff ch-height sub ch-xoff ch-width add ch-yoff
  36. setcachedevice ch-width ch-height true[1 0 0 -1 -.1 ch-xoff sub ch-yoff
  37. .1 sub]{ch-image}imagemask restore}B /D{/cc X dup type /stringtype ne{]}
  38. if nn /base get cc ctr put nn /BitMaps get S ctr S sf 1 ne{dup dup
  39. length 1 sub dup 2 index S get sf div put}if put /ctr ctr 1 add N}B /I{
  40. cc 1 add D}B /bop{userdict /bop-hook known{bop-hook}if /SI save N @rigin
  41. 0 0 moveto /V matrix currentmatrix dup 1 get dup mul exch 0 get dup mul
  42. add .99 lt{/QV}{/RV}ifelse load def pop pop}N /eop{SI restore userdict
  43. /eop-hook known{eop-hook}if showpage}N /@start{userdict /start-hook
  44. known{start-hook}if pop /VResolution X /Resolution X 1000 div /DVImag X
  45. /IE 256 array N 0 1 255{IE S 1 string dup 0 3 index put cvn put}for
  46. 65781.76 div /vsize X 65781.76 div /hsize X}N /p{show}N /RMat[1 0 0 -1 0
  47. 0]N /BDot 260 string N /rulex 0 N /ruley 0 N /v{/ruley X /rulex X V}B /V
  48. {}B /RV statusdict begin /product where{pop product dup length 7 ge{0 7
  49. getinterval dup(Display)eq exch 0 4 getinterval(NeXT)eq or}{pop false}
  50. ifelse}{false}ifelse end{{gsave TR -.1 .1 TR 1 1 scale rulex ruley false
  51. RMat{BDot}imagemask grestore}}{{gsave TR -.1 .1 TR rulex ruley scale 1 1
  52. false RMat{BDot}imagemask grestore}}ifelse B /QV{gsave newpath transform
  53. round exch round exch itransform moveto rulex 0 rlineto 0 ruley neg
  54. rlineto rulex neg 0 rlineto fill grestore}B /a{moveto}B /delta 0 N /tail
  55. {dup /delta X 0 rmoveto}B /M{S p delta add tail}B /b{S p tail}B /c{-4 M}
  56. B /d{-3 M}B /e{-2 M}B /f{-1 M}B /g{0 M}B /h{1 M}B /i{2 M}B /j{3 M}B /k{
  57. 4 M}B /w{0 rmoveto}B /l{p -4 w}B /m{p -3 w}B /n{p -2 w}B /o{p -1 w}B /q{
  58. p 1 w}B /r{p 2 w}B /s{p 3 w}B /t{p 4 w}B /x{0 S rmoveto}B /y{3 2 roll p
  59. a}B /bos{/SS save N}B /eos{SS restore}B end
  60. %%EndProcSet
  61. %%BeginFont: Times-Roman
  62. % @@psencodingfile@{
  63. %   author = "S. Rahtz, P. MacKay, Alan Jeffrey, B. Horn, K. Berry",
  64. %   version = "0.6",
  65. %   date = "22 June 1996",
  66. %   filename = "8r.enc",
  67. %   email = "kb@@mail.tug.org",
  68. %   address = "135 Center Hill Rd. // Plymouth, MA 02360",
  69. %   codetable = "ISO/ASCII",
  70. %   checksum = "119     662    4424",
  71. %   docstring = "Encoding for TrueType or Type 1 fonts to be used with TeX."
  72. % @}
  73. % Idea is to have all the characters normally included in Type 1 fonts
  74. % available for typesetting. This is effectively the characters in Adobe
  75. % Standard Encoding + ISO Latin 1 + extra characters from Lucida.
  76. % Character code assignments were made as follows:
  77. % (1) the Windows ANSI characters are almost all in their Windows ANSI
  78. % positions, because some Windows users cannot easily reencode the
  79. % fonts, and it makes no difference on other systems. The only Windows
  80. % ANSI characters not available are those that make no sense for
  81. % typesetting -- rubout (127 decimal), nobreakspace (160), softhyphen
  82. % (173). quotesingle and grave are moved just because it's such an
  83. % irritation not having them in TeX positions.
  84. % (2) Remaining characters are assigned arbitrarily to the lower part
  85. % of the range, avoiding 0, 10 and 13 in case we meet dumb software.
  86. % (3) Y&Y Lucida Bright includes some extra text characters; in the
  87. % hopes that other PostScript fonts, perhaps created for public
  88. % consumption, will include them, they are included starting at 0x12.
  89. % (4) Remaining positions left undefined are for use in (hopefully)
  90. % upward-compatible revisions, if someday more characters are generally
  91. % available.
  92. % (5) hyphen appears twice for compatibility with both ASCII and Windows.
  93. /TeXBase1Encoding [
  94. % 0x00 (encoded characters from Adobe Standard not in Windows 3.1)
  95.   /.notdef /dotaccent /fi /fl
  96.   /fraction /hungarumlaut /Lslash /lslash
  97.   /ogonek /ring /.notdef
  98.   /breve /minus /.notdef 
  99. % These are the only two remaining unencoded characters, so may as
  100. % well include them.
  101.   /Zcaron /zcaron 
  102. % 0x10
  103.  /caron /dotlessi 
  104. % (unusual TeX characters available in, e.g., Lucida Bright)
  105.  /dotlessj /ff /ffi /ffl 
  106.  /.notdef /.notdef /.notdef /.notdef
  107.  /.notdef /.notdef /.notdef /.notdef
  108.  % very contentious; it's so painful not having quoteleft and quoteright
  109.  % at 96 and 145 that we move the things normally found there down to here.
  110.  /grave /quotesingle 
  111. % 0x20 (ASCII begins)
  112.  /space /exclam /quotedbl /numbersign
  113.  /dollar /percent /ampersand /quoteright
  114.  /parenleft /parenright /asterisk /plus /comma /hyphen /period /slash
  115. % 0x30
  116.  /zero /one /two /three /four /five /six /seven
  117.  /eight /nine /colon /semicolon /less /equal /greater /question
  118. % 0x40
  119.  /at /A /B /C /D /E /F /G /H /I /J /K /L /M /N /O
  120. % 0x50
  121.  /P /Q /R /S /T /U /V /W
  122.  /X /Y /Z /bracketleft /backslash /bracketright /asciicircum /underscore
  123. % 0x60
  124.  /quoteleft /a /b /c /d /e /f /g /h /i /j /k /l /m /n /o
  125. % 0x70
  126.  /p /q /r /s /t /u /v /w
  127.  /x /y /z /braceleft /bar /braceright /asciitilde
  128.  /.notdef % rubout; ASCII ends
  129. % 0x80
  130.  /.notdef /.notdef /quotesinglbase /florin
  131.  /quotedblbase /ellipsis /dagger /daggerdbl
  132.  /circumflex /perthousand /Scaron /guilsinglleft
  133.  /OE /.notdef /.notdef /.notdef
  134. % 0x90
  135.  /.notdef /.notdef /.notdef /quotedblleft
  136.  /quotedblright /bullet /endash /emdash
  137.  /tilde /trademark /scaron /guilsinglright
  138.  /oe /.notdef /.notdef /Ydieresis
  139. % 0xA0
  140.  /.notdef % nobreakspace
  141.  /exclamdown /cent /sterling
  142.  /currency /yen /brokenbar /section
  143.  /dieresis /copyright /ordfeminine /guillemotleft
  144.  /logicalnot
  145.  /hyphen % Y&Y (also at 45); Windows' softhyphen
  146.  /registered
  147.  /macron
  148. % 0xD0
  149.  /degree /plusminus /twosuperior /threesuperior
  150.  /acute /mu /paragraph /periodcentered
  151.  /cedilla /onesuperior /ordmasculine /guillemotright
  152.  /onequarter /onehalf /threequarters /questiondown
  153. % 0xC0
  154.  /Agrave /Aacute /Acircumflex /Atilde /Adieresis /Aring /AE /Ccedilla
  155.  /Egrave /Eacute /Ecircumflex /Edieresis
  156.  /Igrave /Iacute /Icircumflex /Idieresis
  157. % 0xD0
  158.  /Eth /Ntilde /Ograve /Oacute
  159.  /Ocircumflex /Otilde /Odieresis /multiply
  160.  /Oslash /Ugrave /Uacute /Ucircumflex
  161.  /Udieresis /Yacute /Thorn /germandbls
  162. % 0xE0
  163.  /agrave /aacute /acircumflex /atilde
  164.  /adieresis /aring /ae /ccedilla
  165.  /egrave /eacute /ecircumflex /edieresis
  166.  /igrave /iacute /icircumflex /idieresis
  167. % 0xF0
  168.  /eth /ntilde /ograve /oacute
  169.  /ocircumflex /otilde /odieresis /divide
  170.  /oslash /ugrave /uacute /ucircumflex
  171.  /udieresis /yacute /thorn /ydieresis
  172. ] def
  173. %%EndFont
  174. %%BeginProcSet: texps.pro
  175. TeXDict begin /rf{findfont dup length 1 add dict begin{1 index /FID ne 2
  176. index /UniqueID ne and{def}{pop pop}ifelse}forall[1 index 0 6 -1 roll
  177. exec 0 exch 5 -1 roll VResolution Resolution div mul neg 0 0]/Metrics
  178. exch def dict begin Encoding{exch dup type /integertype ne{pop pop 1 sub
  179. dup 0 le{pop}{[}ifelse}{FontMatrix 0 get div Metrics 0 get div def}
  180. ifelse}forall Metrics /Metrics currentdict end def[2 index currentdict
  181. end definefont 3 -1 roll makefont /setfont load]cvx def}def
  182. /ObliqueSlant{dup sin S cos div neg}B /SlantFont{4 index mul add}def
  183. /ExtendFont{3 -1 roll mul exch}def /ReEncodeFont{/Encoding exch def}def
  184. end
  185. %%EndProcSet
  186. %%BeginProcSet: special.pro
  187. TeXDict begin /SDict 200 dict N SDict begin /@SpecialDefaults{/hs 612 N
  188. /vs 792 N /ho 0 N /vo 0 N /hsc 1 N /vsc 1 N /ang 0 N /CLIP 0 N /rwiSeen
  189. false N /rhiSeen false N /letter{}N /note{}N /a4{}N /legal{}N}B
  190. /@scaleunit 100 N /@hscale{@scaleunit div /hsc X}B /@vscale{@scaleunit
  191. div /vsc X}B /@hsize{/hs X /CLIP 1 N}B /@vsize{/vs X /CLIP 1 N}B /@clip{
  192. /CLIP 2 N}B /@hoffset{/ho X}B /@voffset{/vo X}B /@angle{/ang X}B /@rwi{
  193. 10 div /rwi X /rwiSeen true N}B /@rhi{10 div /rhi X /rhiSeen true N}B
  194. /@llx{/llx X}B /@lly{/lly X}B /@urx{/urx X}B /@ury{/ury X}B /magscale
  195. true def end /@MacSetUp{userdict /md known{userdict /md get type
  196. /dicttype eq{userdict begin md length 10 add md maxlength ge{/md md dup
  197. length 20 add dict copy def}if end md begin /letter{}N /note{}N /legal{}
  198. N /od{txpose 1 0 mtx defaultmatrix dtransform S atan/pa X newpath
  199. clippath mark{transform{itransform moveto}}{transform{itransform lineto}
  200. }{6 -2 roll transform 6 -2 roll transform 6 -2 roll transform{
  201. itransform 6 2 roll itransform 6 2 roll itransform 6 2 roll curveto}}{{
  202. closepath}}pathforall newpath counttomark array astore /gc xdf pop ct 39
  203. 0 put 10 fz 0 fs 2 F/|______Courier fnt invertflag{PaintBlack}if}N
  204. /txpose{pxs pys scale ppr aload pop por{noflips{pop S neg S TR pop 1 -1
  205. scale}if xflip yflip and{pop S neg S TR 180 rotate 1 -1 scale ppr 3 get
  206. ppr 1 get neg sub neg ppr 2 get ppr 0 get neg sub neg TR}if xflip yflip
  207. not and{pop S neg S TR pop 180 rotate ppr 3 get ppr 1 get neg sub neg 0
  208. TR}if yflip xflip not and{ppr 1 get neg ppr 0 get neg TR}if}{noflips{TR
  209. pop pop 270 rotate 1 -1 scale}if xflip yflip and{TR pop pop 90 rotate 1
  210. -1 scale ppr 3 get ppr 1 get neg sub neg ppr 2 get ppr 0 get neg sub neg
  211. TR}if xflip yflip not and{TR pop pop 90 rotate ppr 3 get ppr 1 get neg
  212. sub neg 0 TR}if yflip xflip not and{TR pop pop 270 rotate ppr 2 get ppr
  213. 0 get neg sub neg 0 S TR}if}ifelse scaleby96{ppr aload pop 4 -1 roll add
  214. 2 div 3 1 roll add 2 div 2 copy TR .96 dup scale neg S neg S TR}if}N /cp
  215. {pop pop showpage pm restore}N end}if}if}N /normalscale{Resolution 72
  216. div VResolution 72 div neg scale magscale{DVImag dup scale}if 0 setgray}
  217. N /psfts{S 65781.76 div N}N /startTexFig{/psf$SavedState save N userdict
  218. maxlength dict begin /magscale true def normalscale currentpoint TR
  219. /psf$ury psfts /psf$urx psfts /psf$lly psfts /psf$llx psfts /psf$y psfts
  220. /psf$x psfts currentpoint /psf$cy X /psf$cx X /psf$sx psf$x psf$urx
  221. psf$llx sub div N /psf$sy psf$y psf$ury psf$lly sub div N psf$sx psf$sy
  222. scale psf$cx psf$sx div psf$llx sub psf$cy psf$sy div psf$ury sub TR
  223. /showpage{}N /erasepage{}N /copypage{}N /p 3 def @MacSetUp}N /doclip{
  224. psf$llx psf$lly psf$urx psf$ury currentpoint 6 2 roll newpath 4 copy 4 2
  225. roll moveto 6 -1 roll S lineto S lineto S lineto closepath clip newpath
  226. moveto}N /endTexFig{end psf$SavedState restore}N /@beginspecial{SDict
  227. begin /SpecialSave save N gsave normalscale currentpoint TR
  228. @SpecialDefaults count /ocount X /dcount countdictstack N}N /@setspecial
  229. {CLIP 1 eq{newpath 0 0 moveto hs 0 rlineto 0 vs rlineto hs neg 0 rlineto
  230. closepath clip}if ho vo TR hsc vsc scale ang rotate rwiSeen{rwi urx llx
  231. sub div rhiSeen{rhi ury lly sub div}{dup}ifelse scale llx neg lly neg TR
  232. }{rhiSeen{rhi ury lly sub div dup scale llx neg lly neg TR}if}ifelse
  233. CLIP 2 eq{newpath llx lly moveto urx lly lineto urx ury lineto llx ury
  234. lineto closepath clip}if /showpage{}N /erasepage{}N /copypage{}N newpath
  235. }N /@endspecial{count ocount sub{pop}repeat countdictstack dcount sub{
  236. end}repeat grestore SpecialSave restore end}N /@defspecial{SDict begin}
  237. N /@fedspecial{end}B /li{lineto}B /rl{rlineto}B /rc{rcurveto}B /np{
  238. /SaveX currentpoint /SaveY X N 1 setlinecap newpath}N /st{stroke SaveX
  239. SaveY moveto}N /fil{fill SaveX SaveY moveto}N /ellipse{/endangle X
  240. /startangle X /yrad X /xrad X /savematrix matrix currentmatrix N TR xrad
  241. yrad scale 0 0 1 startangle endangle arc savematrix setmatrix}N end
  242. %%EndProcSet
  243. TeXDict begin 39158280 55380996 1000 360 360 (diplarb.dvi)
  244. @start /Fa 1 106 df<0C0E0C00000000305898983030606464683007127D910D>105
  245. D E /Fb 4 96 df<70000000000EF8000000001FF8000000001FF8000000001FF8000000
  246. 001FF8000000001FF8000000001FF8000000001FF8000000001FF8000000001FF8000000
  247. 001FF8000000001FF8000000001FF8000000001FF8000000001FF8000000001FF8000000
  248. 001FF8000000001FF8000000001FF8000000001FF8000000001FF8000000001FF8000000
  249. 001FF8000000001FF8000000001FF8000000001FF8000000001FF8000000001FF8000000
  250. 001FF8000000001FF8000000001FF8000000001FF8000000001FF8000000001FF8000000
  251. 001FF8000000001FF8000000001FF8000000001FF8000000001FF8000000001FF8000000
  252. 001FF8000000001FF8000000001FF8000000001FF8000000001FF8000000001FF8000000
  253. 001FF8000000001FF8000000001FF8000000001FFC000000003F7C000000003E7C000000
  254. 003E7E000000007E3E000000007C3F00000000FC1F00000000F81F80000001F80FC00000
  255. 03F00FE0000007F007F000000FE003F800001FC001FE00007F8000FF8001FF00007FF00F
  256. FE00003FFFFFFC00000FFFFFF0000007FFFFE0000000FFFF000000001FF8000030467D7F
  257. 37>91 D<00001FF800000000FFFF00000007FFFFE000000FFFFFF000003FFFFFFC00007F
  258. F00FFE0000FF8001FF0001FE00007F8003F800001FC007F000000FE00FE0000007F00FC0
  259. 000003F01F80000001F81F00000000F83F00000000FC3E000000007C7E000000007E7C00
  260. 0000003E7C000000003EFC000000003FF8000000001FF8000000001FF8000000001FF800
  261. 0000001FF8000000001FF8000000001FF8000000001FF8000000001FF8000000001FF800
  262. 0000001FF8000000001FF8000000001FF8000000001FF8000000001FF8000000001FF800
  263. 0000001FF8000000001FF8000000001FF8000000001FF8000000001FF8000000001FF800
  264. 0000001FF8000000001FF8000000001FF8000000001FF8000000001FF8000000001FF800
  265. 0000001FF8000000001FF8000000001FF8000000001FF8000000001FF8000000001FF800
  266. 0000001FF8000000001FF8000000001FF8000000001FF8000000001FF8000000001FF800
  267. 0000001FF8000000001FF8000000001FF8000000001FF8000000001FF8000000001FF800
  268. 0000001FF8000000001FF8000000001FF8000000001F70000000000E30467D7F37>I<00
  269. 0001C00000000003C00000000007E00000000007E00000000007E0000000000FF0000000
  270. 000FF0000000000FF0000000001FF8000000001FF8000000001FF8000000003FFC000000
  271. 003E7C000000003E7C000000007E7E000000007C3E000000007C3E00000000FC3F000000
  272. 00F81F00000000F81F00000001F81F80000001F00F80000001F00F80000003F00FC00000
  273. 03E007C0000003E007C0000007E007E0000007C003E0000007C003E000000FC003F00000
  274. 0F8001F000000F8001F000001F8001F800001F0000F800001F0000F800003F0000FC0000
  275. 3E00007C00003E00007C00007E00007E00007C00003E00007C00003E0000FC00003F0000
  276. F800001F0000F800001F0001F800001F8001F000000F8001F000000F8003F000000FC003
  277. E0000007C003E0000007C007E0000007E007C0000003E007C0000003E00FC0000003F00F
  278. 80000001F00F80000001F01F80000001F81F00000000F81F00000000F83F00000000FC3E
  279. 000000007C3E000000007C7E000000007E7C000000003E7C000000003EFC000000003FF8
  280. 000000001FF8000000001FF8000000001F70000000000E30467D7F37>94
  281. D<70000000000EF8000000001FF8000000001FF8000000001FFC000000003F7C00000000
  282. 3E7C000000003E7E000000007E3E000000007C3E000000007C3F00000000FC1F00000000
  283. F81F00000000F81F80000001F80F80000001F00F80000001F00FC0000003F007C0000003
  284. E007C0000003E007E0000007E003E0000007C003E0000007C003F000000FC001F000000F
  285. 8001F000000F8001F800001F8000F800001F0000F800001F0000FC00003F00007C00003E
  286. 00007C00003E00007E00007E00003E00007C00003E00007C00003F0000FC00001F0000F8
  287. 00001F0000F800001F8001F800000F8001F000000F8001F000000FC003F0000007C003E0
  288. 000007C003E0000007E007E0000003E007C0000003E007C0000003F00FC0000001F00F80
  289. 000001F00F80000001F81F80000000F81F00000000F81F00000000FC3F000000007C3E00
  290. 0000007C3E000000007E7E000000003E7C000000003E7C000000003FFC000000001FF800
  291. 0000001FF8000000001FF8000000000FF0000000000FF0000000000FF00000000007E000
  292. 00000007E00000000007E00000000003C00000000001C0000030467D7F37>I
  293. E /Fc 1 49 df<060F0F0F1E1E1C3C38383870706060E0C04008127E920B>48
  294. D E /Fd 1 49 df<081C1C3838383070706060C0C0060D7E8D0B>48
  295. D E /Fe 1 50 df<C0000018E0000038F0000078F80000F8DC0001D8CE000398C7000718
  296. C3800E18C1C01C18C0E03818C0707018C038E018C01DC018C00F8018C00F8018C01DC018
  297. C038E018C0707018C0E03818C1C01C18C3800E18C7000718CE000398DC0001D8F80000F8
  298. F0000078E0000038C00000181D1C7D9E24>49 D E /Ff 27 120
  299. df<60F0F06004047C830C>58 D<60F0F07010101020204040040B7C830C>I<0000300000
  300. 007000000078000000F8000001F8000001F800000378000003780000067800000E780000
  301. 0C780000187C0000183C0000303C0000603C0000603C0000FFFC0000FFFC0001803C0003
  302. 003C0003003E0006001E000E001E007F80FFC0FF81FFC01A197E981E>65
  303. D<07FFFE0007FFFF8000F007C000F003C000F001E000F001E001E001C001E003C001E007
  304. 8001E00F0003C03E0003FFF80003C01E0003C00F00078007800780078007800780078007
  305. 800F000F000F000F000F003E000F007C00FFFFF000FFFFC0001B187E971E>I<000FE040
  306. 003FF8C000F81DC001E00780078007800F0003801E0003801C0003003C00030078000300
  307. 78000000F0000000F0000000F0000000F0000000F0000000E0000C00E0000C00F0001800
  308. F000180070003000780060003C00C0001F0380000FFF000003F800001A1A7D981D>I<07
  309. FFFE0007FFFF8000F003E000F000F000F0007000F0007801E0007801E0003801E0003801
  310. E0003803C0007803C0007803C0007803C00078078000F0078000F0078001E0078001C00F
  311. 0003C00F0007800F000E000F007C00FFFFF000FFFFC0001D187E9721>I<07FFFFE007FF
  312. FFE000F001E000F000C000F000C000F000C001E000C001E030C001E030C001E0700003C0
  313. 600003FFE00003FFE00003C0E0000780C1800780C1800780C300078003000F0006000F00
  314. 06000F001E000F007C00FFFFFC00FFFFF8001B187E971D>I<03FFC003FF800078000078
  315. 0000780000780000F00000F00000F00000F00001E00001E00001E00001E00003C00003C0
  316. 0003C00003C0000780000780000780000780007FF000FFF00012187E9712>73
  317. D<07FF8007FF8000F00000F00000F00000F00001E00001E00001E00001E00003C00003C0
  318. 0003C00003C00007800C07800C07800C0780180F00180F00380F00700F01F0FFFFE0FFFF
  319. E016187E971B>76 D<07FC0003FC07FC0007FC00FC000FC000DE000FC000DE001BC000DE
  320. 0033C0019E003780019E006780019E00C780018F00C780030F018F00030F030F00030F03
  321. 0F00030F060F00060F0C1E0006078C1E000607981E000607B01E000C07B03C000C07E03C
  322. 000C07C03C001C03C03C00FF8383FF80FF8303FF8026187E9726>I<07F801FF07FC01FF
  323. 00FC003800FE003000DE003000CF0030018F006001878060018780600183C0600303E0C0
  324. 0301E0C00301F0C00300F0C00600F9800600798006007D8006003D800C003F000C001F00
  325. 0C000F001C000F00FF800600FF80060020187E9720>I<07FFFC0007FFFF0000F0078000
  326. F003C000F001C000F001C001E003C001E003C001E003C001E0078003C00F0003C01E0003
  327. FFF80003C00000078000000780000007800000078000000F0000000F0000000F0000000F
  328. 000000FFE00000FFE000001A187E9719>80 D<07FFF80007FFFE0000F00F0000F0078000
  329. F0038000F003C001E0078001E0078001E0070001E00E0003C0380003FFE00003C0700003
  330. C0380007803C0007803C0007803C0007803C000F0078000F0078000F0078600F007860FF
  331. E078C0FFE0388000000F001B197E971E>82 D<001F84007FCC01E0FC0380380300380700
  332. 380700380F00300F00000F800007F00007FE0003FF8000FFC0001FC00003E00001E00000
  333. E03000E06001C06001C0700380700300FC0E00CFFC0083F000161A7D9818>I<1FFFFFC0
  334. 1FFFFFC03C0F03C0300F0180700F0180600F0180601E0180C01E0180C01E0180001E0000
  335. 003C0000003C0000003C0000003C00000078000000780000007800000078000000F00000
  336. 00F0000000F0000000F000003FFF00003FFF00001A187E9718>I<FFE03FE0FFE03FE01E
  337. 0007001E0006001E0006001E0006003C000C003C000C003C000C003C000C007800180078
  338. 0018007800180078001800F0003000F0003000F0003000F0006000F0006000F000C000F0
  339. 01C000700380003C0E00001FFC000007F000001B197D971B>I<03FF87FC03FF87FC003C
  340. 03C0003E0300001E0600001F0E00000F1C00000FB800000FF0000007E0000007C0000003
  341. C0000003E0000007E000000DF0000018F0000030F0000060F80000C0780001807C000300
  342. 3C000F003E00FFC0FFC0FFC1FFC01E187E9721>88 D<07980C781878303870386070E070
  343. E070E070C0E1C0E3C0E3C1E663E43C38100F7D8E16>97 D<03E00E301878307870706000
  344. E000E000E000C000C000C010603060E01F800D0F7D8E12>99 D<03E00E30181830187030
  345. E070FFC0E000E000E000E000E010603030E01F800D0F7D8E13>101
  346. D<018003C003800380000000000000000000001C0027004700C700C7000E000E001C001C
  347. 001C4038C038C0398039001E000A187E970E>105 D<001C001C003C0018000000000000
  348. 0000000001E0033006380C380C38007000700070007000E000E000E000E001C001C001C0
  349. 01C06380F380F700E60078000E1F7F9710>I<1F801F8007000700070007000E000E000E
  350. 000E0E1C371C4F1C8F1D063A003F003BC038E070E170E370E370E6E064603810187D9715
  351. >I<3C1F00666380478180C781C0C701C00E03800E03800E03800E07001C07081C07181C
  352. 0E181C0E303806601803C0150F7E8E19>110 D<3C7C66C7478FC70FC7060E000E000E00
  353. 0E001C001C001C001C0038001800100F7E8E12>114 D<03E00C300878187818701F001F
  354. E00FF003F06030F030F030E06060C03F000D0F7D8E13>I<1E0183002303878063038380
  355. C7038380C7038380070703000E0703000E0703000E0703001C0E06001C0E06001C0E0400
  356. 0C0E08000617180003E1E000190F7E8E1D>119 D E /Fg 4 62 df<03000F00FF00F700
  357. 07000700070007000700070007000700070007000700070007000700070007000700FFF0
  358. FFF00C177D9614>49 D<0F803FE070F06078F83CF83CF83C703C003C00380078007000E0
  359. 01C0038003000600080C100C201C7FF8FFF8FFF80E177E9614>I<0F801FE038F0707078
  360. 78787878783078007000E001C00F8000E000700038003C703CF83CF83CF838707870F03F
  361. E00F800E187E9614>I<FFFFFF80FFFFFF80000000000000000000000000000000000000
  362. 000000000000FFFFFF80FFFFFF80190A7E8D1F>61 D E /Fh 133[27
  363. 30 30 43 30 33 20 23 27 1[33 30 33 50 17 33 1[17 33 30
  364. 20 27 33 27 33 30 9[60 43 43 40 33 43 47 37 47 43 56
  365. 40 2[23 47 47 37 40 43 43 1[43 8[30 30 30 30 30 30 30
  366. 30 2[15 20 15 2[20 20 37[33 2[{ TeXBase1Encoding ReEncodeFont }58
  367. 60.000002 /Times-Bold rf /Fi 133[32 36 36 52 36 40 24
  368. 28 32 1[40 36 40 60 20 2[20 40 36 24 32 40 32 40 36 9[72
  369. 1[52 48 40 52 56 44 56 1[68 48 2[28 56 56 44 48 52 52
  370. 1[52 8[36 36 36 36 36 36 36 36 1[20 18 1[18 4[24 39[{
  371.  TeXBase1Encoding ReEncodeFont }53 71.999969 /Times-Bold
  372. rf /Fj 139[34 1[46 1[57 7[57 2[46 3[52 29[75 15[52 52
  373. 52 49[{ TeXBase1Encoding ReEncodeFont }10 103.700026
  374. /Times-Bold rf /Fk 43 123 df<07FFFFC00FFFFFC01FFFFFC0383060006070C000C0
  375. 60C000C060C0000060C00000E1C00000C1C00001C1C00001C1C00001C1C0000381C00003
  376. 81C0000781E0000701E0000F01E0000F01F0000E00F0000C00E0001A157F941C>25
  377. D<007FFF8001FFFF8003FFFF800783C0000F01C0001E01E0003C01E0003C01E0007801E0
  378. 007801E0007801E000F003C000F003C000F003C000F0078000F0070000700F0000700E00
  379. 00301800001870000007C0000019157E941C>27 D<78FCFCFCFC7806067C850E>58
  380. D<78FCFCFEFE7A0202020404040810204007107C850E>I<0000000C0000003C000000F0
  381. 000003C000000F0000003C000000F0000003C000000F0000003C000000F0000003C00000
  382. 0F0000003C000000F0000000F00000003C0000000F00000003C0000000F00000003C0000
  383. 000F00000003C0000000F00000003C0000000F00000003C0000000F00000003C0000000C
  384. 1E1E7C9A27>I<C0000000F00000003C0000000F00000003C0000000F00000003C000000
  385. 0F00000003C0000000F00000003C0000000F00000003C0000000F00000003C0000003C00
  386. 0000F0000003C000000F0000003C000000F0000003C000000F0000003C000000F0000003
  387. C000000F0000003C000000F0000000C00000001E1E7C9A27>62 D<000001C000000001C0
  388. 00000003C000000003C000000007C00000000FC00000000FC00000001FC00000001FE000
  389. 000037E000000033E000000063E0000000C3E0000000C3E000000183E000000183E00000
  390. 0303E000000703E000000603E000000C03E000000C03F000001801F000001801F000003F
  391. FFF000007FFFF000006001F00000C001F00000C001F000018001F000038001F000030001
  392. F000070001F8001F0001F800FFE01FFF80FFC01FFF8021237EA225>65
  393. D<00FFFFFC0000FFFFFF000007C00FC00007C003C0000F8003E0000F8001E0000F8001F0
  394. 000F8001F0001F0001E0001F0003E0001F0003E0001F0007C0003E000780003E001F0000
  395. 3E003E00003E00F800007FFFF000007C003C00007C001E00007C001F0000F8000F0000F8
  396. 000F0000F8000F8000F8000F8001F0000F0001F0001F0001F0001F0001F0003E0003E000
  397. 7C0003E0007C0003E001F80007E007E000FFFFFFC000FFFFFE000024227FA126>I<0000
  398. 7F00C00003FFC180000FC0E380001F003380007C001F8000F0000F0001E0000F0003C000
  399. 0F000780000F000F800006000F000006001F000006003E000006003E00000C007C000000
  400. 007C000000007C00000000F800000000F800000000F800000000F800000000F800000000
  401. F000000000F000003000F000003000F000006000F800006000F80000C000780000C00078
  402. 000180003C000300001E000600000F001C000007C070000003FFE00000007F0000002224
  403. 7DA224>I<00FFFFFC0000FFFFFF800007C00FC00007C003E0000F8001F0000F8000F000
  404. 0F800078000F800078001F000078001F00007C001F00007C001F00007C003E00007C003E
  405. 00007C003E00007C003E00007C007C000078007C0000F8007C0000F8007C0000F800F800
  406. 01F000F80001F000F80001E000F80003E001F00003C001F000078001F0000F8001F0000F
  407. 0003E0001E0003E0007C0003E000F00007E007E000FFFFFF8000FFFFFC000026227FA129
  408. >I<00FFFFFFF000FFFFFFF00007C001F00007C000F0000F800070000F800070000F8000
  409. 60000F800060001F000060001F006060001F006060001F006060003E00C000003E00C000
  410. 003E03C000003FFFC000007FFF8000007C038000007C038000007C03800000F803000000
  411. F80300C000F80300C000F800018001F000018001F000030001F000030001F000070003E0
  412. 00060003E0000E0003E0003C0007E000FC00FFFFFFFC00FFFFFFF80024227FA125>I<00
  413. FFFFFFE000FFFFFFE00007C003E00007C001E0000F8000E0000F8000E0000F8000C0000F
  414. 8000C0001F0000C0001F0000C0001F00C0C0001F00C0C0003E018000003E018000003E03
  415. 8000003E078000007FFF0000007FFF0000007C070000007C07000000F806000000F80600
  416. 0000F806000000F806000001F000000001F000000001F000000001F000000003E0000000
  417. 03E000000003E000000007E0000000FFFF800000FFFF00000023227EA120>I<007FFE00
  418. FFFE0007C00007C0000F80000F80000F80000F80001F00001F00001F00001F00003E0000
  419. 3E00003E00003E00007C00007C00007C00007C0000F80000F80000F80000F80001F00001
  420. F00001F00001F00003E00003E00003E00007E0007FFE00FFFE0017227FA116>73
  421. D<00FFFF0000FFFF000007C0000007C000000F8000000F8000000F8000000F8000001F00
  422. 00001F0000001F0000001F0000003E0000003E0000003E0000003E0000007C0000007C00
  423. 00007C0000007C000000F8000000F8000C00F8000C00F8001801F0001801F0001801F000
  424. 3001F0003003E0007003E000E003E003E007E00FE0FFFFFFC0FFFFFFC01E227FA122>76
  425. D<00FFE00003FF8000FFE00003FF800007E00007F0000007E0000DF000000DE0000FE000
  426. 000DE0001BE000000DE0001BE000000DE00033E0000019E00067C0000019E00067C00000
  427. 18F000C7C0000018F000C7C0000030F0018F80000030F0030F80000030F0030F80000030
  428. F0060F80000060F0061F00000060F00C1F00000060F0181F0000006078181F000000C078
  429. 303E000000C078303E000000C078603E000000C078C03E0000018078C07C000001807980
  430. 7C0000018079807C000001807B007C000003007E00F8000003003E00F8000003003C00F8
  431. 00000F803C01F80000FFF0383FFF8000FFF0303FFF800031227EA130>I<007FE001FFC0
  432. 00FFE003FFC00007F0003C000007F0003800000DF0003000000DF8003000000CF8003000
  433. 000CFC00300000187C00600000187C00600000183E00600000183E00600000303F00C000
  434. 00301F00C00000301F80C00000300F80C00000600F81800000600FC18000006007C18000
  435. 006007E1800000C003E3000000C003E3000000C001F3000000C001F30000018001FE0000
  436. 018000FE0000018000FE00000180007E00000300007C00000300007C00000300003C0000
  437. 0F80003C00007FF000180000FFF0001800002A227FA128>I<00007F00000003C1E00000
  438. 0E007000003C0038000078001C0000E0001E0001E0000E0003C0000F000780000F000F00
  439. 000F000F00000F801E00000F803E00000F803E00000F807C00000F807C00000F807C0000
  440. 0F80F800001F00F800001F00F800001F00F800001E00F800003E00F000003E00F000007C
  441. 00F000007C00F00000F800F00000F000F80001F000780003E000780003C0003800078000
  442. 3C000E00001E001C00000F007800000381E0000000FF00000021247DA226>I<00FFFFFC
  443. 0000FFFFFF000007C00F800007C003C0000F8003E0000F8001E0000F8001E0000F8001E0
  444. 001F0003E0001F0003E0001F0003E0001F0003C0003E0007C0003E000780003E000F0000
  445. 3E001E00007C00F800007FFFE000007C000000007C00000000F800000000F800000000F8
  446. 00000000F800000001F000000001F000000001F000000001F000000003E000000003E000
  447. 000003E000000007E0000000FFFE000000FFFE00000023227FA120>I<00FFFFF00000FF
  448. FFFC000007C03F000007C00F80000F8007C0000F8003C0000F8003C0000F8003C0001F00
  449. 07C0001F0007C0001F0007C0001F000F80003E000F00003E001E00003E007800003E01E0
  450. 00007FFF0000007C03C000007C01E000007C00F00000F800F80000F800F80000F800F800
  451. 00F800F80001F001F00001F001F00001F001F00001F001F00003E003E00003E003E06003
  452. E003E06007E001E0C0FFFE01E0C0FFFE00F1800000003E0023237EA126>82
  453. D<0001F8180007FE30001E0770003C01F0007801F000F000E000E000E001E000E001E000
  454. E003E000C003E000C003E0000003E0000003F0000003FF000001FFE00001FFF80000FFFC
  455. 00007FFE00000FFE000000FE0000003F0000001F0000001F0000001F0030001E0030001E
  456. 0030001E0030001C0070003C0078003800780070007C00E000EF03C000C3FF800080FE00
  457. 001D247DA21F>I<1FFFFFFF1FFFFFFF1F01F01F3C01F0073803E0073003E0077003E006
  458. 6003E0066007C006C007C006C007C006C007C006000F8000000F8000000F8000000F8000
  459. 001F0000001F0000001F0000001F0000003E0000003E0000003E0000003E0000007C0000
  460. 007C0000007C0000007C000000F8000000F8000000F8000001F80000FFFFE000FFFFE000
  461. 20227EA11D>I<3FFF00FFE07FFF01FFE003E0001E0003E0001C0007C000180007C00018
  462. 0007C000180007C00018000F800030000F800030000F800030000F800030001F00006000
  463. 1F000060001F000060001F000060003E0000C0003E0000C0003E0000C0003E0000C0007C
  464. 000180007C000180007C000180007C000180007800030000F80003000078000600007800
  465. 06000078000C000078001800003C003000001E00E000000F03C0000007FF00000001FC00
  466. 000023237EA122>I<007FFE0FFF007FFE0FFF0007F003F00003E001C00003F003800003
  467. F007000001F00E000001F80C000000F818000000FC30000000FC600000007CC00000007F
  468. 800000007F800000003F000000003F000000001F000000001F800000003F800000006F80
  469. 000000CFC00000018FC000000387C000000707E000000E03E000000C03F000001803F000
  470. 003001F000006001F80000C001F80001C000F80007C001FC00FFF00FFFC0FFF00FFFC028
  471. 227FA129>88 D<007C6001C6F00303F00601E00E01E01C01E03C01E03803C07803C07803
  472. C07803C0F00780F00780F00784F00786F00F0C700F0C701F083037181867100F81E01715
  473. 7E941A>97 D<01E0003FC0003FC00003C00003C0000780000780000780000780000F0000
  474. 0F00000F00000F00001E00001E7C001EC6001F03003E03803C03C03C03C03C03C07803C0
  475. 7803C07803C07803C0F00780F00780F00780F00F00F00E00701E00701C00303800186000
  476. 0F800012237EA215>I<003F0000E1800381C00703C00E07C01C07C03C03803C00007800
  477. 00780000780000F00000F00000F00000F000007000407000C03001803807001C1C0007F0
  478. 0012157E9416>I<00000F0001FE0001FE00001E00001E00003C00003C00003C00003C00
  479. 00780000780000780000780000F0007CF001C6F00303F00601E00E01E01C01E03C01E038
  480. 03C07803C07803C07803C0F00780F00780F00784F00786F00F0C700F0C701F0830371818
  481. 67100F81E018237EA21A>I<007E000383000701800E01801C0180380180780300700600
  482. FFF800F00000F00000E00000E00000E00000E00000E00080E00180700300300E00183800
  483. 0FE00011157D9417>I<007000F800F800F000E000000000000000000000000000000000
  484. 0F00118021C061C0C3C0C3C0C3C0078007800F000F000F001E001E101E183C303C303C60
  485. 384018C00F000D227FA111>105 D<0078000FF0000FF00000F00000F00001E00001E000
  486. 01E00001E00003C00003C00003C00003C00007800007807807818C07821C0F043C0F087C
  487. 0F107C0F20381EC0001F00001FF0001E3C003C1E003C1E003C0F083C0F0C781E18781E18
  488. 781E10780E30F006206003C016237EA21A>107 D<00F00FE01FE001E001E003C003C003
  489. C003C007800780078007800F000F000F000F001E001E001E001E003C003C003C003C0078
  490. 007800788078C0F180F180F180730073001C000C237EA20F>I<1E03F000338C380063D8
  491. 1C0063E01E00C3E01E00C3C01E00C3C01E0007803C0007803C0007803C0007803C000F00
  492. 78000F0078000F00F0400F00F0601E00F0C01E01E0C01E01E1801E00E1003C00E2001800
  493. 3C001B157F941E>110 D<003F0000E1C00380E00700700E00701C00783C00783C007878
  494. 0078780078780078F000F0F000F0F000E0F001E07001C0700380300700380E001C3C0007
  495. E00015157E9418>I<03C0F80006718C000C7E06000C7C07001878078018780780187807
  496. 8000F0078000F0078000F0078000F0078001E00F0001E00F0001E00F0001E01E0003C01C
  497. 0003C03C0003E0380003E0700007B0C000078F000007800000078000000F0000000F0000
  498. 000F0000000F0000001E0000001E000000FFE00000FFE00000191F819419>I<007C1001
  499. C6700303F00601E00E01E01C01E03C01E03803C07803C07803C07803C0F00780F00780F0
  500. 0780F00780F00F00700F00701F00303F00187E000F9E00001E00001E00003C00003C0000
  501. 3C00003C0000780000780007FF8007FF80141F7E9416>I<1F078033984063F0E063E1E0
  502. C3C3E0C3C3E0C3C1C00780000780000780000780000F00000F00000F00000F00001E0000
  503. 1E00001E00001E00003C000018000013157F9416>I<007E0000C3000181800303800707
  504. 8007078007020007E00007FC0007FE0003FF0001FF80001F80300780780780F80700F807
  505. 00F00600600C003038000FE00011157E9417>I<00E001E001E001E001E003C003C003C0
  506. 03C00780FFFCFFFC07800F000F000F000F001E001E001E001E003C003C003C083C0C7818
  507. 78107830386038C00F000E1F7F9E12>I<0F807019C0F031E0F861E078C1E038C1E038C3
  508. C03803C0300780300780300780300F00600F00600F00400F00C00F00800F01800F010007
  509. 0200038C0001F00015157F9418>118 D<0F80180E19C03C1E31E03C1F61E0780FC1E078
  510. 07C1E07807C3C0780703C0F0060780F0060780F0060780F0060F01E00C0F01E00C0F01E0
  511. 0C0F01E0180F01E0180F01E0100F03E0200702E060038470C000F81F0020157F9424>I<
  512. 03E0F00C3318183E1C303E3C203C7C603C7C603C3800780000780000780000780000F000
  513. 00F00000F00830F00C79E018F9E018F9E030F360606230C03C1F0016157E941C>I<0F80
  514. 0C19C01E31E01E61E03CC1E03CC1E03CC3C03C03C0780780780780780780780F00F00F00
  515. F00F00F00F00F00F01E00F01E00F01E00703E0030FC001F3C00003C00003C00007803C07
  516. 007C0F007C0E00781C0060380030E0001F8000171F7F9418>I<00E03003F03007F86007
  517. FFC00C01800C0300000600000C0000180000300000600000C0000180000300400600600C
  518. 00C01803C03FFF8071FF0060FE00C0780014157E9417>I E /Fl
  519. 14 94 df<00200040008001800300060006000E000C001C001800380038003800700070
  520. 0070007000F000F000F000F000F000F000F000F000F000F000F000F000F000F000700070
  521. 007000700038003800380018001C000C000E0006000600030001800080004000200B327C
  522. A413>40 D<800040002000300018000C000C000E0006000700030003800380038001C001
  523. C001C001C001E001E001E001E001E001E001E001E001E001E001E001E001E001E001C001
  524. C001C001C00380038003800300070006000E000C000C00180030002000400080000B327D
  525. A413>I<0001800000018000000180000001800000018000000180000001800000018000
  526. 0001800000018000000180000001800000018000000180000001800000018000FFFFFFFF
  527. FFFFFFFF0001800000018000000180000001800000018000000180000001800000018000
  528. 000180000001800000018000000180000001800000018000000180000001800020227D9C
  529. 27>43 D<01F800070E000E07001C03803C03C03801C07801E07801E07801E07801E0F801
  530. F0F801F0F801F0F801F0F801F0F801F0F801F0F801F0F801F0F801F0F801F0F801F0F801
  531. F0F801F07801E07801E07801E07801E03C03C03C03C01C03800E0700070E0001F8001422
  532. 7EA019>48 D<00C001C007C0FFC0FBC003C003C003C003C003C003C003C003C003C003C0
  533. 03C003C003C003C003C003C003C003C003C003C003C003C003C003C003C003C0FFFFFFFF
  534. 10217CA019>I<03F8000FFE001C1F803007C06003C06003E0F801E0FC01F0FC01F0FC01
  535. F07801F03001F00001E00003E00003E00007C0000780000F00000E00001C000038000070
  536. 0000E0000180000300300600300400300800701000603FFFE07FFFE0FFFFE0FFFFE01421
  537. 7EA019>I<01F8000FFE001E0F803807C03803C07C03E07C03E07C03E03C03E01803E000
  538. 03C0000780000780000E00001C0003F800000E000007800003C00003E00001E00001F000
  539. 01F03001F07801F0FC01F0FC01F0FC01E0F803E06003C03007801C0F000FFE0003F80014
  540. 227EA019>I<000180000380000380000780000F80001F80001780003780006780004780
  541. 00C7800187800107800307800607800407800C0780180780300780200780600780C00780
  542. FFFFFCFFFFFC00078000078000078000078000078000078000078000FFFC00FFFC16217F
  543. A019>I<1000401E03801FFF001FFE001FFC001FF0001800001800001800001800001800
  544. 0018000018F8001B0E001C07001803801003C00001E00001E00001F00001F00001F07001
  545. F0F801F0F801F0F801F0F801E0C001E06003C07003C03807801C1F000FFC0003F0001422
  546. 7EA019>I<003E0000FF8003C1C00780E00F01E01E03E01C03E03C01C03C000078000078
  547. 0000780000F8F800F90E00FA0300FC0380FC01C0FC01E0F801E0F801F0F801F0F801F0F8
  548. 01F0F801F07801F07801F07801E03801E03C01E01C03C01E03800F0F0003FE0001F80014
  549. 227EA019>I<78FCFCFCFC7800000000000000000078FCFCFCFC7806157C940E>58
  550. D<FFFFFFFFFFFFFFFF000000000000000000000000000000000000000000000000000000
  551. 0000000000FFFFFFFFFFFFFFFF200C7D9127>61 D<FFFFC0C0C0C0C0C0C0C0C0C0C0C0C0
  552. C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0FFFF0831
  553. 7CA40E>91 D<FFFF03030303030303030303030303030303030303030303030303030303
  554. 0303030303030303030303030303030303FFFF08317FA40E>93 D
  555. E /Fm 165[30 1[36 47 36 36 30 28 33 36 28 36 36 44 30
  556. 2[17 36 36 28 30 36 33 1[36 8[25 25 25 25 25 25 25 25
  557. 1[14 12 1[12 4[17 39[{ .167 SlantFont TeXBase1Encoding ReEncodeFont }34
  558. 50.000002 /Times-Roman rf /Fn 105[25 27[22 25 25 36 25
  559. 28 17 19 22 28 28 25 28 41 14 28 1[14 28 25 17 22 28
  560. 22 28 25 10[36 36 33 28 36 39 30 39 36 47 33 39 25 19
  561. 39 39 30 33 36 36 1[36 6[17 25 25 25 25 25 25 25 25 25
  562. 25 14 12 1[12 2[17 17 17 36[28 2[{ TeXBase1Encoding ReEncodeFont }65
  563. 50.000002 /Times-Bold rf /Fo 22 111 df<FFFFFFFCFFFFFFFC1E027C8C27>0
  564. D<C00003E0000770000E38001C1C00380E00700700E00381C001C38000E700007E00003C
  565. 00003C00007E0000E70001C3800381C00700E00E00701C003838001C70000EE00007C000
  566. 031818799727>2 D<00C00000E00000C00000C00040C080E0C1C0F8C7C07CCF801EDE00
  567. 03F00000C00003F0001EDE007CCF80F8C7C0E0C1C040C08000C00000C00000E00000C000
  568. 12157D9619>I[<00038000000FE000000FE000000FE000000FE000000FE0000003800000
  569. 0000000000000000000000000000000000000000000000FFFFFFFEFFFFFFFE0000000000
  570. 0000000000000000000000000000000000000000038000000FE000000FE000000FE00000
  571. 0FE000000FE00000038000>31 28 125 153 38 I<03F0000FFC001FFE003FFF007FFF80
  572. 7FFF80FFFFC0FFFFC0FFFFC0FFFFC0FFFFC0FFFFC0FFFFC0FFFFC07FFF807FFF803FFF00
  573. 1FFE000FFC0003F00012147D9519>15 D<001FFFFC00FFFFFC01E00000078000000E0000
  574. 001C0000003800000030000000700000006000000060000000E0000000C0000000C00000
  575. 00C0000000C0000000C0000000C0000000E0000000600000006000000070000000300000
  576. 00380000001C0000000E0000000780000001E0000000FFFFFC001FFFFC00000000000000
  577. 000000000000000000000000000000000000000000000000007FFFFFFC7FFFFFFC1E287C
  578. 9F27>18 D<0000000C0000003C000000F0000003C000000F0000003C000000F0000003C0
  579. 00000F0000003C000000F0000003C000000F0000003C000000F0000000F00000003C0000
  580. 000F00000003C0000000F00000003C0000000F00000003C0000000F00000003C0000000F
  581. 00000003C0000000F00000003C0000000C00000000000000000000000000000000000000
  582. 00000000000000000000000000FFFFFFFCFFFFFFFC1E287C9F27>20
  583. D<C0000000F00000003C0000000F00000003C0000000F00000003C0000000F00000003C0
  584. 000000F00000003C0000000F00000003C0000000F00000003C0000003C000000F0000003
  585. C000000F0000003C000000F0000003C000000F0000003C000000F0000003C000000F0000
  586. 003C000000F0000000C00000000000000000000000000000000000000000000000000000
  587. 000000000000000000FFFFFFFCFFFFFFFC1E287C9F27>I<000000600000000000300000
  588. 0000003000000000001800000000001800000000000C0000000000060000000000030000
  589. FFFFFFFF8000FFFFFFFFE000000000007000000000001C00000000000F800000000003E0
  590. 000000000780000000001E00000000003800000000006000FFFFFFFFC000FFFFFFFF8000
  591. 0000000300000000000600000000000C0000000000180000000000180000000000300000
  592. 0000003000000000006000002B1C7D9932>41 D<001FFF00FFFF01E0000780000E00001C
  593. 0000380000300000700000600000600000E00000C00000C00000FFFFFFFFFFFFC00000C0
  594. 0000E000006000006000007000003000003800001C00000E000007800001E00000FFFF00
  595. 1FFF181E7C9A21>50 D<00000300000300000700000600000E00000C00001C0000180000
  596. 380000300000700000600000E00000C00001C0000180000380000300000700000600000E
  597. 00000C00001C0000180000180000380000300000700000600000E00000C00001C0000180
  598. 000380000300000700000600000E00000C00001C00001800003800003000007000006000
  599. 00E00000C00000C00000183079A300>54 D<C0000030C0000030E0000070600000607000
  600. 00E0300000C0300000C0380001C018000180180001801C0003800C0003000E00070007FF
  601. FE0007FFFE0007000E0003000C0003000C0003801C000180180001C0380000C0300000C0
  602. 300000E07000006060000070E0000030C0000030C0000039C0000019800000198000001F
  603. 8000000F0000000F000000060000000600001C2480A21D>56 D<FFFFF8FFFFF800001800
  604. 001800001800001800001800001800001800001800001800001800001800001800001800
  605. 00183FFFF87FFFF800001800001800001800001800001800001800001800001800001800
  606. 0018000018000018000018000018000018FFFFF8FFFFF815237DA21C>I<FFFFFFC0FFFF
  607. FFC0000000C0000000C0000000C0000000C0000000C0000000C0000000C0000000C00000
  608. 00C0000000C0000000C01A0D7D9121>I<C00000C0C00000C0C00000C0C00000C0C00000
  609. C0C00000C0C00000C0C00000C0C00000C0C00000C0C00000C0C00000C0C00000C0C00000
  610. C0C00000C0C00000C0C00000C0C00000C0C00000C0C00000C0C00000C0C00000C0C00000
  611. C0E00001C06000018070000380380007001C000E000F807C0003FFF000007F80001A1F7D
  612. 9D21>91 D<007F800003FFF0000F807C001C000E00380007007000038060000180E00001
  613. C0C00000C0C00000C0C00000C0C00000C0C00000C0C00000C0C00000C0C00000C0C00000
  614. C0C00000C0C00000C0C00000C0C00000C0C00000C0C00000C0C00000C0C00000C0C00000
  615. C0C00000C0C00000C0C00000C0C00000C0C00000C01A1F7D9D21>I<000C0000000C0000
  616. 001E0000001E0000003F00000033000000330000007380000061800000E1C00000C0C000
  617. 01C0E000018060000180600003807000030030000700380006001800060018000E001C00
  618. 0C000C001C000E00180006003800070030000300300003007000038060000180E00001C0
  619. C00000C0C00000C01A1F7D9D21>94 D<C00000C0C00000C0E00001C06000018070000380
  620. 300003003000030038000700180006001C000E000C000C000E001C000600180006001800
  621. 070038000300300003807000018060000180600001C0E00000C0C00000E1C00000618000
  622. 007380000033000000330000003F0000001E0000001E0000000C0000000C00001A1F7D9D
  623. 21>I<0007C0003E0000780000F00001E00001E00001E00001E00001E00001E00001E000
  624. 01E00001E00001E00001E00001E00001E00001E00001E00001E00001E00003C000078000
  625. 1F0000F800001F000007800003C00001E00001E00001E00001E00001E00001E00001E000
  626. 01E00001E00001E00001E00001E00001E00001E00001E00001E00001E00000F000007800
  627. 003E000007C012317DA419>102 D<F800001F000007800003C00001E00001E00001E000
  628. 01E00001E00001E00001E00001E00001E00001E00001E00001E00001E00001E00001E000
  629. 01E00001E00000F000007800003E000007C0003E0000780000F00001E00001E00001E000
  630. 01E00001E00001E00001E00001E00001E00001E00001E00001E00001E00001E00001E000
  631. 01E00001E00003C0000780001F0000F8000012317DA419>I<C0C0C0C0C0C0C0C0C0C0C0
  632. C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0
  633. C0C002317AA40E>106 D<C00000C00000E0000060000060000070000030000030000038
  634. 00001800001800001C00000C00000C00000E000006000006000007000003000003000003
  635. 800001800001800001C00000C00000E00000600000600000700000300000300000380000
  636. 1800001800001C00000C00000C00000E0000060000060000070000030000030000038000
  637. 01800001800001C00000C00000C012317DA419>110 D E /Fp 133[19
  638. 22 22 33 22 25 14 19 19 25 25 25 25 36 14 22 14 14 25
  639. 25 14 22 25 22 25 25 9[41 30 36 28 25 30 36 30 36 33
  640. 41 28 33 1[17 36 36 30 30 36 33 30 30 3[34 3[25 6[25
  641. 25 1[14 12 17 12 2[17 17 17 36[25 2[{ TeXBase1Encoding ReEncodeFont }60
  642. 50.000002 /Times-Italic rf /Fq 134[62 1[89 1[69 41 48
  643. 55 1[69 62 69 103 34 2[34 69 62 41 55 1[55 69 62 10[89
  644. 89 1[69 1[96 76 3[83 5[76 2[89 83 89 25[41 39[{
  645.  TeXBase1Encoding ReEncodeFont }30 124.400017 /Times-Bold
  646. rf /Fr 119[30 10[30 30 30 30 30 30 30 30 30 30 30 30
  647. 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 1[30
  648. 1[30 30 30 1[30 30 30 30 30 30 30 30 30 30 30 30 30 30
  649. 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30
  650. 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30
  651. 30 30 30 30 30 30 30 33[{ TeXBase1Encoding ReEncodeFont }91
  652. 50.000002 /Courier rf /Fs 134[30 2[30 1[17 23 20 2[30
  653. 30 47 17 2[17 1[30 20 27 2[30 27 11[43 1[33 2[33 43 43
  654. 53 1[43 3[43 2[43 2[43 7[30 30 5[30 30 2[15 1[15 44[{
  655.  TeXBase1Encoding ReEncodeFont }31 60.000002 /Times-Roman
  656. rf /Ft 87[17 19[22 25[22 25 25 36 25 25 14 19 17 25 25
  657. 25 25 39 14 25 14 14 25 25 17 22 25 22 25 22 3[17 1[17
  658. 1[36 36 47 36 36 30 28 33 36 28 36 36 44 30 36 19 17
  659. 36 36 28 30 36 33 33 36 1[22 1[28 1[14 14 25 25 25 25
  660. 25 25 25 25 25 25 14 12 17 12 28 25 17 17 17 2[25 2[17
  661. 29[28 28 2[{ TeXBase1Encoding ReEncodeFont }82 50.000002
  662. /Times-Roman rf /Fu 139[24 33 29 1[43 43 43 67 24 2[24
  663. 43 43 29 38 1[38 1[38 13[48 1[62 48 1[62 1[53 2[29 3[53
  664. 3[62 65[{ TeXBase1Encoding ReEncodeFont }23 86.399998
  665. /Times-Roman rf /Fv 139[20 1[24 1[36 36 1[56 20 2[20
  666. 3[32 2[36 32 28[52 68[{ TeXBase1Encoding ReEncodeFont }11
  667. 71.999969 /Times-Roman rf end
  668. %%EndProlog
  669. %%BeginSetup
  670. %%Feature: *Resolution 360dpi
  671. TeXDict begin
  672. %%PaperSize: A4
  673. %%EndSetup
  674. %%Page: 1 1
  675. 1 0 bop 907 899 a Fv(Diplomarbeit)221 1151 y Fu(Enhancement)22
  676. b(of)f(the)h(ANSI)f(SQL)g(Implementation)h(of)888 1260
  677. y(PostgreSQL)629 1492 y Ft(ausgef)t(250)-21 b(uhrt)12
  678. b(am)g(Institut)g(f)t(250)-21 b(ur)11 b(Informationssysteme)761
  679. 1552 y(der)h(T)m(echnischen)h(Uni)o(v)o(ersit)s(250)-20
  680. b(at)11 b(W)n(ien)860 1612 y(unter)h(der)g(Anleitung)f(v)o(on)726
  681. 1771 y Fs(O.Uni)o(v)l(.Prof.Dr)m(.)17 b(Geor)o(g)d(Gottlob)1061
  682. 1831 y Ft(und)762 1891 y Fs(Uni)o(v)l(.Ass.)k(Mag.)g(Katrin)c(Se)o(yr)
  683. 671 1950 y Ft(als)f(v)o(erantwortlicher)d(Uni)o(v)o(ersit)s(250)-20
  684. b(atsassistentin)1041 2110 y(durch)859 2269 y Fr(Stefan)29
  685. b(Simkovics)814 2329 y(Paul)h(Petersgasse)e(36)799 2389
  686. y(A)i(-)g(2384)f(Breitenfurt)244 2749 y Fs(No)o(v)o(ember)14
  687. b(29,)g(1998)p 244 2766 475 2 v 414 2819 a Ft(Datum)p
  688. 1431 2730 567 2 v 1594 2800 a(Unterschrift)p eop
  689. %%Page: 2 2
  690. 2 1 bop eop
  691. %%Page: 3 3
  692. 3 2 bop 198 633 a Fq(Abstract)198 892 y Ft(PostgreSQL)14
  693. b(is)i(an)f Fp(object-r)n(elational)f Ft(database)h(management)g
  694. (system)g(that)g(runs)f(on)h(almost)g(an)o(y)198 951
  695. y(UNIX)g(based)i(operating)e(system)h(and)g(is)g(distrib)o(uted)f(as)h
  696. (C-source)g(code.)26 b(It)15 b(is)h(neither)f Fp(fr)n(ee)o(war)n(e)198
  697. 1011 y Ft(nor)f Fp(public)h(domain)f Ft(software.)23
  698. b(It)14 b(is)h(copyrighted)e(by)i(the)g(Uni)o(v)o(ersity)f(of)h
  699. (California)f(b)o(ut)g(may)h(be)198 1071 y(used,)e(modi02ed)e(and)i
  700. (distrib)o(uted)e(as)i(long)f(as)g(the)h(licensing)f(terms)g(of)f(the)i
  701. (copyright)d(are)i(accepted.)273 1131 y(As)g(the)f(name)g(already)h
  702. (suggests,)h(PostgreSQL)e(uses)h(an)g(e)o(xtended)f(subset)h(of)f(the)h
  703. (SQL92)f(stan-)198 1191 y(dard)17 b(as)i(the)f(query)f(language.)32
  704. b(At)18 b(the)g(time)f(of)h(writing)f(this)h(document)f(the)h(actual)g
  705. (v)o(ersion)g(of)198 1250 y(PostgreSQL)11 b(was)h(v6.3.2.)k(In)11
  706. b(this)h(v)o(ersion)g(the)f(implemented)g(part)g(of)g(SQL)h(did)f(not)h
  707. (support)f(some)198 1310 y(important)e(features)g(included)h(in)g(the)g
  708. (SQL92)g(standard.)k(T)l(wo)c(of)g(the)g(not)f(supported)h(features)f
  709. (were:)273 1410 y Fo(17)25 b Ft(the)12 b Fp(having)g(clause)273
  710. 1509 y Fo(17)25 b Ft(the)12 b(support)g(of)g(the)g(set)h(theoretic)f
  711. (operations)g Fp(intersect)g Ft(and)g Fp(e)o(xcept)198
  712. 1609 y Ft(It)e(was)g(the)h(author')m(s)f(task)g(to)g(add)h(the)f
  713. (support)g(for)g(the)g(two)f(missing)i(features)f(to)g(the)h(e)o
  714. (xisting)f(source)198 1669 y(code.)22 b(Before)14 b(the)g
  715. (implementation)g(could)g(be)g(started)h(an)f(intensi)o(v)o(e)h(study)f
  716. (of)g(the)g Fp(r)n(ele)o(vant)i(parts)198 1729 y(of)d(the)g(SQL92)f
  717. (standar)n(d)h Ft(and)g(the)g(implementation)f(of)g(the)h
  718. Fp(e)o(xisting)g(featur)n(es)h Ft(of)f(PostgreSQL)f(had)198
  719. 1788 y(been)h(necessary)m(.)19 b(This)13 b(document)g(will)g(not)g
  720. (present)g(only)f(the)h(results)h(of)e(the)h(implementation)f(b)o(ut)
  721. 198 1848 y(also)h(the)h(kno)o(wledge)e(collected)h(while)g(studying)g
  722. (the)g(SQL)g(language)h(and)f(the)g(source)g(code)g(of)g(the)198
  723. 1908 y(already)f(e)o(xisting)h(features.)273 1968 y(Chapter)i(1)h
  724. (presents)h(an)f(o)o(v)o(ervie)o(w)f(on)h(the)g(SQL92)g(standard.)26
  725. b(It)16 b(gi)o(v)o(es)g(a)g(description)g(of)f(the)198
  726. 2027 y Fp(r)n(elational)k(data)f(model)h Ft(and)g(the)g(theoretical)g
  727. ((mathematical))e(background)i(of)f(SQL.)i(Ne)o(xt)f(the)198
  728. 2087 y(SQL)13 b(language)g(itself)f(is)h(described.)18
  729. b(The)13 b(most)g(important)e(SQL)i(statements)h(are)e(presented)h(and)
  730. g(a)198 2147 y(lot)d(of)g(e)o(xamples)h(are)f(included)h(for)e(better)h
  731. (understanding.)15 b(The)c(information)d(gi)o(v)o(en)j(in)f(this)g
  732. (chapter)198 2207 y(has)j(mainly)f(been)g(taken)g(form)f(the)i(books)f
  733. ([D)n(A)-6 b(TE96)q(],)12 b([D)n(A)-6 b(TE94)q(])12 b(and)g([ULL88)q
  734. (].)273 2267 y(Chapter)18 b(2)g(gi)o(v)o(es)g(a)h(description)e(on)h
  735. (ho)o(w)g(to)g(use)h(PostgreSQL.)f(First)g(it)g(is)g(sho)o(wn)g(ho)o(w)
  736. g(the)198 2326 y Fp(bac)o(kend)e Ft((serv)o(er))g(can)h(be)g(started)
  737. g(and)f(ho)o(w)h(a)g(connection)f(from)g(a)h(client)f(to)h(the)f(serv)o
  738. (er)h(can)g(be)198 2386 y(established.)f(Ne)o(xt)c(some)g(basic)h
  739. (database)f(management)g(tasks)h(like)e(creating)g(a)h(database,)i
  740. (creating)198 2446 y(a)g(table)f(etc.)19 b(are)14 b(described.)19
  741. b(Finally)12 b(some)i(of)f(PostgreSQL)-5 b(')m(s)14 b(special)g
  742. (features)f(like)g Fp(user)h(de02ned)198 2506 y(functions)p
  743. Ft(,)d Fp(user)h(de02ned)f(types)p Ft(,)h(the)f Fp(rule)g(system)h
  744. Ft(etc.)j(are)c(presented)g(and)g(illustrated)f(using)h(a)g(lot)g(of)
  745. 198 2565 y(e)o(xamples.)16 b(The)d(information)d(gi)o(v)o(en)i(in)g
  746. (chapter)g(2)g(has)g(mainly)g(been)g(taken)f(from)g(the)h(PostgreSQL)
  747. 198 2625 y(documentation)17 b((see)i([LOCK98)o(]),)h(the)e
  748. (PostgreSQL)f(manual)h(pages)h(and)f(was)g(v)o(eri02ed)f(by)h(the)198
  749. 2685 y(author)12 b(throughout)f(v)o(arious)h(e)o(xamples)h(which)f(ha)o
  750. (v)o(e)g(also)h(been)g(included.)273 2745 y(Chapter)h(3)g(concentrates)
  751. h(on)f(the)h(internal)e(structure)h(of)g(the)h(PostgreSQL)f
  752. Fp(bac)o(kend)p Ft(.)21 b(First)14 b(the)198 2804 y(stages)19
  753. b(that)g(a)g(query)f(has)h(to)f(pass)h(in)g(order)f(to)g(retrie)o(v)o
  754. (e)g(a)h(result)f(are)g(described)h(using)f(a)h(lot)g(of)198
  755. 2864 y(02gures)h(to)f(illustrate)g(the)h(in)n(v)o(olv)o(ed)g(data)g
  756. (structures.)38 b(The)20 b(information)e(gi)o(v)o(en)i(in)f(that)h
  757. (part)g(of)198 2924 y(chapter)e(3)h(has)g(been)g(collected)g(while)f
  758. (intensi)o(v)o(ely)h(studying)f(the)h(source)f(code)h(of)f(the)h(rele)o
  759. (v)o(ant)198 2984 y(parts)13 b(of)g(PostgreSQL.)g(This)h(intensi)o(v)o
  760. (e)f(and)g(detailed)g(e)o(xamination)g(of)f(the)h(source)h(code)f(had)g
  761. (been)198 3044 y(necessary)h(to)f(be)g(able)g(to)g(add)g(the)g(missing)
  762. h(functionality)m(.)i(The)e(kno)o(wledge)f(gathered)f(during)g(that)198
  763. 3103 y(period)h(of)h(time)f(has)i(been)f(summarized)f(here)h(in)g
  764. (order)f(to)g(make)h(it)f(easier)i(for)e(programmers)f(who)198
  765. 3163 y(are)g(ne)o(w)g(to)h(PostgreSQL)f(to)g(02nd)g(their)g(way)g
  766. (in.)273 3223 y(The)f(follo)o(wing)f(sections)i(co)o(v)o(er)f(the)g
  767. (author')m(s)g(ideas)h(for)e(the)h(implementation)f(of)h(the)g(two)f
  768. (miss-)198 3283 y(ing)i(SQL)h(features)f(mentioned)g(abo)o(v)o(e)g(and)
  769. h(a)f(description)g(of)g(the)g(implementation)g(itself.)273
  770. 3342 y(Section)e(3.7)h(deals)h(with)e(the)h(implementation)e(of)i(the)g
  771. Fp(having)f(logic)p Ft(.)15 b(As)c(mentioned)f(earlier)g(the)198
  772. 3402 y Fp(having)15 b(logic)f Ft(is)i(one)f(of)f(the)h(two)g(missing)g
  773. (SQL92)g(features)g(that)g(the)g(author)f(had)i(to)e(implement.)1086
  774. 3552 y(3)p eop
  775. %%Page: 4 4
  776. 4 3 bop 270 60 a Ft(4)270 234 y(The)13 b(02rst)g(parts)g(of)f(the)h
  777. (chapter)f(describe)h(ho)o(w)g Fp(aggr)n(e)n(gate)f(functions)g
  778. Ft(are)h(realized)g(in)f(PostgreSQL)270 294 y(and)e(after)e(that)i(a)f
  779. (description)g(of)g(the)h(enhancements)g(applied)f(to)g(the)h(code)f
  780. (of)h(the)f Fp(planner/optimizer)270 354 y Ft(and)14
  781. b(the)f Fp(e)o(xecutor)i Ft(in)e(order)g(to)g(realize)h(the)g(ne)o(w)f
  782. (functionality)f(is)i(gi)o(v)o(en.)20 b(The)14 b(functions)f(and)h
  783. (data)270 413 y(structures)e(used)h(and)f(added)h(to)f(the)g(source)h
  784. (code)f(are)g(also)h(handled)f(here.)345 473 y(Section)19
  785. b(3.8)i(deals)g(with)e(the)i(implementation)e(of)g(the)h
  786. Fp(intersect)h Ft(and)f Fp(e)o(xcept)g Ft(functionality)270
  787. 533 y(which)d(was)h(the)f(second)h(missing)f(SQL92)g(feature)g(that)g
  788. (had)h(to)f(be)g(added)h(by)f(the)g(author)m(.)31 b(First)270
  789. 593 y(a)13 b(theoretical)f(description)g(of)g(the)h(basic)g(idea)g(is)g
  790. (gi)o(v)o(en.)j(The)d Fp(intersect)g Ft(and)g Fp(e)o(xcept)g
  791. Ft(logic)f(is)h(imple-)270 653 y(mented)i(using)f(a)i
  792. Fp(query)f(r)n(e)o(write)h Ft(technique)f((i.e.)23 b(a)15
  793. b(query)g(in)n(v)o(olving)f(an)h Fp(intersect)g Ft(and/or)f
  794. Fp(e)o(xcept)270 712 y Ft(operation)h(is)h Fp(r)n(e)o(written)h
  795. Ft(to)f(a)g(semantically)g(equi)o(v)o(alent)f(form)g(that)g(does)i(not)
  796. e(use)h(these)h Fp(set)f(oper)o(-)270 772 y(ations)e
  797. Ft(an)o(y)h(more).)21 b(After)14 b(presenting)g(the)g(basic)h(idea)g
  798. (the)f(changes)h(made)g(to)f(the)h Fp(parser)g Ft(and)f(the)270
  799. 832 y Fp(r)n(e)o(write)g(system)f Ft(are)f(described)h(and)f(the)g
  800. (added)h(functions)f(and)g(data)g(structures)h(are)f(presented.)p
  801. eop
  802. %%Page: 5 5
  803. 5 4 bop 198 633 a Fq(Contents)198 943 y Fn(1)50 b(SQL)1600
  804. b(9)273 1003 y Ft(1.1)52 b(The)13 b(Relational)f(Data)h(Model)27
  805. b(.)e(.)g(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h
  806. (.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)44 b(10)387 1063 y(1.1.1)61
  807. b(F)o(ormal)11 b(Notion)h(of)g(the)g(Relational)h(Data)f(Model)47
  808. b(.)25 b(.)g(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)44
  809. b(10)547 1123 y(Domains)12 b(vs.)k(Data)d(T)l(ypes)35
  810. b(.)25 b(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)
  811. h(.)f(.)h(.)f(.)g(.)h(.)44 b(11)273 1184 y(1.2)52 b(Operations)12
  812. b(in)h(the)f(Relational)g(Data)h(Model)22 b(.)k(.)f(.)g(.)h(.)f(.)g(.)h
  813. (.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)44 b(11)387
  814. 1244 y(1.2.1)61 b(Relational)12 b(Algebra)33 b(.)25 b(.)g(.)h(.)f(.)g
  815. (.)h(.)f(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)h(.)
  816. f(.)g(.)h(.)44 b(11)387 1304 y(1.2.2)61 b(Relational)12
  817. b(Calculus)20 b(.)25 b(.)g(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)f(.)g
  818. (.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)44
  819. b(14)547 1364 y(T)n(uple)12 b(Relational)g(Calculus)43
  820. b(.)25 b(.)h(.)f(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)
  821. f(.)h(.)f(.)g(.)h(.)44 b(14)387 1425 y(1.2.3)61 b(Relational)12
  822. b(Algebra)g(vs.)k(Relational)c(Calculus)43 b(.)26 b(.)f(.)g(.)h(.)f(.)g
  823. (.)h(.)f(.)h(.)f(.)g(.)h(.)44 b(14)273 1485 y(1.3)52
  824. b(The)13 b(SQL)g(Language)28 b(.)e(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h
  825. (.)f(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)
  826. g(.)h(.)44 b(14)387 1545 y(1.3.1)61 b(Select)27 b(.)e(.)h(.)f(.)h(.)f
  827. (.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)
  828. g(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)44 b(15)547 1605
  829. y(Simple)11 b(Selects)42 b(.)25 b(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)h
  830. (.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)
  831. 44 b(15)547 1665 y(Joins)j(.)25 b(.)h(.)f(.)h(.)f(.)g(.)h(.)f(.)g(.)h
  832. (.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)
  833. f(.)h(.)f(.)g(.)h(.)44 b(16)547 1726 y(Aggre)o(gate)12
  834. b(Operators)32 b(.)25 b(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)f(.)g(.)h
  835. (.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)44 b(17)547
  836. 1786 y(Aggre)o(gation)11 b(by)h(Groups)k(.)26 b(.)f(.)g(.)h(.)f(.)h(.)f
  837. (.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)44
  838. b(17)547 1846 y(Ha)o(ving)c(.)26 b(.)f(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f
  839. (.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)
  840. h(.)f(.)g(.)h(.)44 b(19)547 1906 y(Subqueries)39 b(.)26
  841. b(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)f(.)g(.)h
  842. (.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)44 b(19)547
  843. 1967 y(Union,)12 b(Intersect,)h(Except)39 b(.)25 b(.)g(.)h(.)f(.)h(.)f
  844. (.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)44
  845. b(20)387 2027 y(1.3.2)61 b(Data)12 b(De02nition)27
  846. b(.)e(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f
  847. (.)g(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)44 b(21)547
  848. 2087 y(Create)12 b(T)l(able)48 b(.)25 b(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h
  849. (.)f(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)
  850. g(.)h(.)44 b(21)547 2147 y(Data)12 b(T)l(ypes)h(in)g(SQL)29
  851. b(.)c(.)g(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h
  852. (.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)44 b(21)547 2208 y(Create)12
  853. b(Inde)o(x)44 b(.)25 b(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)g
  854. (.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)44
  855. b(22)547 2268 y(Create)12 b(V)m(ie)o(w)j(.)26 b(.)f(.)g(.)h(.)f(.)g(.)h
  856. (.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)
  857. f(.)h(.)f(.)g(.)h(.)44 b(22)547 2328 y(Drop)12 b(T)l(able,)h(Drop)f
  858. (Inde)o(x,)g(Drop)g(V)m(ie)o(w)27 b(.)e(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f
  859. (.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)44 b(23)387 2388 y(1.3.3)61
  860. b(Data)12 b(Manipulation)36 b(.)25 b(.)g(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)
  861. g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)44
  862. b(23)547 2449 y(Insert)12 b(Into)17 b(.)25 b(.)h(.)f(.)g(.)h(.)f(.)g(.)
  863. h(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h
  864. (.)f(.)h(.)f(.)g(.)h(.)44 b(23)547 2509 y(Update)e(.)26
  865. b(.)f(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)f
  866. (.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)44
  867. b(24)547 2569 y(Delete)19 b(.)25 b(.)h(.)f(.)h(.)f(.)g(.)h(.)f(.)g(.)h
  868. (.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)
  869. f(.)h(.)f(.)g(.)h(.)44 b(24)387 2629 y(1.3.4)61 b(System)12
  870. b(Catalogs)40 b(.)26 b(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)f
  871. (.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)44
  872. b(24)387 2690 y(1.3.5)61 b(Embedded)12 b(SQL)17 b(.)25
  873. b(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g
  874. (.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)44 b(24)198 2800
  875. y Fn(2)50 b(P)o(ostgr)o(eSQL)12 b(fr)o(om)h(the)f(User')n(s)h(P)o(oint)
  876. f(of)g(V)n(iew)778 b(26)273 2860 y Ft(2.1)52 b(A)13 b(Short)e(History)h
  877. (of)g(PostgreSQL)k(.)26 b(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)f(.)g(.)h
  878. (.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)44 b(26)273
  879. 2920 y(2.2)52 b(An)13 b(Ov)o(ervie)o(w)e(on)i(the)f(Features)g(of)g
  880. (PostgreSQL)49 b(.)26 b(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)h(.)f
  881. (.)g(.)h(.)44 b(26)273 2981 y(2.3)52 b(Where)12 b(to)h(Get)f
  882. (PostgreSQL)46 b(.)25 b(.)g(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)f(.)g
  883. (.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)44
  884. b(27)547 3041 y(Copyright)11 b(of)h(PostgreSQL)48 b(.)25
  885. b(.)h(.)f(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)h
  886. (.)f(.)g(.)h(.)44 b(27)547 3101 y(Support)11 b(for)g(PostgreSQL)39
  887. b(.)25 b(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)
  888. h(.)f(.)h(.)f(.)g(.)h(.)44 b(27)273 3161 y(2.4)52 b(Ho)o(w)12
  889. b(to)h(use)f(PostgreSQL)i(.)25 b(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)h(.)
  890. f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)44
  891. b(28)387 3222 y(2.4.1)61 b(Starting)11 b(The)i(Postmaster)44
  892. b(.)25 b(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)
  893. h(.)f(.)h(.)f(.)g(.)h(.)44 b(28)387 3282 y(2.4.2)61 b(Creating)12
  894. b(a)g(Ne)o(w)h(Database)k(.)25 b(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)f(.)g(.)
  895. h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)44 b(28)387
  896. 3342 y(2.4.3)61 b(Connecting)12 b(T)l(o)h(a)f(Database)38
  897. b(.)25 b(.)h(.)f(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)
  898. f(.)h(.)f(.)g(.)h(.)44 b(29)387 3402 y(2.4.4)61 b(De02ning)11
  899. b(and)i(Populating)e(T)l(ables)45 b(.)26 b(.)f(.)g(.)h(.)f(.)g(.)h(.)f
  900. (.)g(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)44 b(29)1086
  901. 3552 y(5)p eop
  902. %%Page: 6 6
  903. 6 5 bop 270 60 a Ft(6)1515 b Fm(CONTENTS)459 234 y Ft(2.4.5)61
  904. b(Retrie)o(ving)11 b(Data)i(From)e(The)i(Database)27
  905. b(.)e(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)44
  906. b(30)345 294 y(2.5)52 b(Some)12 b(of)g(PostgreSQL)-5
  907. b(')m(s)13 b(Special)f(Features)g(in)g(Detail)41 b(.)25
  908. b(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)44
  909. b(31)459 354 y(2.5.1)61 b(Inheritance)36 b(.)26 b(.)f(.)g(.)h(.)f(.)g
  910. (.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)
  911. h(.)f(.)h(.)f(.)g(.)h(.)44 b(31)459 413 y(2.5.2)61 b(User)12
  912. b(De02ned)g(Functions)g(.)26 b(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)f(.)
  913. g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)44
  914. b(33)619 473 y(Query)12 b(Language)g((SQL))g(Functions)28
  915. b(.)d(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h
  916. (.)44 b(33)619 533 y(Programming)10 b(Language)j(Functions)18
  917. b(.)25 b(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)
  918. h(.)44 b(35)459 593 y(2.5.3)61 b(User)12 b(De02ned)g(T)l(ypes)18
  919. b(.)25 b(.)g(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)
  920. h(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)44 b(36)459 653 y(2.5.4)61
  921. b(Extending)12 b(Operators)34 b(.)25 b(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)g
  922. (.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)44
  923. b(39)459 712 y(2.5.5)61 b(Extending)12 b(Aggre)o(gates)42
  924. b(.)26 b(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)
  925. g(.)h(.)f(.)h(.)f(.)g(.)h(.)44 b(40)459 772 y(2.5.6)61
  926. b(T)n(riggers)19 b(.)26 b(.)f(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h
  927. (.)f(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)
  928. g(.)h(.)44 b(43)459 832 y(2.5.7)61 b(Serv)o(er)11 b(Programming)g
  929. (Interface)g((SPI))23 b(.)i(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h
  930. (.)f(.)h(.)f(.)g(.)h(.)44 b(46)459 892 y(2.5.8)61 b(Rules)13
  931. b(in)f(PostgreSQL)27 b(.)e(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)f(.)g
  932. (.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)44
  933. b(49)270 1001 y Fn(3)50 b(P)o(ostgr)o(eSQL)12 b(fr)o(om)h(the)f(Pr)o
  934. (ogrammer')n(s)i(P)o(oint)e(of)g(V)n(iew)602 b(51)345
  935. 1061 y Ft(3.1)52 b(The)13 b(W)l(ay)g(of)f(a)g(Query)j(.)26
  936. b(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)f(.)g(.)h
  937. (.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)44 b(51)345
  938. 1121 y(3.2)52 b(Ho)o(w)12 b(Connections)h(are)f(Established)48
  939. b(.)25 b(.)h(.)f(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)
  940. f(.)h(.)f(.)g(.)h(.)44 b(52)345 1181 y(3.3)52 b(The)13
  941. b(P)o(arser)f(Stage)47 b(.)25 b(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h
  942. (.)f(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)
  943. g(.)h(.)44 b(52)459 1240 y(3.3.1)61 b(P)o(arser)25 b(.)g(.)h(.)f(.)h(.)
  944. f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f
  945. (.)g(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)44 b(53)459
  946. 1300 y(3.3.2)61 b(T)n(ransformation)11 b(Process)i(.)26
  947. b(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h
  948. (.)f(.)h(.)f(.)g(.)h(.)44 b(54)345 1360 y(3.4)52 b(The)13
  949. b(PostgreSQL)f(Rule)h(System)45 b(.)26 b(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)
  950. h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)44
  951. b(58)459 1420 y(3.4.1)61 b(The)13 b(Re)o(write)f(System)42
  952. b(.)25 b(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)
  953. f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)44 b(58)619 1479 y(T)m(echniques)12
  954. b(T)l(o)h(Implement)e(V)m(ie)o(ws)19 b(.)26 b(.)f(.)g(.)h(.)f(.)g(.)h
  955. (.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)44 b(58)345
  956. 1539 y(3.5)52 b(Planner/Optimizer)14 b(.)25 b(.)h(.)f(.)g(.)h(.)f(.)g
  957. (.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)
  958. h(.)f(.)h(.)f(.)g(.)h(.)44 b(59)459 1599 y(3.5.1)61 b(Generating)11
  959. b(Possible)i(Plans)40 b(.)25 b(.)h(.)f(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f
  960. (.)g(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)44 b(59)459
  961. 1659 y(3.5.2)61 b(Data)12 b(Structure)f(of)h(the)h(Plan)42
  962. b(.)25 b(.)h(.)f(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)
  963. f(.)h(.)f(.)g(.)h(.)44 b(59)345 1719 y(3.6)52 b(Ex)o(ecutor)18
  964. b(.)25 b(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)
  965. f(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)g
  966. (.)h(.)44 b(60)345 1778 y(3.7)52 b(The)13 b(Realization)g(of)e(the)i
  967. (Ha)o(ving)f(Clause)45 b(.)25 b(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h
  968. (.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)44 b(62)459 1838 y(3.7.1)61
  969. b(Ho)o(w)12 b(Aggre)o(gate)g(Functions)g(are)g(Implemented)23
  970. b(.)j(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)44
  971. b(62)619 1898 y(The)13 b(P)o(arser)f(Stage)36 b(.)26
  972. b(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h
  973. (.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)44 b(62)619 1958 y(The)13
  974. b(Re)o(write)f(System)42 b(.)25 b(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h
  975. (.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)44
  976. b(63)619 2017 y(Planner/Optimizer)d(.)25 b(.)g(.)h(.)f(.)g(.)h(.)f(.)h
  977. (.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)
  978. 44 b(63)619 2077 y(Ex)o(ecutor)h(.)25 b(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f
  979. (.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)
  980. h(.)f(.)g(.)h(.)44 b(65)459 2137 y(3.7.2)61 b(Ho)o(w)12
  981. b(the)g(Ha)o(ving)g(Clause)h(is)g(Implemented)25 b(.)g(.)g(.)h(.)f(.)g
  982. (.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)44 b(66)619 2197
  983. y(The)13 b(P)o(arser)f(Stage)36 b(.)26 b(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)
  984. h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h
  985. (.)44 b(66)619 2257 y(The)13 b(Re)o(write)f(System)42
  986. b(.)25 b(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)
  987. f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)44 b(68)619 2316 y(Planner/Optimizer)d
  988. (.)25 b(.)g(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h
  989. (.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)44 b(80)619 2376 y(Ex)o(ecutor)h(.)
  990. 25 b(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)f(.)
  991. g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)44
  992. b(87)345 2436 y(3.8)52 b(The)13 b(Realization)g(of)e(Union,)i
  993. (Intersect)f(and)g(Except)43 b(.)25 b(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h
  994. (.)f(.)h(.)f(.)g(.)h(.)44 b(89)459 2496 y(3.8.1)61 b(Ho)o(w)12
  995. b(Unions)g(ha)o(v)o(e)h(been)f(Realized)h(Until)f(V)-6
  996. b(ersion)13 b(6.3.2)42 b(.)25 b(.)h(.)f(.)h(.)f(.)g(.)h(.)44
  997. b(91)619 2555 y(The)13 b(P)o(arser)f(Stage)36 b(.)26
  998. b(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h
  999. (.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)44 b(91)619 2615 y(The)13
  1000. b(Re)o(write)f(System)42 b(.)25 b(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h
  1001. (.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)44
  1002. b(92)619 2675 y(Planner/Optimizer)d(.)25 b(.)g(.)h(.)f(.)g(.)h(.)f(.)h
  1003. (.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)
  1004. 44 b(92)619 2735 y(Ex)o(ecutor)h(.)25 b(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f
  1005. (.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)
  1006. h(.)f(.)g(.)h(.)44 b(93)459 2795 y(3.8.2)61 b(Ho)o(w)12
  1007. b(Intersect,)g(Except)h(and)f(Union)g(W)l(ork)g(T)l(ogether)34
  1008. b(.)26 b(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)44 b(93)619
  1009. 2854 y(Set)12 b(Operations)g(as)h(Propositional)e(Logic)i(F)o(ormulas)i
  1010. (.)25 b(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)44 b(95)459
  1011. 2914 y(3.8.3)61 b(Implementing)11 b(Intersect)h(and)g(Except)h(Using)f
  1012. (the)h(Union)f(Capabilities)k(.)26 b(.)44 b(95)619 2974
  1013. y(P)o(arser)25 b(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)
  1014. f(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)g
  1015. (.)h(.)44 b(98)619 3034 y(T)n(ransformations)h(.)26 b(.)f(.)g(.)h(.)f
  1016. (.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)
  1017. h(.)f(.)g(.)h(.)19 b(105)619 3093 y(The)13 b(Re)o(write)f(System)42
  1018. b(.)25 b(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)
  1019. f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)19 b(106)p eop
  1020. %%Page: 7 7
  1021. 7 6 bop 198 633 a Fq(List)32 b(of)f(Figur)n(es)273 892
  1022. y Ft(1.1)52 b(The)13 b(suppliers)g(and)f(parts)g(database)36
  1023. b(.)25 b(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)
  1024. h(.)f(.)h(.)f(.)g(.)h(.)44 b(10)273 1001 y(3.1)52 b(Ho)o(w)12
  1025. b(a)h(connection)f(is)h(established)42 b(.)25 b(.)g(.)h(.)f(.)h(.)f(.)g
  1026. (.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)44
  1027. b(52)273 1061 y(3.2)52 b Fp(T)-5 b(ar)n(getList)12 b
  1028. Ft(and)h Fp(F)m(r)n(omList)g Ft(for)e(query)h(of)g(e)o(xample)h(3.1)35
  1029. b(.)25 b(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)44
  1030. b(54)273 1121 y(3.3)52 b Fp(Wher)n(eClause)14 b Ft(for)e(query)g(of)g
  1031. (e)o(xample)g(3.1)23 b(.)i(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f
  1032. (.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)44 b(55)273 1181 y(3.4)52
  1033. b(T)n(ransformed)12 b Fp(T)-5 b(ar)n(getList)12 b Ft(and)h
  1034. Fp(F)m(r)n(omList)g Ft(for)e(query)h(of)g(e)o(xample)h(3.1)28
  1035. b(.)e(.)f(.)h(.)f(.)g(.)h(.)44 b(56)273 1240 y(3.5)52
  1036. b(T)n(ransformed)12 b Fp(wher)n(e)i(clause)e Ft(for)g(query)g(of)g(e)o
  1037. (xample)g(3.1)23 b(.)j(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)44
  1038. b(57)273 1300 y(3.6)52 b Fp(Plan)13 b Ft(for)e(query)h(of)g(e)o(xample)
  1039. h(3.1)45 b(.)26 b(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g
  1040. (.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)44 b(61)273 1360
  1041. y(3.7)52 b Fp(Querytr)n(ee)14 b Ft(b)o(uilt)e(up)g(for)f(the)i(query)f
  1042. (of)g(e)o(xample)g(3.2)38 b(.)25 b(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f
  1043. (.)h(.)f(.)g(.)h(.)44 b(63)273 1420 y(3.8)52 b Fp(Plantr)n(ee)13
  1044. b Ft(for)f(the)g(query)g(of)g(e)o(xample)h(3.2)46 b(.)25
  1045. b(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)g
  1046. (.)h(.)44 b(64)273 1479 y(3.9)52 b(Data)13 b(structure)f(handed)g(back)
  1047. g(by)h(the)f Fp(parser)49 b Ft(.)25 b(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h
  1048. (.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)44 b(92)273 1539 y(3.10)27
  1049. b Fp(Plan)13 b Ft(for)e(a)i(union)f(query)44 b(.)25 b(.)h(.)f(.)g(.)h
  1050. (.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)
  1051. f(.)h(.)f(.)g(.)h(.)44 b(93)273 1599 y(3.11)27 b Fp(Oper)o(ator)13
  1052. b(tr)n(ee)g Ft(for)f Fl(()p Fk(A)g Fo([)f Fk(B)r Fl())p
  1053. Fo(n)p Fl(()p Fk(C)k Fo(\)d Fk(D)q Fl())29 b Ft(.)d(.)f(.)h(.)f(.)g
  1054. (.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)19
  1055. b(101)273 1659 y(3.12)27 b(Data)13 b(structure)f(handed)g(back)g(by)h
  1056. Fr(SelectStmt)e Ft(rule)48 b(.)26 b(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)h(.)f
  1057. (.)g(.)h(.)19 b(102)273 1719 y(3.13)27 b(Data)13 b(structure)f(of)f
  1058. Fl(()p Fk(A)h Fo([)g Fk(B)r Fl())p Fo(n)p Fk(C)k Ft(after)11
  1059. b(transformation)g(to)h(DNF)50 b(.)25 b(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)
  1060. 19 b(107)273 1778 y(3.14)27 b(Data)13 b(structure)f(of)f
  1061. Fk(A)h Fo(\)f Fk(C)16 b Ft(after)c(query)f(re)o(writing)40
  1062. b(.)26 b(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)19
  1063. b(109)1086 3552 y(7)p eop
  1064. %%Page: 8 8
  1065. 8 7 bop eop
  1066. %%Page: 9 9
  1067. 9 8 bop 198 661 a Fj(Chapter)26 b(1)198 964 y Fq(SQL)198
  1068. 1276 y Ft(SQL)10 b(has)h(become)f(one)g(of)g(the)g(most)g(popular)f
  1069. (relational)g(query)h(languages)g(all)g(o)o(v)o(er)h(the)f(world.)k
  1070. (The)198 1336 y(name)i(224SQL224)g(is)g(an)g(abbre)o(viation)f(for)g
  1071. Fp(Structur)n(ed)h(Query)g(Language)p Ft(.)25 b(In)15
  1072. b(1974)h(Donald)f(Cham-)198 1395 y(berlin)f(and)g(others)g(de02ned)h
  1073. (the)f(language)g(SEQUEL)h Fp((Structur)n(ed)g(English)g(Query)g
  1074. (Language))d Ft(at)198 1455 y(IBM)f(Research.)16 b(This)11
  1075. b(language)f(was)h(02rst)f(implemented)f(in)i(an)f(IBM)h(prototype)e
  1076. (called)i(SEQUEL-)198 1515 y(XRM)h(in)e(1974-75.)15 b(In)10
  1077. b(1976-77)g(a)i(re)o(vised)e(v)o(ersion)h(of)g(SEQUEL)g(called)g
  1078. (SEQUEL/2)g(was)g(de02ned)198 1575 y(and)h(the)h(name)f(was)g
  1079. (changed)h(to)f(SQL)h(subsequently)m(.)273 1688 y(A)j(ne)o(w)f
  1080. (prototype)g(called)h(System)g(R)g(was)g(de)o(v)o(eloped)g(by)f(IBM)h
  1081. (in)g(1977.)26 b(System)16 b(R)g(imple-)198 1748 y(mented)f(a)h(lar)o
  1082. (ge)f(subset)h(of)f(SEQUEL/2)h((no)o(w)f(SQL))g(and)h(a)f(number)g
  1083. (of)g(changes)h(were)g(made)f(to)198 1808 y(SQL)i(during)e(the)h
  1084. (project.)28 b(System)16 b(R)h(was)f(installed)g(in)h(a)f(number)g(of)g
  1085. (user)g(sites,)j(both)d(internal)198 1867 y(IBM)d(sites)h(and)f(also)g
  1086. (some)h(selected)f(customer)g(sites.)19 b(Thanks)13 b(to)g(the)g
  1087. (success)i(and)e(acceptance)h(of)198 1927 y(System)d(R)g(at)g(those)g
  1088. (user)h(sites)f(IBM)g(started)g(to)g(de)o(v)o(elop)g(commercial)f
  1089. (products)h(that)g(implemented)198 1987 y(the)h(SQL)h(language)f(based)
  1090. h(on)f(the)h(System)f(R)g(technology)m(.)273 2100 y(Ov)o(er)g(the)g(ne)
  1091. o(xt)g(years)h(IBM)f(and)h(also)f(a)h(number)e(of)h(other)g(v)o(endors)
  1092. g(announced)g(SQL)g(products)198 2160 y(such)18 b(as)h(SQL/DS)e
  1093. ((IBM),)h(DB2)g((IBM))f(ORA)n(CLE)i((Oracle)e(Corp.))32
  1094. b(DG/SQL)18 b((Data)f(General)198 2220 y(Corp.))e(SYB)n(ASE)e
  1095. ((Sybase)f(Inc.).)273 2333 y(SQL)i(is)h(also)g(an)g(of)o(02cial)e
  1096. (standard)h(no)o(w)m(.)22 b(In)14 b(1982)g(the)h(American)f(National)g
  1097. (Standards)g(Insti-)198 2392 y(tute)g((ANSI))e(chartered)h(its)h
  1098. (Database)h(Committee)e(X3H2)g(to)h(de)o(v)o(elop)g(a)g(proposal)f(for)
  1099. g(a)h(standard)198 2452 y(relational)9 b(language.)16
  1100. b(This)10 b(proposal)g(was)h(rati02ed)e(in)h(1986)g(and)g(consisted)h
  1101. (essentially)g(of)f(the)g(IBM)198 2512 y(dialect)j(of)f(SQL.)i(In)e
  1102. (1987)g(this)h(ANSI)f(standard)h(was)g(also)g(accepted)g(as)h(an)f
  1103. (international)e(standard)198 2572 y(by)h(the)g(International)f(Or)o
  1104. (ganization)g(for)g(Standardization)g((ISO).)f(This)j(original)e
  1105. (standard)h(v)o(ersion)198 2632 y(of)k(SQL)g(is)h(often)f(referred)f
  1106. (to,)i(informally)m(,)f(as)h(224SQL/86224.)27 b(In)16
  1107. b(1989)g(the)h(original)e(standard)h(was)198 2691 y(e)o(xtended)c(and)f
  1108. (this)h(ne)o(w)f(standard)g(is)h(often,)g(again)f(informally)m(,)f
  1109. (referred)h(to)g(as)h(224SQL/89224.)k(Also)11 b(in)198
  1110. 2751 y(1989,)i(a)f(related)g(standard)g(called)h Fp(Database)f
  1111. (Language)f(Embedded)i(SQL)f Ft(was)g(de)o(v)o(eloped.)273
  1112. 2864 y(The)22 b(ISO)f(and)h(ANSI)f(committees)g(ha)o(v)o(e)i(been)f
  1113. (working)e(for)h(man)o(y)h(years)g(on)f(the)h(de02ni-)198
  1114. 2924 y(tion)g(of)g(a)h(greatly)f(e)o(xpanded)h(v)o(ersion)g(of)f(the)h
  1115. (original)e(standard,)26 b(referred)21 b(to)h(informally)g(as)198
  1116. 2984 y(224SQL2224)17 b(or)f(224SQL/92224.)27 b(This)18
  1117. b(v)o(ersion)e(became)g(a)h(rati02ed)f(standard)g(-)g
  1118. (224International)f(Standard)198 3044 y(ISO/IEC)d(9075:1992)o(,)f
  1119. Fp(Database)f(Language)e(SQL)p Ft(224)h(-)h(in)g(late)g(1992.)k
  1120. (224SQL/92224)c(is)g(the)g(v)o(ersion)g(nor)o(-)198
  1121. 3103 y(mally)h(meant)g(when)g(people)h(refer)e(to)h(224the)h(SQL)f
  1122. (standard224.)16 b(A)11 b(detailed)g(description)g(of)g
  1123. (224SQL/92224)198 3163 y(is)18 b(gi)o(v)o(en)f(in)h([D)n(A)-6
  1124. b(TE96)q(].)31 b(At)18 b(the)f(time)h(of)f(writing)g(this)g(document)h
  1125. (a)g(ne)o(w)f(standard)h(informally)198 3223 y(referred)11
  1126. b(to)i(as)g(224SQL3224)g(is)g(under)f(de)o(v)o(elopment.)17
  1127. b(It)12 b(is)h(planned)f(to)h(make)f(SQL)h(a)g(turing-complete)198
  1128. 3283 y(language,)e(i.e.)h(all)f(computable)f(queries)g((e.g.)16
  1129. b(recursi)o(v)o(e)10 b(queries))g(will)h(be)f(possible.)16
  1130. b(This)11 b(is)g(a)g(v)o(ery)198 3342 y(comple)o(x)h(task)h(and)g
  1131. (therefore)e(the)h(completion)g(of)g(the)h(ne)o(w)f(standard)g(can)h
  1132. (not)f(be)h(e)o(xpected)g(before)198 3402 y(1999.)1086
  1133. 3552 y(9)p eop
  1134. %%Page: 10 10
  1135. 10 9 bop 270 60 a Ft(10)1351 b Fm(CHAPTER)14 b(1.)28
  1136. b(SQL)270 234 y Fi(1.1)71 b(The)18 b(Relational)f(Data)g(Model)270
  1137. 346 y Ft(As)10 b(mentioned)f(before,)h(SQL)g(is)g(a)g(relational)e
  1138. (language.)15 b(That)10 b(means)g(it)g(is)g(based)g(on)f(the)h
  1139. (224relational)270 405 y(data)j(model224)f(02rst)g(published)h(by)f
  1140. (E.F)l(.)i(Codd)e(in)h(1970.)j(W)l(e)d(will)f(gi)o(v)o(e)h(a)f(formal)g
  1141. (description)g(of)g(the)270 465 y(relational)h(model)h(in)f(section)h
  1142. (1.1.1)h Fp(F)-5 b(ormal)14 b(Notion)g(of)g(the)f(Relational)h(Data)g
  1143. (Model)g Ft(b)o(ut)f(02rst)h(we)270 525 y(want)e(to)g(ha)o(v)o(e)h(a)
  1144. f(look)g(at)h(it)f(from)f(a)i(more)f(intuiti)o(v)o(e)f(point)h(of)g
  1145. (vie)o(w)m(.)345 585 y(A)19 b Fp(r)n(elational)g(database)g
  1146. Ft(is)h(a)f(database)h(that)f(is)h(percei)o(v)o(ed)f(by)g(its)g(users)h
  1147. (as)g(a)f Fp(collection)g(of)270 645 y(tables)13 b Ft((and)f(nothing)g
  1148. (else)i(b)o(ut)e(tables).)17 b(A)c(table)g(consists)h(of)e(ro)o(ws)h
  1149. (and)f(columns)h(where)g(each)g(ro)o(w)270 704 y(represents)g(a)g
  1150. (record)f(and)h(each)g(column)f(represents)h(an)g(attrib)o(ute)f(of)g
  1151. (the)h(records)f(contained)h(in)f(the)270 764 y(table.)k(Figure)11
  1152. b(1.1)i(sho)o(ws)g(an)f(e)o(xample)h(of)f(a)g(database)h(consisting)g
  1153. (of)f(three)g(tables:)345 864 y Fo(17)25 b Ft(SUPPLIER)16
  1154. b(is)h(a)f(table)h(storing)e(the)i(number)f((SNO),)f(the)i(name)f
  1155. ((SN)n(AME))g(and)h(the)f(city)395 924 y((CITY))11
  1156. b(of)h(a)h(supplier)m(.)345 1024 y Fo(17)25 b Ft(P)-5
  1157. b(AR)m(T)10 b(is)g(a)g(table)g(storing)f(the)h(number)f((PNO))g(the)g
  1158. (name)h((PN)n(AME))g(and)f(the)h(price)g((PRICE))395
  1159. 1084 y(of)h(a)i(part.)345 1184 y Fo(17)25 b Ft(SELLS)12
  1160. b(stores)g(information)e(about)h(which)h(part)f((PNO))g(is)h(sold)f
  1161. (by)h(which)f(supplier)h((SNO).)395 1243 y(It)f(serv)o(es)j(in)e(a)g
  1162. (sense)i(to)e(connect)g(the)h(other)e(two)h(tables)h(together)m(.)360
  1163. 1391 y Fr(SUPPLIER)88 b(SNO)30 b(|)60 b(SNAME)f(|)h(CITY)178
  1164. b(SELLS)90 b(SNO)29 b(|)h(PNO)659 1451 y(-----+---------+--------)326
  1165. b(-----+-----)718 1511 y(1)60 b(|)g(Smith)f(|)30 b(London)417
  1166. b(1)60 b(|)g(1)718 1571 y(2)g(|)g(Jones)f(|)30 b(Paris)447
  1167. b(1)60 b(|)g(2)718 1631 y(3)g(|)g(Adams)f(|)30 b(Vienna)417
  1168. b(2)60 b(|)g(4)718 1690 y(4)g(|)g(Blake)f(|)30 b(Rome)477
  1169. b(3)60 b(|)g(1)1764 1750 y(3)g(|)g(3)1764 1810 y(4)g(|)g(2)360
  1170. 1870 y(PART)208 b(PNO)30 b(|)60 b(PNAME)f(|)h(PRICE)417
  1171. b(4)60 b(|)g(3)659 1929 y(-----+---------+---------)355
  1172. b(4)60 b(|)g(4)718 1989 y(1)g(|)g(Screw)f(|)89 b(10)718
  1173. 2049 y(2)60 b(|)g(Nut)119 b(|)g(8)718 2109 y(3)60 b(|)g(Bolt)89
  1174. b(|)g(15)718 2169 y(4)60 b(|)g(Cam)119 b(|)89 b(25)729
  1175. 2328 y Ft(Figure)12 b(1.1:)j(The)e(suppliers)g(and)f(parts)g(database)
  1176. 270 2448 y(The)h(tables)f(P)-5 b(AR)m(T)13 b(and)f(SUPPLIER)f(may)h(be)
  1177. g(re)o(garded)g(as)g Fp(entities)g Ft(and)g(SELLS)h(may)f(be)g(re)o
  1178. (garded)270 2507 y(as)h(a)g Fp(r)n(elationship)f Ft(between)g(a)h
  1179. (particular)e(part)h(and)h(a)f(particular)f(supplier)m(.)345
  1180. 2567 y(As)k(we)g(will)f(see)h(later)n(,)g(SQL)g(operates)g(on)f(tables)
  1181. h(like)f(the)h(ones)g(just)g(de02ned)f(b)o(ut)g(before)g(that)270
  1182. 2627 y(we)f(will)e(study)i(the)f(theory)g(of)g(the)g(relational)g
  1183. (model.)270 2770 y Fh(1.1.1)59 b(F)o(ormal)13 b(Notion)i(of)f(the)h
  1184. (Relational)e(Data)i(Model)270 2864 y Ft(The)22 b(mathematical)f
  1185. (concept)g(underlying)f(the)h(relational)g(model)g(is)g(the)h
  1186. (set-theoretic)e Fp(r)n(elation)270 2924 y Ft(which)d(is)h(a)g(subset)g
  1187. (of)g(the)f(Cartesian)h(product)f(of)g(a)h(list)f(of)g(domains.)32
  1188. b(This)18 b(set-theoretic)f Fp(r)n(ela-)270 2983 y(tion)i
  1189. Ft(gi)o(v)o(es)g(the)g(model)g(its)g(name)g((do)g(not)g(confuse)g(it)g
  1190. (with)g(the)g(relationship)f(from)g(the)h Fp(Entity-)270
  1191. 3043 y(Relationship)14 b(model)p Ft().)20 b(F)o(ormally)13
  1192. b(a)h(domain)g(is)g(simply)g(a)g(set)g(of)g(v)o(alues.)21
  1193. b(F)o(or)13 b(e)o(xample)h(the)g(set)h(of)270 3103 y(inte)o(gers)d(is)g
  1194. (a)g(domain.)j(Also)c(the)h(set)g(of)f(character)h(strings)f(of)g
  1195. (length)h(20)f(and)h(the)f(real)h(numbers)f(are)270 3163
  1196. y(e)o(xamples)i(of)f(domains.)270 3283 y Fn(De02nition)f(1.1)25
  1197. b Ft(The)65 b Fp(Cartesian)g Ft(product)e(of)h(domains)h
  1198. Fk(D)1580 3290 y Fg(1)1602 3283 y Fk(;)8 b(D)1665 3290
  1199. y Fg(2)1688 3283 y Fk(;)g(:)g(:)g(:)h(;)f(D)1840 3290
  1200. y Ff(k)1929 3283 y Ft(written)270 3342 y Fk(D)311 3349
  1201. y Fg(1)345 3342 y Fo(02)i Fk(D)435 3349 y Fg(2)469
  1202. 3342 y Fo(02)h Fk(:)d(:)g(:)j Fo(02)g Fk(D)679 3349
  1203. y Ff(k)757 3342 y Ft(is)54 b(the)g(set)g(of)f(all)h Fk(k)r
  1204. Ft(-tuples)e Fl(()p Fk(v)1526 3349 y Fg(1)1549 3342
  1205. y Fk(;)8 b(v)1595 3349 y Fg(2)1618 3342 y Fk(;)g(:)g(:)g(:)g(;)g(v)1752
  1206. 3349 y Ff(k)1777 3342 y Fl())54 b Ft(such)g(that)270
  1207. 3402 y Fk(v)294 3409 y Fg(1)330 3402 y Fo(2)14 b Fk(D)418
  1208. 3409 y Fg(1)441 3402 y Fk(;)8 b(v)487 3409 y Fg(2)523
  1209. 3402 y Fo(2)14 b Fk(D)611 3409 y Fg(2)634 3402 y Fk(;)8
  1210. b(:)g(:)g(:)h(;)f(v)769 3409 y Ff(k)807 3402 y Fo(2)14
  1211. b Fk(D)895 3409 y Ff(k)920 3402 y Ft(.)p eop
  1212. %%Page: 11 11
  1213. 11 10 bop 198 60 a Fm(1.2.)29 b(OPERA)-6 b(TIONS)12 b(IN)g(THE)i(RELA)
  1214. -6 b(TION)n(AL)14 b(D)n(A)-6 b(T)h(A)14 b(MODEL)521 b
  1215. Ft(11)198 234 y(F)o(or)16 b(e)o(xample,)h(when)f(we)g(ha)o(v)o(e)g
  1216. Fk(k)22 b Fl(=)f(2)p Ft(,)c Fk(D)989 241 y Fg(1)1032
  1217. 234 y Fl(=)j Fo(f)p Fl(0)p Fk(;)8 b Fl(1)p Fo(g)16 b
  1218. Ft(and)g Fk(D)1358 241 y Fg(2)1401 234 y Fl(=)21 b Fo(f)p
  1219. Fk(a;)8 b(b;)g(c)p Fo(g)p Ft(,)17 b(then)f Fk(D)1796
  1220. 241 y Fg(1)1833 234 y Fo(02)d Fk(D)1926 241 y Fg(2)1965
  1221. 234 y Ft(is)198 294 y Fo(f)p Fl((0)p Fk(;)8 b(a)p Fl())p
  1222. Fk(;)g Fl((0)p Fk(;)g(b)p Fl())p Fk(;)g Fl((0)p Fk(;)g(c)p
  1223. Fl())p Fk(;)g Fl((1)p Fk(;)g(a)q Fl())p Fk(;)g Fl(()q(1)p
  1224. Fk(;)g(b)p Fl())p Fk(;)h Fl((1)p Fk(;)f(c)p Fl())p
  1225. Fo(g)p Ft(.)198 420 y Fn(De02nition)j(1.2)25 b Ft(A)13
  1226. b(Relation)g(is)h(an)o(y)g(subset)f(of)g(the)h(Cartesian)f(product)g
  1227. (of)f(one)i(or)f(more)f(domains:)198 480 y Fk(R)i Fo(22)e
  1228. Fk(D)342 487 y Fg(1)376 480 y Fo(02)f Fk(D)467 487
  1229. y Fg(2)500 480 y Fo(02)g Fk(:)d(:)g(:)j Fo(02)g Fk(D)710
  1230. 487 y Ff(k)198 584 y Ft(F)o(or)g(e)o(xample)h Fo(f)p
  1231. Fl((0)p Fk(;)c(a)p Fl())p Fk(;)g Fl((0)p Fk(;)g(b)p
  1232. Fl())p Fk(;)g Fl((1)p Fk(;)g(a)p Fl())p Fo(g)15 b
  1233. Ft(is)d(a)g(relation,)f(it)g(is)h(in)g(fact)f(a)g(subset)i(of)e
  1234. Fk(D)1635 591 y Fg(1)1666 584 y Fo(02)d Fk(D)1754 591
  1235. y Fg(2)1788 584 y Ft(mentioned)198 644 y(abo)o(v)o(e.)15
  1236. b(The)10 b(members)g(of)f(a)h(relation)e(are)i(called)f(tuples.)15
  1237. b(Each)10 b(relation)f(of)g(some)h(Cartesian)g(product)198
  1238. 703 y Fk(D)239 710 y Fg(1)273 703 y Fo(02)g Fk(D)363
  1239. 710 y Fg(2)397 703 y Fo(02)h Fk(:)d(:)g(:)j Fo(02)g
  1240. Fk(D)607 710 y Ff(k)644 703 y Ft(is)i(said)g(to)f(ha)o(v)o(e)g(arity)g
  1241. Fk(k)i Ft(and)f(is)f(therefore)f(a)i(set)g(of)f Fk(k)r
  1242. Ft(-tuples.)273 764 y(A)j(relation)f(can)h(be)f(vie)o(wed)h(as)g(a)g
  1243. (table)g((as)g(we)g(already)f(did,)i(remember)d(02gure)i(1.1)g
  1244. Fp(The)f(sup-)198 824 y(pliers)j(and)g(parts)h(database)p
  1245. Ft())f(where)g(e)o(v)o(ery)g(tuple)g(is)g(represented)g(by)g(a)h(ro)o
  1246. (w)e(and)i(e)o(v)o(ery)f(column)198 884 y(corresponds)c(to)h(one)f
  1247. (component)g(of)g(a)h(tuple.)19 b(Gi)o(ving)13 b(names)h((called)f
  1248. (attrib)o(utes))f(to)i(the)f(columns)198 944 y(leads)g(to)f(the)g
  1249. (de02nition)g(of)g(a)g Fp(r)n(elation)h(sc)o(heme)p
  1250. Ft(.)198 1070 y Fn(De02nition)e(1.3)25 b Ft(A)12 b
  1251. Fp(r)n(elation)g(sc)o(heme)h Fk(R)g Ft(is)f(a)g(02nite)g(set)g(of)g
  1252. (attrib)o(utes)g Fo(f)p Fk(A)1507 1077 y Fg(1)1529 1070
  1253. y Fk(;)c(A)1588 1077 y Fg(2)1611 1070 y Fk(;)g(:)g(:)g(:)h(;)f(A)1759
  1254. 1077 y Ff(k)1784 1070 y Fo(g)p Ft(.)15 b(There)e(is)198
  1255. 1130 y(a)h(domain)g Fk(D)439 1137 y Ff(i)470 1130 y Ft(for)g(each)g
  1256. (attrib)o(ute)g Fk(A)865 1137 y Ff(i)882 1130 y Fk(;)8
  1257. b Fl(1)17 b Fo(24)g Fk(i)g Fo(24)g Fk(k)f Ft(where)e(the)g(v)o
  1258. (alues)h(of)f(the)g(attrib)o(utes)f(are)i(taken)198 1189
  1259. y(from.)g(W)l(e)d(often)g(write)g(a)h(relation)e(scheme)i(as)g
  1260. Fk(R)p Fl(()p Fk(A)1139 1196 y Fg(1)1162 1189 y Fk(;)8
  1261. b(A)1221 1196 y Fg(2)1244 1189 y Fk(;)g(:)g(:)g(:)h(;)f(A)1392
  1262. 1196 y Ff(k)1417 1189 y Fl())p Ft(.)198 1293 y Fn(Note:)21
  1263. b Ft(A)15 b Fp(r)n(elation)g(sc)o(heme)i Ft(is)e(just)h(a)f(kind)g(of)g
  1264. (template)g(whereas)h(a)g Fp(r)n(elation)f Ft(is)h(an)f(instance)h(of)f
  1265. (a)198 1353 y Fp(r)n(elation)h(sc)o(heme)p Ft(.)26 b(The)17
  1266. b Fp(r)n(elation)e Ft(consists)i(of)e(tuples)h((and)f(can)h(therefore)
  1267. e(be)i(vie)o(wed)f(as)i(a)f(table))198 1413 y(not)c(so)h(the)f
  1268. Fp(r)n(elation)h(sc)o(heme)p Ft(.)198 1552 y Fn(Domains)g(vs.)j(Data)c
  1269. (T)l(ypes)198 1647 y Ft(W)l(e)j(often)g(talked)f(about)h
  1270. Fp(domains)g Ft(in)g(the)g(last)g(section.)25 b(Recall)15
  1271. b(that)g(a)g(domain)g(is,)h(formally)m(,)f(just)198 1707
  1272. y(a)f(set)g(of)f(v)o(alues)h((e.g.,)h(the)e(set)h(of)g(inte)o(gers)f
  1273. (or)g(the)h(real)f(numbers).)19 b(In)13 b(terms)h(of)f(database)h
  1274. (systems)198 1767 y(we)f(often)f(talk)g(of)g Fp(data)h(types)g
  1275. Ft(instead)g(of)f(domains.)k(When)d(we)g(de02ne)f(a)h(table)g(we)f
  1276. (ha)o(v)o(e)h(to)g(make)f(a)198 1827 y(decision)j(about)f(which)g
  1277. (attrib)o(utes)g(to)g(include.)22 b(Additionally)14 b(we)g(ha)o(v)o(e)h
  1278. (to)g(decide)f(which)g(kind)h(of)198 1886 y(data)f(is)f(going)g(to)h
  1279. (be)f(stored)h(as)g(attrib)o(ute)e(v)o(alues.)20 b(F)o(or)13
  1280. b(e)o(xample)g(the)h(v)o(alues)f(of)h(SN)n(AME)g(from)e(the)198
  1281. 1946 y(table)g(SUPPLIER)f(will)g(be)h(character)f(strings,)h(whereas)g
  1282. (SNO)f(will)h(store)f(inte)o(gers.)16 b(W)l(e)c(de02ne)f(this)198
  1283. 2006 y(by)f(assigning)f(a)h Fp(data)g(type)f Ft(to)h(each)g(attrib)o
  1284. (ute.)k(The)c(type)f(of)h(SN)n(AME)g(will)f(be)h(V)-7
  1285. b(ARCHAR(20))9 b((this)198 2066 y(is)14 b(the)f(SQL)h(type)f(for)g
  1286. (character)g(strings)g(of)h(length)f Fo(24)g Ft(20),)h(the)f(type)h
  1287. (of)f(SNO)g(will)g(be)g(INTEGER.)198 2125 y(W)n(ith)i(the)h(assignment)
  1288. g(of)f(a)g Fp(data)h(type)f Ft(we)h(also)g(ha)o(v)o(e)g(selected)g(a)g
  1289. (domain)f(for)f(an)i(attrib)o(ute.)25 b(The)198 2185
  1290. y(domain)12 b(of)g(SN)n(AME)i(is)f(the)f(set)h(of)f(all)h(character)f
  1291. (strings)h(of)f(length)g Fo(24)h Ft(20,)g(the)f(domain)g(of)g(SNO)h
  1292. (is)198 2245 y(the)f(set)h(of)f(all)g(inte)o(ger)g(numbers.)198
  1293. 2419 y Fi(1.2)71 b(Operations)17 b(in)h(the)f(Relational)g(Data)g
  1294. (Model)198 2533 y Ft(In)11 b(section)h(1.1.1)g(we)g(de02ned)f(the)g
  1295. (mathematical)g(notion)g(of)g(the)h(relational)f(model.)k(No)o(w)c(we)h
  1296. (kno)o(w)198 2592 y(ho)o(w)j(the)g(data)h(can)g(be)f(stored)g(using)h
  1297. (a)f(relational)g(data)g(model)g(b)o(ut)h(we)f(do)h(not)f(kno)o(w)g
  1298. (what)g(to)g(do)198 2652 y(with)g(all)f(these)i(tables)f(to)g(retrie)o
  1299. (v)o(e)f(something)g(from)g(the)h(database)g(yet.)24
  1300. b(F)o(or)14 b(e)o(xample)h(somebody)198 2712 y(could)i(ask)g(for)f(the)
  1301. h(names)g(of)g(all)g(suppliers)g(that)g(sell)g(the)g(part)f('Scre)o
  1302. (w'.)28 b(Therefore)17 b(two)f(rather)198 2772 y(dif)o(ferent)11
  1303. b(kinds)h(of)g(notations)g(for)g(e)o(xpressing)g(operations)g(on)h
  1304. (relations)f(ha)o(v)o(e)g(been)h(de02ned:)273 2875
  1305. y Fo(17)25 b Ft(The)14 b Fp(Relational)f(Algebr)o(a)g
  1306. Ft(which)h(is)f(an)h(algebraic)f(notation,)g(where)h(queries)f(are)g(e)
  1307. o(xpressed)323 2934 y(by)f(applying)g(specialized)g(operators)g(to)g
  1308. (the)h(relations.)273 3039 y Fo(17)25 b Ft(The)13 b
  1309. Fp(Relational)f(Calculus)h Ft(which)f(is)h(a)g(logical)g(notation,)f
  1310. (where)h(queries)f(are)h(e)o(xpressed)g(by)323 3098 y(formulating)d
  1311. (some)j(logical)f(restrictions)g(that)g(the)g(tuples)h(in)f(the)g
  1312. (answer)h(must)f(satisfy)m(.)198 3247 y Fh(1.2.1)59 b(Relational)14
  1313. b(Algebra)198 3342 y Ft(The)20 b Fp(Relational)f(Algebr)o(a)h
  1314. Ft(was)f(introduced)g(by)g(E.)i(F)l(.)e(Codd)h(in)f(1972.)37
  1315. b(It)19 b(consists)h(of)f(a)h(set)g(of)198 3402 y(operations)12
  1316. b(on)g(relations:)p eop
  1317. %%Page: 12 12
  1318. 12 11 bop 270 60 a Ft(12)1351 b Fm(CHAPTER)14 b(1.)28
  1319. b(SQL)345 234 y Fo(17)d Ft(SELECT)17 b(()p Fk(33)r
  1320. Ft():)j(e)o(xtracts)c Fp(tuples)g Ft(from)e(a)i(relation)e(that)i
  1321. (satisfy)f(a)h(gi)o(v)o(en)f(restriction.)24 b(Let)16
  1322. b Fk(R)395 294 y Ft(be)f(a)h(table)g(that)f(contains)h(an)g(attrib)o
  1323. (ute)e Fk(A)p Ft(.)27 b Fk(33)1227 301 y Ff(A)p Fg(=)p
  1324. Ff(a)1312 294 y Fl(()p Fk(R)p Fl())21 b(=)e Fo(f)p
  1325. Fk(t)h Fo(2)g Fk(R)g Fo(j)g Fk(t)p Fl(()p Fk(A)p Fl())h(=)f
  1326. Fk(a)p Fo(g)c Ft(where)f Fk(t)395 354 y Ft(denotes)d(a)h(tuple)f(of)g
  1327. Fk(R)g Ft(and)h Fk(t)p Fl(()p Fk(A)p Fl())g Ft(denotes)g(the)f(v)o
  1328. (alue)g(of)g(attrib)o(ute)g Fk(A)h Ft(of)f(tuple)g Fk(t)p
  1329. Ft(.)345 471 y Fo(17)25 b Ft(PR)n(OJECT)17 b(()p Fk(31)r
  1330. Ft():)22 b(e)o(xtracts)16 b(speci02ed)g Fp(attrib)o(utes)g
  1331. Ft((columns))f(from)g(a)h(relation.)26 b(Let)17 b Fk(R)f
  1332. Ft(be)g(a)395 530 y(relation)10 b(that)h(contains)g(an)g(attrib)o(ute)f
  1333. Fk(X)t Ft(.)16 b Fk(31)1156 537 y Ff(X)1194 530 y Fl(()p
  1334. Fk(R)p Fl())f(=)f Fo(f)p Fk(t)p Fl(()p Fk(X)t Fl())g
  1335. Fo(j)g Fk(t)g Fo(2)g Fk(R)p Fo(g)p Ft(,)e(where)f Fk(t)p
  1336. Fl(()p Fk(X)t Fl())h Ft(denotes)395 590 y(the)g(v)o(alue)g(of)g
  1337. (attrib)o(ute)f Fk(X)17 b Ft(of)12 b(tuple)g Fk(t)p Ft(.)345
  1338. 707 y Fo(17)25 b Ft(PR)n(ODUCT)12 b(()p Fo(02)p
  1339. Ft():)i(b)o(uilds)f(the)f(Cartesian)g(product)g(of)f(two)h(relations.)
  1340. j(Let)e Fk(R)g Ft(be)f(a)g(table)g(with)395 767 y(arity)i
  1341. Fk(k)527 774 y Fg(1)564 767 y Ft(and)h(let)g Fk(S)i Ft(be)e(a)g(table)g
  1342. (with)f(arity)g Fk(k)1210 774 y Fg(2)1233 767 y Ft(.)23
  1343. b Fk(R)13 b Fo(02)g Fk(S)k Ft(is)e(the)g(set)g(of)g(all)g
  1344. Fl(()p Fk(k)1780 774 y Fg(1)1815 767 y Fl(+)e Fk(k)1893
  1345. 774 y Fg(2)1915 767 y Fl())p Ft(-tuples)395 827 y(whose)h(02rst)f
  1346. Fk(k)653 834 y Fg(1)690 827 y Ft(components)g(form)g(a)h(tuple)g(in)g
  1347. Fk(R)g Ft(and)g(whose)g(last)g Fk(k)1646 834 y Fg(2)1682
  1348. 827 y Ft(components)g(form)f(a)395 887 y(tuple)f(in)g
  1349. Fk(S)s Ft(.)345 1004 y Fo(17)25 b Ft(UNION)13 b(()p
  1350. Fo([)p Ft():)18 b(b)o(uilds)c(the)g(set-theoretic)f(union)h(of)g(two)f
  1351. (tables.)21 b(Gi)o(v)o(en)14 b(the)g(tables)g Fk(R)h
  1352. Ft(and)f Fk(S)395 1063 y Ft((both)e(must)g(ha)o(v)o(e)h(the)g(same)g
  1353. (arity),)g(the)f(union)h Fk(R)e Fo([)h Fk(S)j Ft(is)e(the)g(set)g(of)g
  1354. (tuples)g(that)f(are)h(in)f Fk(R)i Ft(or)395 1123 y Fk(S)g
  1355. Ft(or)e(both.)345 1240 y Fo(17)25 b Ft(INTERSECT)12
  1356. b(()p Fo(\)p Ft():)h(b)o(uilds)e(the)f(set-theoretic)g(intersection)
  1357. g(of)g(two)g(tables.)16 b(Gi)o(v)o(en)10 b(the)h(tables)395
  1358. 1300 y Fk(R)j Ft(and)f Fk(S)s Ft(,)i Fk(R)d Fo([)g Fk(S)17
  1359. b Ft(is)d(the)g(set)g(of)f(tuples)h(that)g(are)g(in)f
  1360. Fk(R)h Ft(and)g(in)g Fk(S)s Ft(.)20 b(W)l(e)14 b(again)f(require)g
  1361. (that)h Fk(R)395 1360 y Ft(and)e Fk(S)j Ft(ha)o(v)o(e)e(the)f(same)h
  1362. (arity)m(.)345 1477 y Fo(17)25 b Ft(DIFFERENCE)14 b(()p
  1363. Fo(00)g Ft(or)f Fo(n)p Ft():)18 b(b)o(uilds)c(the)g(set)h(dif)o
  1364. (ference)d(of)i(two)f(tables.)21 b(Let)15 b Fk(R)f Ft(and)g
  1365. Fk(S)i Ft(again)395 1536 y(be)c(two)g(tables)g(with)g(the)h(same)g
  1366. (arity)m(.)h Fk(R)e Fo(00)f Fk(S)j Ft(is)f(the)f(set)h(of)f(tuples)h
  1367. (in)f Fk(R)h Ft(b)o(ut)f(not)g(in)g Fk(S)s Ft(.)345 1653
  1368. y Fo(17)25 b Ft(JOIN)d(()p Fe(1)p Ft():)36 b(connects)23
  1369. b(two)g(tables)g(by)g(their)f(common)g(attrib)o(utes.)47
  1370. b(Let)24 b Fk(R)f Ft(be)g(a)g(table)395 1713 y(with)18
  1371. b(the)g(attrib)o(utes)g Fk(A;)8 b(B)22 b Ft(and)c Fk(C)k
  1372. Ft(and)c(let)h Fk(S)i Ft(a)e(table)f(with)g(the)h(attrib)o(utes)f
  1373. Fk(C)q(;)8 b(D)19 b Ft(and)g Fk(E)s Ft(.)395 1773 y(There)k(is)g(one)g
  1374. (attrib)o(ute)f(common)g(to)h(both)f(relations,)k(the)d(attrib)o(ute)f
  1375. Fk(C)t Ft(.)47 b Fk(R)33 b Fe(1)g Fk(S)j Fl(=)395 1833
  1376. y Fk(31)423 1840 y Ff(R:A;R:B)r(;R:C;S:D)q(;S:E)826
  1377. 1833 y Fl(()p Fk(33)873 1840 y Ff(R:C)r Fg(=)p Ff(S:C)1047
  1378. 1833 y Fl(()p Fk(R)15 b Fo(02)e Fk(S)s Fl()))p Ft(.)27
  1379. b(What)16 b(are)g(we)g(doing)f(here?)27 b(W)l(e)16 b(02rst)f(cal-)395
  1380. 1893 y(culate)g(the)h(Cartesian)f(product)g Fk(R)f Fo(02)f
  1381. Fk(S)s Ft(.)24 b(Then)16 b(we)g(select)g(those)g(tuples)f(whose)h(v)o
  1382. (alues)g(for)395 1952 y(the)c(common)g(attrib)o(ute)g
  1383. Fk(C)k Ft(are)d(equal)f(()p Fk(33)1124 1959 y Ff(R:C)r
  1384. Fg(=)p Ff(S:C)1297 1952 y Ft().)17 b(No)o(w)12 b(we)h(got)f(a)h(table)
  1385. g(that)f(contains)h(the)395 2012 y(attrib)o(ute)e Fk(C)16
  1386. b Ft(two)11 b(times)i(and)f(we)h(correct)e(this)i(by)f(projecting)f
  1387. (out)i(the)f(duplicate)g(column.)395 2153 y Fn(Example)g(1.1)25
  1388. b Ft(Let')m(s)11 b(ha)o(v)o(e)g(a)g(look)f(at)g(the)g(tables)h(that)f
  1389. (are)h(produced)e(by)i(e)o(v)o(aluating)e(the)h(steps)395
  1390. 2213 y(necessary)j(for)e(a)i(join.)395 2273 y(Let)f(the)h(follo)o(wing)
  1391. e(two)g(tables)i(be)f(gi)o(v)o(en:)664 2410 y Fr(R)89
  1392. b(A)30 b(|)g(B)f(|)h(C)179 b(S)90 b(C)30 b(|)f(D)h(|)g(E)753
  1393. 2470 y(---+---+---)238 b(---+---+---)783 2529 y(1)30
  1394. b(|)g(2)f(|)h(3)299 b(3)30 b(|)f(a)h(|)g(b)783 2589 y(4)g(|)g(5)f(|)h
  1395. (6)299 b(6)30 b(|)f(c)h(|)g(d)783 2649 y(7)g(|)g(8)f(|)h(9)395
  1396. 2786 y Ft(First)11 b(we)i(calculate)f(the)h(Cartesian)f(product)g
  1397. Fk(R)f Fo(02)g Fk(S)k Ft(and)d(get:)604 2923 y Fr(R)30
  1398. b(x)f(S)90 b(A)30 b(|)f(B)h(|)g(R.C)g(|)f(S.C)h(|)g(D)f(|)h(E)813
  1399. 2983 y(---+---+-----+-----+---+---)843 3042 y(1)g(|)f(2)h(|)60
  1400. b(3)g(|)f(3)h(|)30 b(a)f(|)h(b)843 3102 y(1)g(|)f(2)h(|)60
  1401. b(3)g(|)f(6)h(|)30 b(c)f(|)h(d)843 3162 y(4)g(|)f(5)h(|)60
  1402. b(6)g(|)f(3)h(|)30 b(a)f(|)h(b)843 3222 y(4)g(|)f(5)h(|)60
  1403. b(6)g(|)f(6)h(|)30 b(c)f(|)h(d)843 3281 y(7)g(|)f(8)h(|)60
  1404. b(9)g(|)f(3)h(|)30 b(a)f(|)h(b)843 3341 y(7)g(|)f(8)h(|)60
  1405. b(9)g(|)f(6)h(|)30 b(c)f(|)h(d)p eop
  1406. %%Page: 13 13
  1407. 13 12 bop 198 60 a Fm(1.2.)29 b(OPERA)-6 b(TIONS)12 b(IN)g(THE)i(RELA)
  1408. -6 b(TION)n(AL)14 b(D)n(A)-6 b(T)h(A)14 b(MODEL)521 b
  1409. Ft(13)323 234 y(After)11 b(the)h(selection)h Fk(33)731
  1410. 241 y Ff(R:C)r Fg(=)p Ff(S:C)905 234 y Fl(()p Fk(R)e
  1411. Fo(02)g Fk(S)s Fl())h Ft(we)h(get:)771 347 y Fr(A)30
  1412. b(|)f(B)h(|)g(R.C)g(|)f(S.C)h(|)g(D)f(|)h(E)741 407 y
  1413. (---+---+-----+-----+---+---)771 467 y(1)g(|)f(2)h(|)60
  1414. b(3)g(|)f(3)h(|)30 b(a)f(|)h(b)771 526 y(4)g(|)f(5)h(|)60
  1415. b(6)g(|)f(6)h(|)30 b(c)f(|)h(d)323 639 y Ft(T)l(o)16
  1416. b(remo)o(v)o(e)g(the)f(duplicate)h(column)f Fk(S:C)k
  1417. Ft(we)d(project)f(it)h(out)f(by)h(the)g(follo)o(wing)e(operation:)323
  1418. 699 y Fk(31)351 706 y Ff(R:A;R:B)r(;R:C;S:D)q(;S:E)754
  1419. 699 y Fl(()p Fk(33)801 706 y Ff(R:C)r Fg(=)p Ff(S:C)975
  1420. 699 y Fl(()p Fk(R)e Fo(02)f Fk(S)s Fl()))h Ft(and)h(get:)890
  1421. 812 y Fr(A)30 b(|)g(B)g(|)g(C)f(|)h(D)g(|)g(E)861 872
  1422. y(---+---+---+---+---)890 931 y(1)g(|)g(2)g(|)g(3)f(|)h(a)g(|)g(b)890
  1423. 991 y(4)g(|)g(5)g(|)g(6)f(|)h(c)g(|)g(d)273 1104 y Fo(17)25
  1424. b Ft(DIVIDE)11 b(()p Fo(04)p Ft():)k(Let)d Fk(R)g
  1425. Ft(be)g(a)g(table)g(with)f(the)h(attrib)o(utes)f Fk(A;)d(B)r(;)g(C)16
  1426. b Ft(and)c Fk(D)i Ft(and)d(let)h Fk(S)i Ft(be)e(a)g(table)323
  1427. 1164 y(with)i(the)h(attrib)o(utes)f Fk(C)k Ft(and)d Fk(D)q
  1428. Ft(.)24 b(Then)16 b(we)f(de02ne)g(the)f(di)o(vision)h(as:)21
  1429. b Fk(R)13 b Fo(04)g Fk(S)21 b Fl(=)e Fo(f)p Fk(t)f
  1430. Fo(j)g(8)p Fk(t)1926 1171 y Ff(s)1965 1164 y Fo(2)323
  1431. 1224 y Fk(S)c Fo(9)p Fk(t)414 1231 y Ff(r)450 1224 y
  1432. Fo(2)g Fk(R)e Ft(such)g(that)g Fk(t)755 1231 y Ff(r)777
  1433. 1224 y Fl(()p Fk(A;)c(B)r Fl())15 b(=)f Fk(t)21 b Fo(^)h
  1434. Fk(t)1094 1231 y Ff(r)1116 1224 y Fl(()p Fk(C)q(;)8
  1435. b(D)q Fl())15 b(=)e Fk(t)1340 1231 y Ff(s)1362 1224
  1436. y Fo(g)f Ft(where)f Fk(t)1550 1231 y Ff(r)1572 1224 y
  1437. Fl(()p Fk(x;)d(y)r Fl())14 b Ft(denotes)e(a)g(tuple)323
  1438. 1283 y(of)i(table)g Fk(R)h Ft(that)g(consists)g(only)f(of)g(the)h
  1439. (components)f Fk(x)i Ft(and)e Fk(y)r Ft(.)23 b(Note)14
  1440. b(that)h(the)f(tuple)h Fk(t)f Ft(only)323 1343 y(consists)f(of)f(the)g
  1441. (components)g Fk(A)h Ft(and)f Fk(B)j Ft(of)d(relation)g
  1442. Fk(R)p Ft(.)323 1459 y Fn(Example)g(1.2)25 b Ft(Gi)o(v)o(en)13
  1443. b(the)f(follo)o(wing)f(tables)621 1571 y Fr(R)90 b(A)30
  1444. b(|)g(B)f(|)h(C)g(|)g(D)239 b(S)89 b(C)30 b(|)g(D)711
  1445. 1631 y(---+---+---+---)297 b(---+---)741 1691 y(a)30
  1446. b(|)g(b)f(|)h(c)g(|)g(d)358 b(c)30 b(|)g(d)741 1751 y(a)g(|)g(b)f(|)h
  1447. (e)g(|)g(f)358 b(e)30 b(|)g(f)741 1811 y(b)g(|)g(c)f(|)h(e)g(|)g(f)741
  1448. 1870 y(e)g(|)g(d)f(|)h(c)g(|)g(d)741 1930 y(e)g(|)g(d)f(|)h(e)g(|)g(f)
  1449. 741 1990 y(a)g(|)g(b)f(|)h(d)g(|)g(e)323 2103 y Fk(R)11
  1450. b Fo(04)h Fk(S)i Ft(is)f(deri)o(v)o(ed)f(as)1070 2216
  1451. y Fr(A)30 b(|)f(B)1040 2275 y(---+---)1070 2335 y(a)h(|)f(b)1070
  1452. 2395 y(e)h(|)f(d)198 2508 y Ft(F)o(or)12 b(a)g(more)g(detailed)g
  1453. (description)g(and)g(de02nition)g(of)g(the)g(relational)g(algebra)g
  1454. (refer)f(to)h([ULL88])h(or)198 2568 y([D)n(A)-6 b(TE94)q(].)198
  1455. 2683 y Fn(Example)13 b(1.3)25 b Ft(Recall)12 b(that)g(we)h(formulated)e
  1456. (all)h(those)g(relational)g(operators)f(to)h(be)h(able)f(to)g(retrie)o
  1457. (v)o(e)198 2743 y(data)i(from)e(the)i(database.)20 b(Let')m(s)14
  1458. b(return)f(to)g(our)g(e)o(xample)h(of)f(section)h(1.2)g(where)f
  1459. (someone)h(wanted)198 2803 y(to)d(kno)o(w)f(the)h(names)g(of)g(all)g
  1460. (suppliers)f(that)h(sell)g(the)g(part)g('Scre)o(w'.)i(This)f(question)f
  1461. (can)g(be)g(answered)198 2862 y(using)h(relational)g(algebra)g(by)g
  1462. (the)h(follo)o(wing)e(operation:)222 2965 y Fk(31)250
  1463. 2972 y Ff(S)r(U)t(P)5 b(P)g(LI)s(E)r(R:S)r(N)t(AM)t(E)657
  1464. 2965 y Fl(()p Fk(33)704 2972 y Ff(P)g(ART)s(:P)g(N)t(AM)t(E)r
  1465. Fg(=)1033 2963 y Fd(0)1047 2972 y Ff(S)r(cr)q(ew)1159
  1466. 2963 y Fd(0)1176 2965 y Fl(()p Fk(S)s(U)g(P)i(P)g(LI)t(E)s(R)13
  1467. b Fe(1)h Fk(S)s(E)s(LLS)h Fe(1)f Fk(P)7 b(ART)g Fl()))198
  1468. 3068 y Ft(W)l(e)14 b(call)g(such)g(an)g(operation)g(a)g(query)m(.)20
  1469. b(If)13 b(we)h(e)o(v)o(aluate)f(the)h(abo)o(v)o(e)h(query)e(against)h
  1470. (the)g(tables)g(form)198 3128 y(02gure)e(1.1)g Fp(The)h(suppliers)f
  1471. (and)g(parts)h(database)g Ft(we)f(will)g(obtain)g(the)g(follo)o(wing)f
  1472. (result:)1065 3222 y Fr(SNAME)1035 3282 y(-------)1065
  1473. 3342 y(Smith)1065 3402 y(Adams)p eop
  1474. %%Page: 14 14
  1475. 14 13 bop 270 60 a Ft(14)1351 b Fm(CHAPTER)14 b(1.)28
  1476. b(SQL)270 234 y Fh(1.2.2)59 b(Relational)14 b(Calculus)270
  1477. 332 y Ft(The)20 b(relational)f(calculus)g(is)h(based)g(on)f(the)g
  1478. (02rst)g(order)g(logic.)37 b(There)19 b(are)h(two)e(v)o(ariants)h(of)
  1479. g(the)270 391 y(relational)12 b(calculus:)345 498 y Fo(17)25
  1480. b Ft(The)13 b Fp(Domain)g(Relational)f(Calculus)i Ft((DRC),)f(where)g
  1481. (v)o(ariables)f(stand)i(for)e(components)h((at-)395
  1482. 557 y(trib)o(utes))e(of)h(the)g(tuples.)345 666 y Fo(17)25
  1483. b Ft(The)12 b Fp(T)m(uple)h(Relational)f(Calculus)g Ft((TRC),)h
  1484. (where)f(v)o(ariables)g(stand)h(for)f(tuples.)270 772
  1485. y(W)l(e)j(want)g(to)g(discuss)h(the)f(tuple)g(relational)f(calculus)h
  1486. (only)g(because)h(it)f(is)g(the)g(one)g(underlying)f(the)270
  1487. 832 y(most)c(relational)g(languages.)16 b(F)o(or)10 b(a)g(detailed)g
  1488. (discussion)h(on)g(DRC)g((and)f(also)h(TRC))g(see)g([D)n(A)-6
  1489. b(TE94])270 891 y(or)12 b([ULL88].)270 1036 y Fn(T)-5
  1490. b(uple)12 b(Relational)g(Calculus)270 1133 y Ft(The)h(queries)f(used)h
  1491. (in)f(TRC)i(are)e(of)g(the)g(follo)o(wing)f(form:)1019
  1492. 1247 y Fo(f)p Fk(x)p Fl(()p Fk(A)p Fl())k Fo(j)f Fk(F)7
  1493. b Fl(()p Fk(x)p Fl())p Fo(g)270 1361 y Ft(where)k Fk(x)h
  1494. Ft(is)g(a)f(tuple)g(v)o(ariable)g Fk(A)h Ft(is)g(a)f(set)h(of)f(attrib)
  1495. o(utes)g(and)g Fk(F)19 b Ft(is)11 b(a)h(formula.)i(The)e(resulting)f
  1496. (relation)270 1421 y(consists)i(of)f(all)g(tuples)h Fk(t)p
  1497. Fl(()p Fk(A)p Fl())g Ft(that)g(satisfy)f Fk(F)7 b Fl(()p
  1498. Fk(t)p Fl())p Ft(.)270 1554 y Fn(Example)13 b(1.4)25
  1499. b Ft(If)9 b(we)h(want)g(to)g(answer)g(the)g(question)g(from)f(e)o
  1500. (xample)h(1.3)g(using)g(TRC)h(we)f(formulate)270 1613
  1501. y(the)i(follo)o(wing)f(query:)370 1725 y Fo(f)p Fk(x)p
  1502. Fl(()p Fk(S)s(N)5 b(AM)g(E)s Fl())51 b Fo(j)f Fk(x)14
  1503. b Fo(2)g Fk(S)s(U)5 b(P)i(P)g(LI)t(E)s(R)12 b Fo(^)785
  1504. 1785 y(9)p Fk(y)k Fo(2)e Fk(S)s(E)s(LLS)g Fo(9)p Fk(z)h
  1505. Fo(2)f Fk(P)7 b(ART)58 b Fl(()p Fk(y)r Fl(()p Fk(S)s(N)5
  1506. b(O)q Fl())15 b(=)f Fk(x)p Fl(()p Fk(S)s(N)5 b(O)q
  1507. Fl())14 b Fo(^)1413 1845 y Fk(z)r Fl(()p Fk(P)7 b(N)e(O)q
  1508. Fl())16 b(=)d Fk(y)r Fl(()p Fk(P)7 b(N)e(O)q Fl())15
  1509. b Fo(^)1413 1904 y Fk(z)r Fl(()p Fk(P)7 b(N)e(AM)g(E)s
  1510. Fl())16 b(=)1745 1886 y Fc(0)1773 1904 y Fk(S)s(cr)q(ew)1912
  1511. 1886 y Fc(0)1926 1904 y Fl())p Fo(g)270 2016 y Ft(Ev)o(aluating)f(the)
  1512. h(query)f(against)h(the)f(tables)h(from)e(02gure)h(1.1)h
  1513. Fp(The)g(suppliers)g(and)f(parts)h(database)270 2075
  1514. y Ft(again)c(leads)h(to)f(the)g(same)h(result)f(as)h(in)g(e)o(xample)f
  1515. (1.3.)270 2230 y Fh(1.2.3)59 b(Relational)14 b(Algebra)f(vs.)19
  1516. b(Relational)13 b(Calculus)270 2327 y Ft(The)j(relational)g(algebra)f
  1517. (and)h(the)g(relational)f(calculus)i(ha)o(v)o(e)f(the)g(same)g
  1518. Fp(e)o(xpr)n(essive)i(power)e Ft(i.e.)h(all)270 2387
  1519. y(queries)g(that)f(can)i(be)e(formulated)g(using)h(relational)f
  1520. (algebra)h(can)g(also)g(be)g(formulated)e(using)i(the)270
  1521. 2447 y(relational)9 b(calculus)h(and)g(vice)g(v)o(ersa.)16
  1522. b(This)10 b(was)g(02rst)g(pro)o(v)o(ed)g(by)g(E.)h(F)l(.)f(Codd)g(in)
  1523. g(1972.)k(This)d(proof)e(is)270 2507 y(based)k(on)g(an)f(algorithm)g
  1524. (-224Codd')m(s)g(reduction)g(algorithm224-)f(by)h(which)h(an)f
  1525. (arbitrary)g(e)o(xpression)h(of)270 2567 y(the)g(relational)f(calculus)
  1526. h(can)g(be)g(reduced)f(to)h(a)g(semantically)f(equi)o(v)o(alent)g(e)o
  1527. (xpression)i(of)e(relational)270 2626 y(algebra.)j(F)o(or)d(a)h(more)f
  1528. (detailed)g(discussion)h(on)f(that)g(refer)g(to)g([D)n(A)-6
  1529. b(TE94)q(])12 b(and)g([ULL88].)345 2688 y(It)i(is)h(sometimes)g(said)g
  1530. (that)f(languages)h(based)g(on)g(the)f(relational)g(calculus)h(are)g
  1531. (224higher)f(le)o(v)o(el224)270 2748 y(or)e(224more)g(declarati)o(v)
  1532. o(e224)h(than)f(languages)h(based)g(on)f(relational)g(algebra)g
  1533. (because)h(the)g(algebra)f((par)o(-)270 2808 y(tially))i(speci02es)
  1534. h(the)g(order)f(of)g(operations)h(while)f(the)h(calculus)g(lea)o(v)o
  1535. (es)h(it)e(to)h(a)g(compiler)f(or)g(inter)o(-)270 2868
  1536. y(preter)e(to)g(determine)f(the)i(most)f(ef)o(02cient)g(order)f(of)h
  1537. (e)o(v)o(aluation.)270 3048 y Fi(1.3)71 b(The)18 b(SQL)f(Language)270
  1538. 3163 y Ft(As)11 b(most)f(modern)g(relational)f(languages)i(SQL)f(is)h
  1539. (based)g(on)f(the)g(tuple)g(relational)g(calculus.)15
  1540. b(As)c(a)g(re-)270 3223 y(sult)i(e)o(v)o(ery)f(query)g(that)h(can)g(be)
  1541. f(formulated)g(using)g(the)h(tuple)f(relational)g(calculus)h((or)f
  1542. (equi)o(v)o(alently)m(,)270 3283 y(relational)g(algebra))h(can)g(also)
  1543. h(be)f(formulated)f(using)i(SQL.)g(There)f(are,)h(ho)o(we)o(v)o(er)n(,)
  1544. f(capabilities)g(be-)270 3342 y(yond)h(the)f(scope)i(of)e(relational)h
  1545. (algebra)f(or)h(calculus.)20 b(Here)14 b(is)g(a)h(list)e(of)h(some)g
  1546. (additional)f(features)270 3402 y(pro)o(vided)f(by)g(SQL)h(that)f(are)g
  1547. (not)g(part)g(of)g(relational)g(algebra)g(or)g(calculus:)p
  1548. eop
  1549. %%Page: 15 15
  1550. 15 14 bop 198 60 a Fm(1.3.)29 b(THE)13 b(SQL)f(LANGU)n(A)n(GE)1160
  1551. b Ft(15)273 234 y Fo(17)25 b Ft(Commands)12 b(for)f(insertion,)i
  1552. (deletion)f(or)g(modi02cation)f(of)h(data.)273 333
  1553. y Fo(17)25 b Ft(Arithmetic)12 b(capability:)17 b(In)c(SQL)h(it)g(is)f
  1554. (possible)h(to)g(in)n(v)o(olv)o(e)f(arithmetic)g(operations)g(as)h
  1555. (well)323 393 y(as)g(comparisons,)h(e.g.)22 b Fk(A)c(<)f(B)e
  1556. Fl(+)d(3)p Ft(.)21 b(Note)15 b(that)f Fl(+)g Ft(or)g(other)f
  1557. (arithmetic)h(operators)f(appear)323 453 y(neither)e(in)i(relational)e
  1558. (algebra)h(nor)g(in)g(relational)g(calculus.)273 552
  1559. y Fo(17)25 b Ft(Assignment)14 b(and)g(Print)g(Commands:)19
  1560. b(It)14 b(is)g(possible)h(to)f(print)g(a)g(relation)g(constructed)g(by)
  1561. g(a)323 612 y(query)d(and)i(to)f(assign)h(a)g(computed)e(relation)h(to)
  1562. g(a)h(relation)f(name.)273 711 y Fo(17)25 b Ft(Aggre)o(gate)15
  1563. b(Functions:)22 b(Operations)16 b(such)g(as)h Fp(aver)o(age)p
  1564. Ft(,)g Fp(sum)p Ft(,)h Fp(max)p Ft(,)f(.)7 b(.)g(.)g(can)19
  1565. b(be)d(applied)g(to)323 771 y(columns)c(of)g(a)g(relation)g(to)g
  1566. (obtain)g(a)h(single)f(quantity)m(.)198 913 y Fh(1.3.1)59
  1567. b(Select)198 1006 y Ft(The)17 b(most)f(often)g(used)h(command)f(in)g
  1568. (SQL)h(is)f(the)h(SELECT)h(statement)e(that)g(is)h(used)g(to)f(retrie)o
  1569. (v)o(e)198 1066 y(data.)g(The)d(syntax)f(is:)288 1165
  1570. y Fr(SELECT)29 b([ALL|DISTINCT])497 1225 y({)h(*)f(|)h(<expr_1>)f([AS)h
  1571. (<c_alias_1>])e([,)i(...)676 1285 y([,)g(<expr_k>)f([AS)g
  1572. (<c_alias_k>]]]})288 1344 y(FROM)g(<table_name_1>)f([t_alias_1])437
  1573. 1404 y([,)i(...)f([,)h(<table_name_n>)e([t_alias_n]]])288
  1574. 1464 y([WHERE)h(condition])288 1524 y([GROUP)g(BY)h(<name_of_attr_i>)
  1575. 587 1583 y([,...)f([,)h(<name_of_attr_j>]])d([HAVING)j(condition]])288
  1576. 1643 y([{UNION)f(|)h(INTERSECT)e(|)i(EXCEPT})f(SELECT)h(...])288
  1577. 1703 y([ORDER)f(BY)h(<name_of_attr_i>)e([ASC|DESC])587
  1578. 1763 y([,)h(...)h([,)f(<name_of_attr_j>)g([ASC|DESC]]]];)198
  1579. 1861 y Ft(No)o(w)15 b(we)g(will)g(illustrate)g(the)g(comple)o(x)g
  1580. (syntax)g(of)g(the)g(SELECT)i(statement)f(with)f(v)o(arious)f(e)o(xam-)
  1581. 198 1921 y(ples.)28 b(The)17 b(tables)g(used)f(for)g(the)g(e)o(xamples)
  1582. h(are)f(de02ned)g(in)g(02gure)g(1.1)h Fp(The)f(suppliers)g(and)h
  1583. (parts)198 1981 y(database)p Ft(.)198 2113 y Fn(Simple)12
  1584. b(Selects)198 2207 y(Example)h(1.5)25 b Ft(Here)12 b(are)g(some)h
  1585. (simple)f(e)o(xamples)h(using)f(a)h(SELECT)h(statement:)198
  1586. 2326 y(T)l(o)23 b(retrie)o(v)o(e)f(all)h(tuples)g(from)f(table)g(P)-5
  1587. b(AR)m(T)24 b(where)f(the)f(attrib)o(ute)g(PRICE)h(is)g(greater)g(than)
  1588. f(10)198 2386 y(we)13 b(formulate)e(the)h(follo)o(wing)f(query)288
  1589. 2485 y Fr(SELECT)29 b(*)288 2545 y(FROM)g(PART)288 2604
  1590. y(WHERE)g(PRICE)g(>)h(10;)198 2703 y Ft(and)12 b(get)h(the)f(table:)766
  1591. 2802 y Fr(PNO)29 b(|)60 b(PNAME)f(|)h(PRICE)736 2862
  1592. y(-----+---------+--------)796 2921 y(3)f(|)h(Bolt)89
  1593. b(|)h(15)796 2981 y(4)59 b(|)h(Cam)119 b(|)90 b(25)198
  1594. 3080 y Ft(Using)12 b(224)p Fo(03)p Ft(224)g(in)g(the)g(SELECT)i
  1595. (statement)e(will)g(deli)o(v)o(er)f(all)h(attrib)o(utes)g(from)f(the)h
  1596. (table.)j(If)d(we)g(want)f(to)198 3140 y(retrie)o(v)o(e)h(only)g(the)g
  1597. (attrib)o(utes)g(PN)n(AME)h(and)f(PRICE)h(from)e(table)h(P)-5
  1598. b(AR)m(T)14 b(we)e(use)h(the)f(statement:)288 3238 y
  1599. Fr(SELECT)29 b(PNAME,)g(PRICE)288 3298 y(FROM)g(PART)288
  1600. 3358 y(WHERE)g(PRICE)g(>)h(10;)p eop
  1601. %%Page: 16 16
  1602. 16 15 bop 270 60 a Ft(16)1351 b Fm(CHAPTER)14 b(1.)28
  1603. b(SQL)270 234 y Ft(In)12 b(this)g(case)i(the)e(result)g(is:)928
  1604. 339 y Fr(PNAME)59 b(|)g(PRICE)898 399 y(--------+--------)928
  1605. 459 y(Bolt)89 b(|)g(15)928 519 y(Cam)119 b(|)89 b(25)270
  1606. 622 y Ft(Note)12 b(that)f(the)h(SQL)g(SELECT)i(corresponds)e(to)f(the)h
  1607. (224projection224)f(in)h(relational)f(algebra)h(not)f(to)h(the)270
  1608. 682 y(224selection224)h((see)f(section)h(1.2.1)g Fp(Relational)f
  1609. (Algebr)o(a)p Ft().)270 802 y(The)26 b(quali02cations)g(in)g(the)f
  1610. (WHERE)i(clause)g(can)f(also)g(be)g(logically)f(connected)h(using)g
  1611. (the)270 862 y(ke)o(ywords)11 b(OR,)i(AND)g(and)f(NO)n(T)n(:)360
  1612. 967 y Fr(SELECT)29 b(PNAME,)g(PRICE)360 1027 y(FROM)g(PART)360
  1613. 1086 y(WHERE)g(PNAME)g(=)h('Bolt')f(AND)539 1146 y((PRICE)g(=)h(0)g
  1614. (OR)f(PRICE)h(<)g(15);)270 1250 y Ft(will)12 b(lead)g(to)h(the)f
  1615. (result:)928 1355 y Fr(PNAME)59 b(|)g(PRICE)898 1415
  1616. y(--------+--------)928 1475 y(Bolt)89 b(|)g(15)270 1578
  1617. y Ft(Arithmetic)10 b(operations)g(may)h(be)g(used)g(in)g(the)f
  1618. Fp(selectlist)i Ft(and)e(in)h(the)g(WHERE)h(clause.)k(F)o(or)10
  1619. b(e)o(xample)270 1638 y(if)k(we)h(want)f(to)g(kno)o(w)h(ho)o(w)f(much)g
  1620. (it)g(would)g(cost)h(if)f(we)h(take)f(two)g(pieces)h(of)f(a)h(part)f
  1621. (we)h(could)g(use)270 1698 y(the)d(follo)o(wing)f(query:)360
  1622. 1803 y Fr(SELECT)29 b(PNAME,)g(PRICE)g(*)h(2)g(AS)g(DOUBLE)360
  1623. 1863 y(FROM)f(PART)360 1923 y(WHERE)g(PRICE)g(*)h(2)g(<)g(50;)270
  1624. 2027 y Ft(and)12 b(we)h(get:)928 2132 y Fr(PNAME)59 b(|)g(DOUBLE)898
  1625. 2191 y(--------+---------)928 2251 y(Screw)g(|)119 b(20)928
  1626. 2311 y(Nut)g(|)g(16)928 2371 y(Bolt)89 b(|)119 b(30)270
  1627. 2475 y Ft(Note)14 b(that)f(the)h(word)e(DOUBLE)j(after)e(the)g(ke)o
  1628. (yword)g(AS)g(is)h(the)g(ne)o(w)f(title)g(of)g(the)h(second)g(column.)
  1629. 270 2534 y(This)i(technique)f(can)h(be)g(used)g(for)e(e)o(v)o(ery)h
  1630. (element)h(of)f(the)g Fp(selectlist)h Ft(to)g(assign)g(a)f(ne)o(w)h
  1631. (title)f(to)g(the)270 2594 y(resulting)i(column.)32 b(This)19
  1632. b(ne)o(w)f(title)f(is)i(often)e(referred)g(to)g(as)i(alias.)33
  1633. b(The)18 b(alias)h(cannot)f(be)g(used)270 2654 y(throughout)11
  1634. b(the)h(rest)h(of)f(the)g(query)m(.)270 2794 y Fn(J)o(oins)270
  1635. 2890 y(Example)h(1.6)25 b Ft(The)13 b(follo)o(wing)e(e)o(xample)h(sho)o
  1636. (ws)h(ho)o(w)f Fp(joins)g Ft(are)g(realized)h(in)f(SQL:)270
  1637. 3010 y(T)l(o)23 b(join)g(the)g(three)g(tables)g(SUPPLIER,)g(P)-5
  1638. b(AR)m(T)24 b(and)f(SELLS)h(o)o(v)o(er)f(their)f(common)h(attrib)o
  1639. (utes)270 3070 y(we)13 b(formulate)e(the)h(follo)o(wing)f(statement:)
  1640. 360 3175 y Fr(SELECT)29 b(S.SNAME,)g(P.PNAME)360 3235
  1641. y(FROM)g(SUPPLIER)g(S,)h(PART)f(P,)h(SELLS)f(SE)360 3294
  1642. y(WHERE)g(S.SNO)g(=)h(SE.SNO)f(AND)539 3354 y(P.PNO)g(=)h(SE.PNO;)p
  1643. eop
  1644. %%Page: 17 17
  1645. 17 16 bop 198 60 a Fm(1.3.)29 b(THE)13 b(SQL)f(LANGU)n(A)n(GE)1160
  1646. b Ft(17)198 234 y(and)12 b(get)h(the)f(follo)o(wing)f(table)h(as)h(a)g
  1647. (result:)885 330 y Fr(SNAME)30 b(|)g(PNAME)856 390 y(-------+-------)
  1648. 885 450 y(Smith)g(|)g(Screw)885 510 y(Smith)g(|)g(Nut)885
  1649. 570 y(Jones)g(|)g(Cam)885 629 y(Adams)g(|)g(Screw)885
  1650. 689 y(Adams)g(|)g(Bolt)885 749 y(Blake)g(|)g(Nut)885
  1651. 809 y(Blake)g(|)g(Bolt)885 868 y(Blake)g(|)g(Cam)198
  1652. 965 y Ft(In)11 b(the)h(FR)n(OM)g(clause)g(we)g(introduced)f(an)h(alias)
  1653. g(name)g(for)f(e)o(v)o(ery)g(relation)g(because)i(there)e(are)h(com-)
  1654. 198 1025 y(mon)j(named)g(attrib)o(utes)f((SNO)g(and)h(PNO))g(among)f
  1655. (the)h(relations.)24 b(No)o(w)14 b(we)h(can)h(distinguish)e(be-)198
  1656. 1084 y(tween)g(the)h(common)f(named)g(attrib)o(utes)g(by)g(simply)g
  1657. (pre02xing)g(the)g(attrib)o(ute)g(name)g(with)g(the)h(alias)198
  1658. 1144 y(name)f(follo)o(wed)e(by)i(a)g(dot.)20 b(The)14
  1659. b(join)g(is)g(calculated)g(in)f(the)h(same)g(way)g(as)g(sho)o(wn)g(in)f
  1660. (e)o(xample)h(1.1.)198 1204 y(First)d(the)g(Cartesian)h(product)e
  1661. Fk(S)s(U)5 b(P)i(P)g(LI)t(E)s(R)g Fo(02)g Fk(P)g(ART)14
  1662. b Fo(02)7 b Fk(S)s(E)s(LLS)12 b Ft(is)g(deri)o(v)o(ed.)j(No)o(w)c
  1663. (only)g(those)198 1264 y(tuples)i(satisfying)h(the)f(conditions)g(gi)o
  1664. (v)o(en)g(in)g(the)h(WHERE)g(clause)g(are)f(selected)h((i.e.)g(the)g
  1665. (common)198 1323 y(named)g(attrib)o(utes)f(ha)o(v)o(e)h(to)g(be)g
  1666. (equal).)20 b(Finally)13 b(we)h(project)f(out)g(all)h(columns)g(b)o
  1667. (ut)f(S.SN)n(AME)i(and)198 1383 y(P)-6 b(.PN)n(AME.)198
  1668. 1515 y Fn(Aggr)o(egate)12 b(Operators)198 1608 y Ft(SQL)k(pro)o(vides)f
  1669. (aggre)o(gate)g(operators)g((e.g.)25 b(A)-7 b(V)o(G,)16
  1670. b(COUNT)l(,)h(SUM,)f(MIN,)g(MAX))f(that)g(take)g(the)198
  1671. 1668 y(name)d(of)f(an)h(attrib)o(ute)f(as)i(an)f(ar)o(gument.)j(The)d
  1672. (v)o(alue)g(of)f(the)h(aggre)o(gate)g(operator)f(is)h(calculated)g(o)o
  1673. (v)o(er)198 1728 y(all)i(v)o(alues)g(of)g(the)g(speci02ed)g(attrib)o
  1674. (ute)f((column))g(of)g(the)h(whole)g(table.)21 b(If)13
  1675. b(groups)h(are)g(speci02ed)g(in)198 1788 y(the)e(query)g(the)h
  1676. (calculation)f(is)g(done)h(only)f(o)o(v)o(er)g(the)g(v)o(alues)h(of)f
  1677. (a)g(group)g((see)h(ne)o(xt)f(section).)198 1905 y
  1678. Fn(Example)h(1.7)25 b Ft(If)15 b(we)h(want)f(to)g(kno)o(w)h(the)f(a)o
  1679. (v)o(erage)h(cost)h(of)e(all)g(parts)h(in)g(table)f(P)-5
  1680. b(AR)m(T)17 b(we)f(use)g(the)198 1965 y(follo)o(wing)11
  1681. b(query:)288 2061 y Fr(SELECT)29 b(AVG(PRICE))g(AS)g(AVG_PRICE)288
  1682. 2121 y(FROM)g(PART;)198 2217 y Ft(The)13 b(result)f(is:)945
  1683. 2313 y Fr(AVG_PRICE)915 2373 y(-----------)1005 2433
  1684. y(14.5)198 2529 y Ft(If)g(we)g(want)g(to)g(kno)o(w)g(ho)o(w)g(man)o(y)g
  1685. (parts)h(are)f(stored)g(in)g(table)h(P)-5 b(AR)m(T)13
  1686. b(we)f(use)h(the)g(statement:)288 2626 y Fr(SELECT)29
  1687. b(COUNT(PNO))288 2685 y(FROM)g(PART;)198 2782 y Ft(and)12
  1688. b(get:)1005 2878 y Fr(COUNT)975 2938 y(-------)1065 2998
  1689. y(4)198 3130 y Fn(Aggr)o(egation)f(by)h(Gr)o(oups)198
  1690. 3223 y Ft(SQL)18 b(allo)o(ws)f(to)h(partition)f(the)g(tuples)h(of)f(a)h
  1691. (table)g(into)f(groups.)31 b(Then)19 b(the)e(aggre)o(gate)h(operators)
  1692. 198 3283 y(described)12 b(abo)o(v)o(e)i(can)e(be)h(applied)f(to)g(the)h
  1693. (groups)f((i.e.)k(the)d(v)o(alue)f(of)g(the)h(aggre)o(gate)f(operator)
  1694. f(is)i(no)198 3342 y(longer)f(calculated)g(o)o(v)o(er)h(all)f(the)h(v)o
  1695. (alues)f(of)g(the)g(speci02ed)h(column)f(b)o(ut)g(o)o(v)o(er)h(all)f
  1696. (v)o(alues)h(of)f(a)g(group.)198 3402 y(Thus)h(the)f(aggre)o(gate)g
  1697. (operator)g(is)h(e)o(v)o(aluated)e(indi)o(vidually)g(for)h(e)o(v)o(ery)
  1698. g(group.))p eop
  1699. %%Page: 18 18
  1700. 18 17 bop 270 60 a Ft(18)1351 b Fm(CHAPTER)14 b(1.)28
  1701. b(SQL)270 294 y Ft(The)21 b(partitioning)e(of)h(the)g(tuples)h(into)f
  1702. (groups)g(is)h(done)f(by)g(using)h(the)f(ke)o(ywords)g(GR)n(OUP)12
  1703. b(BY)270 354 y(follo)o(wed)g(by)h(a)g(list)g(of)g(attrib)o(utes)f(that)
  1704. h(de02ne)g(the)g(groups.)18 b(If)12 b(we)h(ha)o(v)o(e)h
  1705. Fr(GROUP)29 b(BY)h Fk(A)1875 361 y Fg(1)1897 354 y Fk(;)8
  1706. b(:)g(:)g(:)h(;)f(A)2045 361 y Ff(k)270 413 y Ft(we)k(partition)f(the)h
  1707. (relation)f(into)h(groups,)g(such)g(that)g(two)f(tuples)i(are)e(in)h
  1708. (the)g(same)h(group)e(if)g(and)h(only)270 473 y(if)g(the)o(y)g(agree)h
  1709. (on)f(all)g(the)h(attrib)o(utes)e Fk(A)962 480 y Fg(1)985
  1710. 473 y Fk(;)d(:)g(:)g(:)h(;)f(A)1133 480 y Ff(k)1158 473
  1711. y Ft(.)270 600 y Fn(Example)13 b(1.8)25 b Ft(If)11 b(we)h(want)g(to)g
  1712. (kno)o(w)g(ho)o(w)f(man)o(y)h(parts)g(are)g(sold)h(by)f(e)o(v)o(ery)f
  1713. (supplier)h(we)g(formulate)270 660 y(the)g(query:)360
  1714. 764 y Fr(SELECT)29 b(S.SNO,)g(S.SNAME,)g(COUNT(SE.PNO))360
  1715. 824 y(FROM)g(SUPPLIER)g(S,)h(SELLS)f(SE)360 883 y(WHERE)g(S.SNO)g(=)h
  1716. (SE.SNO)360 943 y(GROUP)f(BY)h(S.SNO,)f(S.SNAME;)270
  1717. 1046 y Ft(and)12 b(get:)898 1151 y Fr(SNO)29 b(|)h(SNAME)f(|)h(COUNT)
  1718. 868 1210 y(-----+-------+-------)928 1270 y(1)59 b(|)30
  1719. b(Smith)f(|)90 b(2)928 1330 y(2)59 b(|)30 b(Jones)f(|)90
  1720. b(1)928 1390 y(3)59 b(|)30 b(Adams)f(|)90 b(2)928 1450
  1721. y(4)59 b(|)30 b(Blake)f(|)90 b(3)270 1553 y Ft(No)o(w)12
  1722. b(let')m(s)h(ha)o(v)o(e)f(a)h(look)f(of)g(what)g(is)h(happening)f
  1723. (here:)270 1612 y(First)g(the)g(join)g(of)g(the)g(tables)h(SUPPLIER)f
  1724. (and)h(SELLS)g(is)f(deri)o(v)o(ed:)808 1717 y Fr(S.SNO)29
  1725. b(|)h(S.SNAME)f(|)h(SE.PNO)778 1777 y(-------+---------+--------)868
  1726. 1836 y(1)89 b(|)60 b(Smith)f(|)90 b(1)868 1896 y(1)f(|)60
  1727. b(Smith)f(|)90 b(2)868 1956 y(2)f(|)60 b(Jones)f(|)90
  1728. b(4)868 2016 y(3)f(|)60 b(Adams)f(|)90 b(1)868 2075 y(3)f(|)60
  1729. b(Adams)f(|)90 b(3)868 2135 y(4)f(|)60 b(Blake)f(|)90
  1730. b(2)868 2195 y(4)f(|)60 b(Blake)f(|)90 b(3)868 2255 y(4)f(|)60
  1731. b(Blake)f(|)90 b(4)270 2358 y Ft(Ne)o(xt)16 b(we)g(partition)f(the)h
  1732. (tuples)g(into)f(groups)h(by)g(putting)f(all)h(tuples)g(together)f
  1733. (that)h(agree)g(on)f(both)270 2418 y(attrib)o(utes)d(S.SNO)g(and)g
  1734. (S.SN)n(AME:)808 2522 y Fr(S.SNO)29 b(|)h(S.SNAME)f(|)h(SE.PNO)778
  1735. 2582 y(-------+---------+--------)868 2642 y(1)89 b(|)60
  1736. b(Smith)f(|)90 b(1)1286 2701 y(|)g(2)778 2761 y
  1737. (--------------------------)868 2821 y(2)f(|)60 b(Jones)f(|)90
  1738. b(4)778 2881 y(--------------------------)868 2940 y(3)f(|)60
  1739. b(Adams)f(|)90 b(1)1286 3000 y(|)g(3)778 3060 y
  1740. (--------------------------)868 3120 y(4)f(|)60 b(Blake)f(|)90
  1741. b(2)1286 3180 y(|)g(3)1286 3239 y(|)g(4)270 3342 y Ft(In)13
  1742. b(our)f(e)o(xample)i(we)f(got)g(four)f(groups)h(and)g(no)o(w)g(we)g
  1743. (can)g(apply)g(the)g(aggre)o(gate)g(operator)f(COUNT)270
  1744. 3402 y(to)g(e)o(v)o(ery)g(group)g(leading)g(to)g(the)h(total)f(result)g
  1745. (of)g(the)g(query)g(gi)o(v)o(en)g(abo)o(v)o(e.)p eop
  1746. %%Page: 19 19
  1747. 19 18 bop 198 60 a Fm(1.3.)29 b(THE)13 b(SQL)f(LANGU)n(A)n(GE)1160
  1748. b Ft(19)198 234 y(Note)11 b(that)f(for)g(the)h(result)g(of)f(a)h(query)
  1749. f(using)h(GR)n(OUP)g(BY)g(and)g(aggre)o(gate)f(operators)g(to)h(make)f
  1750. (sense)198 294 y(the)16 b(attrib)o(utes)f(grouped)h(by)f(must)h(also)h
  1751. (appear)e(in)h(the)g Fp(selectlist)p Ft(.)27 b(All)16
  1752. b(further)e(attrib)o(utes)i(not)f(ap-)198 354 y(pearing)d(in)g(the)g
  1753. (GR)n(OUP)g(BY)h(clause)g(can)f(only)g(be)h(selected)f(by)h(using)f(an)
  1754. g(aggre)o(gate)g(function.)j(On)198 413 y(the)f(other)f(hand)g(you)g
  1755. (can)h(not)f(use)h(aggre)o(gate)g(functions)f(on)g(attrib)o(utes)g
  1756. (appearing)g(in)h(the)f(GR)n(OUP)198 473 y(BY)g(clause.)198
  1757. 606 y Fn(Ha)o(ving)198 699 y Ft(The)18 b(HA)-7 b(VING)17
  1758. b(clause)i(works)e(much)g(like)g(the)g(WHERE)i(clause)f(and)g(is)g
  1759. (used)g(to)f(consider)g(only)198 759 y(those)h(groups)g(satisfying)f
  1760. (the)h(quali02cation)f(gi)o(v)o(en)h(in)g(the)f(HA)-7
  1761. b(VING)18 b(clause.)33 b(The)18 b(e)o(xpressions)198
  1762. 818 y(allo)o(wed)13 b(in)h(the)g(HA)-7 b(VING)13 b(clause)i(must)e(in)n
  1763. (v)o(olv)o(e)h(aggre)o(gate)f(functions.)20 b(Ev)o(ery)14
  1764. b(e)o(xpression)g(using)198 878 y(only)h(plain)h(attrib)o(utes)f
  1765. (belongs)h(to)g(the)g(WHERE)h(clause.)27 b(On)15 b(the)h(other)f(hand)h
  1766. (e)o(v)o(ery)g(e)o(xpression)198 938 y(in)n(v)o(olving)11
  1767. b(an)i(aggre)o(gate)f(function)f(must)i(be)f(put)g(to)h(the)f(HA)-7
  1768. b(VING)12 b(clause.)198 1056 y Fn(Example)h(1.9)25 b
  1769. Ft(If)11 b(we)h(want)f(only)h(those)g(suppliers)g(selling)g(more)f
  1770. (than)h(one)g(part)f(we)h(use)h(the)f(query:)288 1155
  1771. y Fr(SELECT)29 b(S.SNO,)g(S.SNAME,)g(COUNT(SE.PNO))288
  1772. 1214 y(FROM)g(SUPPLIER)g(S,)h(SELLS)f(SE)288 1274 y(WHERE)g(S.SNO)g(=)h
  1773. (SE.SNO)288 1334 y(GROUP)f(BY)h(S.SNO,)f(S.SNAME)288
  1774. 1394 y(HAVING)g(COUNT(SE.PNO))f(>)i(1;)198 1492 y Ft(and)12
  1775. b(get:)826 1590 y Fr(SNO)29 b(|)h(SNAME)f(|)h(COUNT)796
  1776. 1650 y(-----+-------+-------)856 1709 y(1)59 b(|)30 b(Smith)f(|)90
  1777. b(2)856 1769 y(3)59 b(|)30 b(Adams)f(|)90 b(2)856 1829
  1778. y(4)59 b(|)30 b(Blake)f(|)90 b(3)198 1961 y Fn(Subqueries)198
  1779. 2055 y Ft(In)11 b(the)g(WHERE)i(and)e(HA)-7 b(VING)12
  1780. b(clauses)g(the)f(use)h(of)f(subqueries)h((subselects))f(is)h(allo)o
  1781. (wed)f(in)g(e)o(v)o(ery)198 2114 y(place)k(where)g(a)g(v)o(alue)g(is)g
  1782. (e)o(xpected.)24 b(In)14 b(this)h(case)h(the)f(v)o(alue)g(must)g(be)g
  1783. (deri)o(v)o(ed)f(by)h(e)o(v)o(aluating)f(the)198 2174
  1784. y(subquery)e(02rst.)j(The)e(usage)g(of)f(subqueries)h(e)o(xtends)g
  1785. (the)f(e)o(xpressi)o(v)o(e)h(po)o(wer)f(of)g(SQL.)198
  1786. 2293 y Fn(Example)h(1.10)25 b Ft(If)17 b(we)h(want)g(to)f(kno)o(w)h
  1787. (all)g(parts)g(ha)o(ving)g(a)g(greater)f(price)h(than)g(the)g(part)f
  1788. (named)198 2352 y('Scre)o(w')11 b(we)h(use)h(the)g(query:)288
  1789. 2450 y Fr(SELECT)29 b(*)288 2510 y(FROM)g(PART)288 2570
  1790. y(WHERE)g(PRICE)g(>)h((SELECT)f(PRICE)h(FROM)f(PART)736
  1791. 2630 y(WHERE)g(PNAME='Screw');)198 2728 y Ft(The)13
  1792. b(result)f(is:)766 2826 y Fr(PNO)29 b(|)60 b(PNAME)f(|)h(PRICE)736
  1793. 2886 y(-----+---------+--------)796 2945 y(3)f(|)h(Bolt)89
  1794. b(|)h(15)796 3005 y(4)59 b(|)h(Cam)119 b(|)90 b(25)198
  1795. 3103 y Ft(When)15 b(we)g(look)g(at)g(the)g(abo)o(v)o(e)h(query)e(we)h
  1796. (can)h(see)f(the)g(ke)o(yword)f(SELECT)j(two)d(times.)24
  1797. b(The)15 b(02rst)198 3163 y(one)h(at)g(the)f(be)o(ginning)h(of)f(the)
  1798. h(query)f(-)h(we)g(will)f(refer)g(to)h(it)f(as)i(outer)e(SELECT)i(-)f
  1799. (and)g(the)f(one)h(in)198 3223 y(the)h(WHERE)h(clause)g(which)f(be)o
  1800. (gins)h(a)f(nested)h(query)e(-)h(we)g(will)g(refer)f(to)h(it)g(as)h
  1801. (inner)f(SELECT)l(.)198 3283 y(F)o(or)d(e)o(v)o(ery)g(tuple)g(of)g(the)
  1802. g(outer)g(SELECT)i(the)e(inner)g(SELECT)i(has)f(to)f(be)h(e)o(v)o
  1803. (aluated.)21 b(After)13 b(e)o(v)o(ery)198 3342 y(e)o(v)o(aluation)f(we)
  1804. i(kno)o(w)f(the)g(price)g(of)g(the)g(tuple)g(named)h('Scre)o(w')d(and)j
  1805. (we)f(can)h(check)f(if)g(the)h(price)f(of)198 3402 y(the)f(actual)h
  1806. (tuple)f(is)g(greater)m(.)p eop
  1807. %%Page: 20 20
  1808. 20 19 bop 270 60 a Ft(20)1351 b Fm(CHAPTER)14 b(1.)28
  1809. b(SQL)270 294 y Ft(If)19 b(we)i(want)f(to)g(kno)o(w)f(all)i(suppliers)f
  1810. (that)g(do)g(not)g(sell)g(an)o(y)h(part)f((e.g.)39 b(to)20
  1811. b(be)h(able)f(to)g(remo)o(v)o(e)270 354 y(these)13 b(suppliers)f(from)f
  1812. (the)i(database))f(we)h(use:)360 471 y Fr(SELECT)29
  1813. b(*)360 531 y(FROM)g(SUPPLIER)g(S)360 590 y(WHERE)g(NOT)h(EXISTS)659
  1814. 650 y((SELECT)f(*)g(FROM)h(SELLS)f(SE)688 710 y(WHERE)h(SE.SNO)f(=)h
  1815. (S.SNO);)270 823 y Ft(In)19 b(our)h(e)o(xample)g(the)g(result)f(will)h
  1816. (be)g(empty)f(because)i(e)o(v)o(ery)e(supplier)h(sells)g(at)g(least)g
  1817. (one)g(part.)270 883 y(Note)15 b(that)g(we)g(use)h(S.SNO)e(from)g(the)h
  1818. (outer)g(SELECT)i(within)d(the)h(WHERE)h(clause)g(of)f(the)g(inner)270
  1819. 942 y(SELECT)l(.)d(As)f(described)f(abo)o(v)o(e)g(the)g(subquery)g(is)g
  1820. (e)o(v)o(aluated)f(for)g(e)o(v)o(ery)h(tuple)g(from)e(the)i(outer)g
  1821. (query)270 1002 y(i.e.)16 b(the)d(v)o(alue)f(for)f(S.SNO)i(is)f(always)
  1822. g(taken)g(from)f(the)h(actual)h(tuple)f(of)g(the)g(outer)g(SELECT)l(.)
  1823. 270 1159 y Fn(Union,)g(Intersect,)h(Except)270 1261 y
  1824. Ft(These)19 b(operations)e(calculate)h(the)g(union,)i(intersect)d(and)h
  1825. (set)h(theoretic)e(dif)o(ference)g(of)g(the)h(tuples)270
  1826. 1320 y(deri)o(v)o(ed)12 b(by)g(two)g(subqueries:)270
  1827. 1466 y Fn(Example)h(1.11)25 b Ft(The)13 b(follo)o(wing)e(query)g(is)i
  1828. (an)g(e)o(xample)f(for)g(UNION:)360 1583 y Fr(SELECT)29
  1829. b(S.SNO,)g(S.SNAME,)g(S.CITY)360 1643 y(FROM)g(SUPPLIER)g(S)360
  1830. 1703 y(WHERE)g(S.SNAME)g(=)h('Jones')360 1763 y(UNION)360
  1831. 1822 y(SELECT)f(S.SNO,)g(S.SNAME,)g(S.CITY)360 1882 y(FROM)g(SUPPLIER)g
  1832. (S)360 1942 y(WHERE)g(S.SNAME)g(=)h('Adams';)270 2055
  1833. y Ft(gi)o(v)o(es)13 b(the)f(result:)898 2172 y Fr(SNO)29
  1834. b(|)h(SNAME)f(|)60 b(CITY)868 2232 y(-----+-------+--------)928
  1835. 2292 y(2)f(|)30 b(Jones)f(|)h(Paris)928 2351 y(3)59 b(|)30
  1836. b(Adams)f(|)h(Vienna)270 2464 y Ft(Here)12 b(an)h(e)o(xample)f(for)g
  1837. (INTERSECT)n(:)360 2581 y Fr(SELECT)29 b(S.SNO,)g(S.SNAME,)g(S.CITY)360
  1838. 2641 y(FROM)g(SUPPLIER)g(S)360 2701 y(WHERE)g(S.SNO)g(>)h(1)360
  1839. 2761 y(INTERSECT)360 2820 y(SELECT)f(S.SNO,)g(S.SNAME,)g(S.CITY)360
  1840. 2880 y(FROM)g(SUPPLIER)g(S)360 2940 y(WHERE)g(S.SNO)g(>)h(2;)270
  1841. 3053 y Ft(gi)o(v)o(es)13 b(the)f(result:)898 3170 y Fr(SNO)29
  1842. b(|)h(SNAME)f(|)60 b(CITY)868 3230 y(-----+-------+--------)928
  1843. 3289 y(2)f(|)30 b(Jones)f(|)h(Paris)270 3402 y Ft(The)13
  1844. b(only)f(tuple)g(returned)f(by)i(both)f(parts)g(of)g(the)g(query)g(is)h
  1845. (the)f(one)h(ha)o(ving)f Fk(S)s(N)5 b(O)15 b Fl(=)e(2)p
  1846. Ft(.)p eop
  1847. %%Page: 21 21
  1848. 21 20 bop 198 60 a Fm(1.3.)29 b(THE)13 b(SQL)f(LANGU)n(A)n(GE)1160
  1849. b Ft(21)198 234 y(Finally)12 b(an)g(e)o(xample)h(for)e(EXCEPT)n(:)288
  1850. 342 y Fr(SELECT)29 b(S.SNO,)g(S.SNAME,)g(S.CITY)288 402
  1851. y(FROM)g(SUPPLIER)g(S)288 461 y(WHERE)g(S.SNO)g(>)h(1)288
  1852. 521 y(EXCEPT)288 581 y(SELECT)f(S.SNO,)g(S.SNAME,)g(S.CITY)288
  1853. 641 y(FROM)g(SUPPLIER)g(S)288 700 y(WHERE)g(S.SNO)g(>)h(3;)198
  1854. 806 y Ft(gi)o(v)o(es)13 b(the)f(result:)826 914 y Fr(SNO)29
  1855. b(|)h(SNAME)f(|)60 b(CITY)796 974 y(-----+-------+--------)856
  1856. 1033 y(2)f(|)30 b(Jones)f(|)h(Paris)856 1093 y(3)59 b(|)30
  1857. b(Adams)f(|)h(Vienna)198 1247 y Fh(1.3.2)59 b(Data)15
  1858. b(De02nition)198 1344 y Ft(There)e(is)f(a)h(set)g(of)f(commands)g
  1859. (used)h(for)e(data)i(de02nition)e(included)h(in)g(the)h(SQL)f
  1860. (language.)198 1488 y Fn(Cr)o(eate)g(T)-5 b(able)198
  1861. 1585 y Ft(The)12 b(most)g(fundamental)e(command)h(for)g(data)h
  1862. (de02nition)e(is)i(the)g(one)f(that)g(creates)h(a)g(ne)o(w)f
  1863. (relation)g((a)198 1645 y(ne)o(w)h(table).)k(The)c(syntax)h(of)f(the)
  1864. g(CREA)-6 b(TE)15 b(T)-5 b(ABLE)14 b(command)e(is:)288
  1865. 1752 y Fr(CREATE)29 b(TABLE)g(<table_name>)676 1812 y
  1866. ((<name_of_attr_1>)f(<type_of_attr_1>)706 1872 y([,)i
  1867. (<name_of_attr_2>)e(<type_of_attr_2>)706 1932 y([,)i(...]]);)198
  1868. 2063 y Fn(Example)13 b(1.12)25 b Ft(T)l(o)13 b(create)g(the)g(tables)h
  1869. (de02ned)e(in)h(02gure)g(1.1)g(the)g(follo)o(wing)f(SQL)h
  1870. (statements)g(are)198 2123 y(used:)288 2231 y Fr(CREATE)29
  1871. b(TABLE)g(SUPPLIER)676 2290 y((SNO)89 b(INTEGER,)706
  1872. 2350 y(SNAME)29 b(VARCHAR(20),)706 2410 y(CITY)59 b(VARCHAR(20));)
  1873. 288 2530 y(CREATE)29 b(TABLE)g(PART)676 2589 y((PNO)89
  1874. b(INTEGER,)706 2649 y(PNAME)29 b(VARCHAR(20),)706 2709
  1875. y(PRICE)g(DECIMAL(4)g(,)h(2));)288 2828 y(CREATE)f(TABLE)g(SELLS)676
  1876. 2888 y((SNO)h(INTEGER,)706 2948 y(PNO)g(INTEGER);)198
  1877. 3092 y Fn(Data)12 b(T)l(ypes)h(in)f(SQL)198 3189 y Ft(The)h(follo)o
  1878. (wing)e(is)i(a)f(list)g(of)g(some)h(data)f(types)h(that)f(are)h
  1879. (supported)e(by)i(SQL:)273 3295 y Fo(17)25 b Ft(INTEGER:)13
  1880. b(signed)f(fullword)e(binary)i(inte)o(ger)g((31)g(bits)g(precision).)
  1881. 273 3402 y Fo(17)25 b Ft(SMALLINT)n(:)12 b(signed)h(halfword)d
  1882. (binary)i(inte)o(ger)g((15)g(bits)g(precision).)p eop
  1883. %%Page: 22 22
  1884. 22 21 bop 270 60 a Ft(22)1354 b Fm(CHAPTER)14 b(1.)25
  1885. b(SQL)345 234 y Fo(17)g Ft(DECIMAL)19 b(()p Fk(p)p
  1886. Fl([)p Fk(;)8 b(q)r Fl(])p Ft():)27 b(signed)19 b(packed)f(decimal)h
  1887. (number)f(of)g Fk(p)h Ft(digits)f(precision)h(with)f(as-)395
  1888. 294 y(sumed)13 b Fk(q)j Ft(of)e(them)f(right)g(to)h(the)g(decimal)f
  1889. (point.)20 b Fl((15)d Fo(25)f Fk(p)g Fo(25)h Fk(q)h
  1890. Fo(25)e Fl(0))p Ft(.)21 b(If)13 b Fk(q)j Ft(is)e(omitted)f(it)h(is)
  1891. 395 354 y(assumed)f(to)f(be)g(0.)345 448 y Fo(17)25
  1892. b Ft(FLO)n(A)-6 b(T)n(:)13 b(signed)f(double)o(word)f(03oating)g
  1893. (point)h(number)m(.)345 543 y Fo(17)25 b Ft(CHAR()p
  1894. Fk(n)p Ft():)14 b(02x)o(ed)f(length)f(character)g(string)f(of)h
  1895. (length)g Fk(n)p Ft(.)345 638 y Fo(17)25 b Ft(V)-7
  1896. b(ARCHAR()p Fk(n)p Ft():)15 b(v)o(arying)c(length)h(character)g
  1897. (string)g(of)g(maximum)f(length)h Fk(n)p Ft(.)270 768
  1898. y Fn(Cr)o(eate)g(Index)270 862 y Ft(Indices)i(are)g(used)h(to)f(speed)h
  1899. (up)f(access)i(to)e(a)g(relation.)21 b(If)14 b(a)g(relation)g
  1900. Fk(R)g Ft(has)h(an)f(inde)o(x)h(on)f(attrib)o(ute)270
  1901. 921 y Fk(A)j Ft(then)f(we)h(can)f(retrie)o(v)o(e)g(all)g(tuples)h
  1902. Fk(t)g Ft(ha)o(ving)f Fk(t)p Fl(()p Fk(A)p Fl())22
  1903. b(=)f Fk(a)c Ft(in)f(time)h(roughly)e(proportional)g(to)h(the)270
  1904. 981 y(number)c(of)g(such)g(tuples)h Fk(t)f Ft(rather)g(than)g(in)g
  1905. (time)g(proportional)f(to)h(the)h(size)f(of)g Fk(R)p
  1906. Ft(.)345 1041 y(T)l(o)h(create)f(an)g(inde)o(x)h(in)f(SQL)h(the)f(CREA)
  1907. -6 b(TE)14 b(INDEX)f(command)f(is)g(used.)17 b(The)c(syntax)f(is:)360
  1908. 1131 y Fr(CREATE)29 b(INDEX)g(<index_name>)360 1190 y(ON)g
  1909. (<table_name>)g(()h(<name_of_attribute>)d();)270 1303
  1910. y Fn(Example)13 b(1.13)25 b Ft(T)l(o)12 b(create)g(an)f(inde)o(x)h
  1911. (named)g(I)f(on)h(attrib)o(ute)f(SN)n(AME)h(of)f(relation)g(SUPPLIER)h
  1912. (we)270 1362 y(use)h(the)f(follo)o(wing)f(statement:)360
  1913. 1452 y Fr(CREATE)29 b(INDEX)g(I)360 1512 y(ON)g(SUPPLIER)g((SNAME);)
  1914. 270 1602 y Ft(The)11 b(created)f(inde)o(x)h(is)g(maintained)f
  1915. (automatically)m(,)g(i.e.)i(whene)o(v)o(er)e(a)g(ne)o(w)h(tuple)f(is)h
  1916. (inserted)f(into)g(the)270 1661 y(relation)k(SUPPLIER)g(the)h(inde)o(x)
  1917. f(I)h(is)g(adapted.)22 b(Note)15 b(that)f(the)h(only)f(changes)h(a)g
  1918. (user)g(can)f(percept)270 1721 y(when)e(an)h(inde)o(x)f(is)h(present)f
  1919. (are)g(an)h(increased)g(speed.)270 1852 y Fn(Cr)o(eate)f(V)n(iew)270
  1920. 1945 y Ft(A)i(vie)o(w)f(may)h(be)g(re)o(garded)f(as)h(a)g
  1921. Fp(virtual)g(table)p Ft(,)g(i.e.)h(a)f(table)f(that)h(does)g(not)g
  1922. Fp(physically)f Ft(e)o(xist)i(in)e(the)270 2005 y(database)i(b)o(ut)f
  1923. (looks)g(to)g(the)g(user)g(as)h(if)e(it)h(did.)21 b(By)14
  1924. b(contrast,)h(when)f(we)g(talk)g(of)g(a)g Fp(base)h(table)e
  1925. Ft(there)270 2064 y(is)f(really)g(a)g(physically)f(stored)h
  1926. (counterpart)e(of)i(each)g(ro)o(w)f(of)h(the)f(table)h(some)o(where)g
  1927. (in)f(the)h(physical)270 2124 y(storage.)345 2184 y(V)m(ie)o(ws)h(do)g
  1928. (not)g(ha)o(v)o(e)h(their)f(o)o(wn,)h(physically)e(separate,)j
  1929. (distinguishable)e(stored)g(data.)19 b(Instead,)270 2244
  1930. y(the)d(system)g(stores)g(the)f Fp(de02nition)g Ft(of)h(the)f(vie)o
  1931. (w)h((i.e.)g(the)g(rules)f(about)h(ho)o(w)f(to)g(access)i(physically)
  1932. 270 2304 y(stored)c Fp(base)g(tables)h Ft(in)e(order)h(to)g
  1933. (materialize)f(the)h(vie)o(w))g(some)o(where)f(in)h(the)g
  1934. Fp(system)h(catalogs)f Ft((see)270 2363 y(section)19
  1935. b(1.3.4)h Fp(System)g(Catalogs)p Ft().)36 b(F)o(or)18
  1936. b(a)i(discussion)g(on)f(dif)o(ferent)e(techniques)j(to)f(implement)270
  1937. 2423 y(vie)o(ws)12 b(refer)g(to)g(section)h(3.4.1)g Fp(T)-5
  1938. b(ec)o(hniques)13 b(T)-5 b(o)12 b(Implement)g(V)l(ie)o(ws)p
  1939. Ft(.)345 2483 y(In)g(SQL)g(the)h(CREA)-6 b(TE)14 b(VIEW)f(command)f(is)
  1940. g(used)h(to)f(de02ne)g(a)h(vie)o(w)m(.)i(The)e(syntax)g(is:)360
  1941. 2573 y Fr(CREATE)29 b(VIEW)g(<view_name>)360 2632 y(AS)g(<select_stmt>)
  1942. 270 2722 y Ft(where)10 b Fk(<)p Fr(select)p 624 2722
  1943. 15 2 v 17 w(stmt)p Fk(>)40 b Ft(is)11 b(a)g(v)o(alid)g(select)g
  1944. (statement)f(as)i(de02ned)e(in)h(section)g(1.3.1.)16
  1945. b(Note)10 b(that)270 2782 y(the)15 b Fk(<)p Fr(select)p
  1946. 568 2782 V 17 w(stmt)p Fk(>)44 b Ft(is)15 b(not)g(e)o(x)o(ecuted)g
  1947. (when)g(the)g(vie)o(w)f(is)h(created.)23 b(It)15 b(is)g(just)g(stored)f
  1948. (in)h(the)270 2842 y Fp(system)e(catalogs)f Ft(and)g(is)h(e)o(x)o
  1949. (ecuted)g(whene)o(v)o(er)f(a)h(query)f(against)g(the)g(vie)o(w)g(is)h
  1950. (made.)270 2954 y Fn(Example)g(1.14)25 b Ft(Let)16 b(the)g(follo)o
  1951. (wing)f(vie)o(w)h(de02nition)f(be)h(gi)o(v)o(en)g((we)g(use)g(the)g
  1952. (tables)h(from)e(02gure)270 3014 y(1.1)e Fp(The)f(suppliers)h(and)f
  1953. (parts)h(database)f Ft(again):)360 3103 y Fr(CREATE)29
  1954. b(VIEW)g(London_Suppliers)449 3163 y(AS)h(SELECT)f(S.SNAME,)g(P.PNAME)
  1955. 539 3223 y(FROM)g(SUPPLIER)g(S,)h(PART)g(P,)f(SELLS)h(SE)539
  1956. 3283 y(WHERE)f(S.SNO)h(=)f(SE.SNO)h(AND)718 3342 y(P.PNO)g(=)f(SE.PNO)h
  1957. (AND)718 3402 y(S.CITY)g(=)f('London';)p eop
  1958. %%Page: 23 23
  1959. 23 22 bop 198 60 a Fm(1.3.)26 b(THE)13 b(SQL)f(LANGU)n(A)n(GE)1163
  1960. b Ft(23)198 234 y(No)o(w)10 b(we)g(can)g(use)g(this)g
  1961. Fp(virtual)g(r)n(elation)f Fr(London)p 1100 234 15 2
  1962. v 18 w(Suppliers)g Ft(as)h(if)f(it)h(were)g(another)f(base)h(table:)288
  1963. 338 y Fr(SELECT)29 b(*)288 397 y(FROM)g(London_Suppliers)288
  1964. 457 y(WHERE)g(P.PNAME)g(=)h('Screw';)198 560 y Ft(will)12
  1965. b(return)f(the)i(follo)o(wing)e(table:)885 663 y Fr(SNAME)30
  1966. b(|)g(PNAME)856 723 y(-------+-------)885 783 y(Smith)g(|)g(Screw)198
  1967. 885 y Ft(T)l(o)17 b(calculate)h(this)f(result)g(the)g(database)g
  1968. (system)h(has)f(to)g(do)g(a)g Fp(hidden)g Ft(access)h(to)f(the)g(base)h
  1969. (tables)198 945 y(SUPPLIER,)e(SELLS)g(and)g(P)-5 b(AR)m(T)16
  1970. b(02rst.)25 b(It)15 b(does)h(so)g(by)f(e)o(x)o(ecuting)h(the)f(query)
  1971. g(gi)o(v)o(en)h(in)f(the)g(vie)o(w)198 1005 y(de02nition)h(against)g
  1972. (those)h(base)h(tables.)28 b(After)16 b(that)h(the)f(additional)g
  1973. (quali02cations)h((gi)o(v)o(en)f(in)g(the)198 1065
  1974. y(query)c(against)g(the)h(vie)o(w))e(can)i(be)f(applied)g(to)h(obtain)
  1975. f(the)g(resulting)g(table.)198 1202 y Fn(Dr)o(op)g(T)-5
  1976. b(able,)13 b(Dr)o(op)g(Index,)f(Dr)o(op)h(V)n(iew)198
  1977. 1298 y Ft(T)l(o)g(destroy)e(a)h(table)h((including)e(all)h(tuples)g
  1978. (stored)g(in)g(that)g(table))g(the)g(DR)n(OP)g(T)-5
  1979. b(ABLE)14 b(command)e(is)198 1357 y(used:)288 1461 y
  1980. Fr(DROP)29 b(TABLE)g(<table_name>;)198 1586 y Fn(Example)13
  1981. b(1.15)25 b Ft(T)l(o)13 b(destroy)e(the)h(SUPPLIER)h(table)f(use)h(the)
  1982. f(follo)o(wing)f(statement:)288 1690 y Fr(DROP)29 b(TABLE)g(SUPPLIER;)
  1983. 198 1792 y Ft(The)13 b(DR)n(OP)f(INDEX)h(command)f(is)g(used)h(to)f
  1984. (destroy)g(an)g(inde)o(x:)288 1896 y Fr(DROP)29 b(INDEX)g
  1985. (<index_name>;)198 1998 y Ft(Finally)12 b(to)g(destroy)f(a)i(gi)o(v)o
  1986. (en)f(vie)o(w)g(use)h(the)f(command)g(DR)n(OP)h(VIEW)n(:)288
  1987. 2102 y Fr(DROP)29 b(VIEW)h(<view_name>;)198 2250 y Fh(1.3.3)59
  1988. b(Data)15 b(Manipulation)198 2345 y Fn(Insert)e(Into)198
  1989. 2440 y Ft(Once)h(a)h(table)f(is)h(created)f((see)g(section)h(1.3.2),)
  1990. g(it)f(can)h(be)f(02lled)g(with)g(tuples)g(using)g(the)h(command)198
  1991. 2500 y(INSER)m(T)e(INT)o(O.)g(The)g(syntax)f(is:)288
  1992. 2603 y Fr(INSERT)29 b(INTO)g(<table_name>)g((<name_of_attr_1>)1065
  1993. 2663 y([,)g(<name_of_attr_2>)g([,...]]))288 2723 y(VALUES)g
  1994. ((<val_attr_1>)527 2783 y([,)g(<val_attr_2>)g([,)h(...]]);)198
  1995. 2908 y Fn(Example)13 b(1.16)25 b Ft(T)l(o)14 b(insert)g(the)h(02rst)f
  1996. (tuple)f(into)h(the)h(relation)e(SUPPLIER)h(of)g(02gure)g(1.1)g
  1997. Fp(The)g(sup-)198 2968 y(pliers)e(and)h(parts)f(database)h
  1998. Ft(we)f(use)h(the)g(follo)o(wing)d(statement:)288 3071
  1999. y Fr(INSERT)29 b(INTO)g(SUPPLIER)g((SNO,)h(SNAME,)f(CITY))288
  2000. 3131 y(VALUES)g((1,)g('Smith',)g('London');)198 3234
  2001. y Ft(T)l(o)13 b(insert)f(the)g(02rst)g(tuple)g(into)g(the)h(relation)
  2002. e(SELLS)i(we)g(use:)288 3337 y Fr(INSERT)29 b(INTO)g(SELLS)h((SNO,)f
  2003. (PNO))288 3397 y(VALUES)g((1,)g(1);)p eop
  2004. %%Page: 24 24
  2005. 24 23 bop 270 60 a Ft(24)1351 b Fm(CHAPTER)14 b(1.)28
  2006. b(SQL)270 234 y Fn(Update)270 330 y Ft(T)l(o)17 b(change)f(one)h(or)f
  2007. (more)g(attrib)o(ute)f(v)o(alues)i(of)f(tuples)g(in)h(a)f(relation)g
  2008. (the)g(UPD)n(A)-6 b(TE)18 b(command)e(is)270 389 y(used.)g(The)d
  2009. (syntax)g(is:)360 493 y Fr(UPDATE)29 b(<table_name>)360
  2010. 553 y(SET)g(<name_of_attr_1>)f(=)i(<value_1>)479 613
  2011. y([,)g(...)f([,)h(<name_of_attr_k>)e(=)i(<value_k>]])360
  2012. 672 y(WHERE)f(<condition>;)270 798 y Fn(Example)13 b(1.17)25
  2013. b Ft(T)l(o)15 b(change)g(the)f(v)o(alue)h(of)f(attrib)o(ute)g(PRICE)h
  2014. (of)f(the)g(part)h('Scre)o(w')e(in)h(the)h(relation)270
  2015. 858 y(P)-5 b(AR)m(T)13 b(we)g(use:)360 962 y Fr(UPDATE)29
  2016. b(PART)360 1022 y(SET)g(PRICE)h(=)f(15)360 1081 y(WHERE)g(PNAME)g(=)h
  2017. ('Screw';)270 1184 y Ft(The)13 b(ne)o(w)f(v)o(alue)g(of)g(attrib)o(ute)
  2018. g(PRICE)g(of)g(the)h(tuple)f(whose)g(name)h(is)f('Scre)o(w')f(is)i(no)o
  2019. (w)f(15.)270 1323 y Fn(Delete)270 1418 y Ft(T)l(o)h(delete)f(a)g(tuple)
  2020. g(from)f(a)h(particular)f(table)h(use)h(the)f(command)g(DELETE)i(FR)n
  2021. (OM.)f(The)g(syntax)f(is:)360 1522 y Fr(DELETE)29 b(FROM)g
  2022. (<table_name>)360 1582 y(WHERE)g(<condition>;)270 1708
  2023. y Fn(Example)13 b(1.18)25 b Ft(T)l(o)13 b(delete)g(the)g(supplier)f
  2024. (called)h('Smith')e(of)i(the)f(table)h(SUPPLIER)g(the)g(follo)o(wing)
  2025. 270 1767 y(statement)f(is)h(used:)360 1871 y Fr(DELETE)29
  2026. b(FROM)g(SUPPLIER)360 1931 y(WHERE)g(SNAME)g(=)h('Smith';)270
  2027. 2079 y Fh(1.3.4)59 b(System)15 b(Catalogs)270 2175 y
  2028. Ft(In)10 b(e)o(v)o(ery)g(SQL)g(database)h(system)f Fp(system)h
  2029. (catalogs)f Ft(are)g(used)g(to)g(keep)g(track)g(of)g(which)g(tables,)h
  2030. (vie)o(ws)270 2235 y(inde)o(x)o(es)16 b(etc.)24 b(are)15
  2031. b(de02ned)g(in)g(the)g(database.)24 b(These)17 b(system)e(catalogs)h
  2032. (can)f(be)g(queried)g(as)g(if)g(the)o(y)270 2294 y(were)g(normal)g
  2033. (relations.)23 b(F)o(or)15 b(e)o(xample)h(there)e(is)i(one)f(catalog)g
  2034. (used)h(for)e(the)i(de02nition)e(of)h(vie)o(ws.)270
  2035. 2354 y(This)h(catalog)f(stores)h(the)f(query)g(from)f(the)h(vie)o(w)g
  2036. (de02nition.)23 b(Whene)o(v)o(er)16 b(a)f(query)g(against)g(a)g(vie)o
  2037. (w)270 2414 y(is)f(made,)h(the)e(system)i(02rst)e(gets)h(the)g
  2038. Fp(vie)o(w-de02nition-query)f Ft(out)h(of)f(the)h(catalog)g(and)f
  2039. (materializes)270 2474 y(the)e(vie)o(w)g(before)g(proceeding)g(with)g
  2040. (the)g(user)g(query)g((see)h(section)f(3.4.1)h Fp(T)-5
  2041. b(ec)o(hniques)12 b(T)-5 b(o)12 b(Implement)270 2533
  2042. y(V)l(ie)o(ws)k Ft(for)e(a)h(more)f(detailed)g(description).)21
  2043. b(F)o(or)14 b(more)g(information)f(about)i Fp(system)g(catalogs)f
  2044. Ft(refer)270 2593 y(to)e([D)n(A)-6 b(TE96)q(].)270 2742
  2045. y Fh(1.3.5)59 b(Embedded)15 b(SQL)270 2837 y Ft(In)h(this)h(section)g
  2046. (we)g(will)g(sketch)f(ho)o(w)h(SQL)g(can)g(be)g(embedded)f(into)h(a)g
  2047. (host)g(language)f((e.g.)i(C).)270 2897 y(There)13
  2048. b(are)f(two)g(main)g(reasons)g(why)g(we)h(want)f(to)g(use)h(SQL)f(from)
  2049. g(a)g(host)h(language:)345 3000 y Fo(17)25 b Ft(There)13
  2050. b(are)g(queries)f(that)h(cannot)g(be)g(formulated)e(using)i(pure)g(SQL)
  2051. g((i.e.)18 b(recursi)o(v)o(e)12 b(queries).)395 3059
  2052. y(T)l(o)f(be)g(able)g(to)g(perform)e(such)j(queries)f(we)g(need)g(a)g
  2053. (host)g(language)g(with)g(a)g(greater)f(e)o(xpressi)o(v)o(e)395
  2054. 3119 y(po)o(wer)h(than)h(SQL.)345 3223 y Fo(17)25 b
  2055. Ft(W)l(e)11 b(simply)f(want)g(to)h(access)h(a)f(database)h(from)d(some)
  2056. i(application)g(that)f(is)h(written)g(in)f(the)h(host)395
  2057. 3283 y(language)g((e.g.)h(a)g(ticket)e(reserv)o(ation)h(system)h(with)
  2058. f(a)h(graphical)f(user)g(interface)g(is)h(written)e(in)395
  2059. 3342 y(C)h(and)g(the)g(information)f(about)g(which)h(tickets)g(are)g
  2060. (still)g(left)g(is)g(stored)g(in)g(a)g(database)h(that)f(can)395
  2061. 3402 y(be)h(accessed)i(using)e(embedded)g(SQL).)p eop
  2062. %%Page: 25 25
  2063. 25 24 bop 198 60 a Fm(1.3.)29 b(THE)13 b(SQL)f(LANGU)n(A)n(GE)1160
  2064. b Ft(25)198 234 y(A)19 b(program)f(using)h(embedded)g(SQL)h(in)f(a)g
  2065. (host)h(language)f(consists)h(of)e(statements)i(of)f(the)g(host)198
  2066. 294 y(language)c(and)g(of)g(embedded)g(SQL)g((ESQL))g(statements.)25
  2067. b(Ev)o(ery)15 b(ESQL)h(statement)f(be)o(gins)g(with)198
  2068. 354 y(the)d(ke)o(ywords)g(EXEC)h(SQL.)g(The)g(ESQL)g(statements)g(are)f
  2069. (transformed)g(to)g(statements)h(of)f(the)g(host)198
  2070. 413 y(language)j(by)g(a)g Fp(pr)n(ecompiler)h Ft((mostly)e(calls)h(to)
  2071. g(library)f(routines)g(that)h(perform)f(the)g(v)o(arious)h(SQL)198
  2072. 473 y(commands).)273 533 y(When)i(we)g(look)f(at)h(the)g(e)o(xamples)g
  2073. (throughout)f(section)h(1.3.1)h(we)f(realize)f(that)h(the)g(result)g
  2074. (of)198 593 y(the)e(queries)g(is)g(v)o(ery)g(often)g(a)g(set)g(of)g
  2075. (tuples.)24 b(Most)15 b(host)g(languages)h(are)f(not)f(designed)i(to)e
  2076. (operate)198 653 y(on)h(sets)g(so)g(we)g(need)g(a)g(mechanism)g(to)g
  2077. (access)h(e)o(v)o(ery)e(single)h(tuple)g(of)f(the)h(set)g(of)f(tuples)h
  2078. (returned)198 712 y(by)h(a)g(SELECT)i(statement.)27 b(This)16
  2079. b(mechanism)g(can)g(be)h(pro)o(vided)e(by)h(declaring)f(a)i
  2080. Fp(cursor)p Ft(.)27 b(After)198 772 y(that)11 b(we)g(can)g(use)g(the)g
  2081. (FETCH)g(command)g(to)g(retrie)o(v)o(e)f(a)h(tuple)f(and)h(set)g(the)g
  2082. (cursor)g(to)f(the)h(ne)o(xt)g(tuple.)198 892 y(F)o(or)h(a)g(detailed)h
  2083. (discussion)g(on)f(embedded)g(SQL)h(refer)e(to)h([D)n(A)-6
  2084. b(TE96)q(],)12 b([D)n(A)-6 b(TE94)q(])12 b(or)g([ULL88].)p
  2085. eop
  2086. %%Page: 26 26
  2087. 26 25 bop 270 609 a Fj(Chapter)26 b(2)270 858 y Fq(P)n(ostgr)n(eSQL)k
  2088. (fr)n(om)g(the)g(User')-5 b(s)32 b(P)n(oint)270 1008
  2089. y(of)f(V)-5 b(iew)270 1268 y Ft(This)13 b(chapter)f(contains)g
  2090. (information)f(that)h(will)f(be)i(useful)f(for)f(people)h(that)g(only)g
  2091. (want)g(to)g(use)h(Post-)270 1327 y(greSQL.)g(It)f(gi)o(v)o(es)h(a)g
  2092. (listing)f(and)h(description)f(of)g(the)g(a)o(v)o(ailable)h(features)f
  2093. (including)g(a)h(lot)f(of)g(e)o(xam-)270 1387 y(ples.)k(The)11
  2094. b(users)h(interested)f(in)g(the)g(internals)g(of)g(PostgreSQL)f(should)
  2095. h(read)g(chapter)g(3)g Fp(P)l(ostgr)n(eSQL)270 1447 y(fr)n(om)h(the)h
  2096. (Pr)n(ogr)o(ammer')n(s)g(P)l(oint)f(of)h(V)l(ie)o(w)p
  2097. Ft(.)270 1620 y Fi(2.1)71 b(A)18 b(Short)f(History)g(of)h(P)o(ostgr)o
  2098. (eSQL)270 1732 y Ft(PostgreSQL)c(is)h(an)g(enhancement)f(of)g(the)h
  2099. (POSTGRES)f(database)i(management)e(system,)i(a)e(ne)o(xt-)270
  2100. 1792 y(generation)f(relational)g(DBMS)h(research)g(prototype)f(running)
  2101. g(on)g(almost)h(an)o(y)g(UNIX)g(based)g(oper)o(-)270
  2102. 1852 y(ating)f(system.)20 b(The)14 b(original)e(POSTGRES)i(code,)g
  2103. (from)f(which)g(PostgreSQL)g(is)h(deri)o(v)o(ed,)g(was)f(the)270
  2104. 1912 y(ef)o(fort)f(of)i(man)o(y)g(graduate)g(students,)h(under)o
  2105. (graduate)e(students,)i(and)f(staf)o(f)g(programmers)e(working)270
  2106. 1971 y(under)d(the)h(direction)f(of)h(Professor)f(Michael)h
  2107. (Stonebraker)e(at)i(the)f(Uni)o(v)o(ersity)h(of)f(California,)h(Berke-)
  2108. 270 2031 y(le)o(y)m(.)16 b(Originally)11 b(POSTGRES)i(implemented)e
  2109. (its)i(o)o(wn)f(query)g(language)g(called)g(POSTQUEL.)345
  2110. 2092 y(In)18 b(1995)g(Andre)o(w)g(Y)-6 b(u)19 b(and)f(Jolly)h(Chen)g
  2111. (adapted)f(the)h(last)f(of)o(02cial)g(release)h(of)f(POSTGRES)270
  2112. 2152 y((v)o(ersion)d(4.2))h(to)f(meet)h(their)f(o)o(wn)g
  2113. (requirements)g(and)g(made)h(some)g(major)e(changes)j(to)e(the)g(code.)
  2114. 270 2211 y(The)i(most)g(important)e(change)i(is)f(the)h(replacement)f
  2115. (of)g(POSTQUEL)h(by)f(an)h(e)o(xtended)f(subset)i(of)270
  2116. 2271 y(SQL92.)f(The)c(name)g(was)g(changed)f(to)h(Postgres95)f(and)h
  2117. (since)g(that)g(time)f(man)o(y)h(other)f(people)h(ha)o(v)o(e)270
  2118. 2331 y(contrib)o(uted)h(to)h(the)g(porting,)g(testing,)h(deb)o(ugging)f
  2119. (and)g(enhancement)g(of)g(the)g(code.)24 b(In)14 b(late)h(1996)270
  2120. 2391 y(the)d(name)h(was)f(changed)h(again)f(to)g(the)g(ne)o(w)g(of)o
  2121. (02cial)g(name)g(PostgreSQL.)270 2563 y Fi(2.2)71 b(An)18
  2122. b(Ov)o(er)o(view)f(on)h(the)g(F)n(eatur)o(es)e(of)i(P)o(ostgr)o(eSQL)
  2123. 270 2676 y Ft(As)d(mentioned)f(earlier)g(PostgreSQL)h(is)g(a)g
  2124. (relational)f(database)h(management)f(system)h((RDBMS))270
  2125. 2736 y(b)o(ut)h(in)f(contrast)h(to)f(the)h(most)g(traditional)f(RDBMSs)
  2126. h(it)g(is)g(designed)g(to)f(pro)o(vide)h(more)f(03e)o(xibility)270
  2127. 2796 y(to)j(the)f(user)m(.)33 b(One)18 b(e)o(xample)g(for)f(the)h
  2128. (impro)o(v)o(ed)f(03e)o(xibility)g(is)h(the)g(support)f(for)g
  2129. Fp(user)i(de02ned)f Ft(or)270 2855 y Fp(abstr)o(act)11
  2130. b(data)f(types)h Ft((ADTs).)k(Another)10 b(e)o(xample)h(is)f(the)h
  2131. (support)f(of)g(user)g(de02ned)h(SQL)f(functions.)270
  2132. 2915 y((W)l(e)j(will)g(discuss)h(these)f(features)g(later)g(in)g
  2133. (section)g(2.5)h Fp(Some)f(of)g(P)l(ostgr)n(eSQL)n(')n(s)h(Special)e(F)
  2134. l(eatur)n(es)270 2975 y(in)g(Detail)p Ft())270 3095
  2135. y(Here)g(is)h(a)f(list)h(of)f(the)g(features)g(PostgreSQL)g(pro)o
  2136. (vides:)345 3197 y Fo(17)25 b Ft(An)12 b(e)o(xtended)g(subset)h(of)f
  2137. (SQL92)h(as)g(query)f(language.)345 3299 y Fo(17)25
  2138. b Ft(A)12 b(commandline)g(interface)f(called)h Fr(psql)g
  2139. Ft(using)h(GNU)f(readline.)345 3402 y Fo(17)25 b Ft(A)12
  2140. b(client/serv)o(er)g(architecture)f(allo)o(wing)h(concurrent)f(access)j
  2141. (to)e(the)h(databases.)1145 3552 y(26)p eop
  2142. %%Page: 27 27
  2143. 27 26 bop 198 60 a Fm(2.3.)29 b(WHERE)13 b(T)o(O)g(GET)g(POSTGRESQL)956
  2144. b Ft(27)273 234 y Fo(17)25 b Ft(Support)11 b(for)g(btree,)i(hash)g
  2145. (or)e(rtree)h(inde)o(x)o(es.)273 331 y Fo(17)25 b Ft(A)13
  2146. b(transaction)f(mechanism)h(based)h(on)f(the)g(two)f(phase)i(commit)e
  2147. (protocol)g(is)i(used)f(to)g(ensure)323 391 y(data)f(inte)o(grity)f
  2148. (throughout)h(concurrent)f(data)h(access.)273 488 y Fo(17)25
  2149. b Ft(Host)17 b(based,)i(password,)f(crypt,)g(ident)e((RFC)h(1413))f
  2150. (or)h(K)o(erberos)f(V4/V5)h(authentication)323 547 y(can)12
  2151. b(be)h(used)f(to)h(ensure)f(authorized)g(data)g(access.)273
  2152. 644 y Fo(17)25 b Ft(A)12 b(huge)g(amount)g(of)g(prede02ned)g(data)g
  2153. (types.)273 741 y Fo(17)25 b Ft(Support)11 b(for)g(user)i(de02ned)f
  2154. (data)g(types.)273 838 y Fo(17)25 b Ft(Support)11 b(for)g(user)i
  2155. (de02ned)f(SQL)g(functions.)273 935 y Fo(17)25 b
  2156. Ft(Support)11 b(for)g(reco)o(v)o(ery)h(after)g(a)h(crash.)273
  2157. 1032 y Fo(17)25 b Ft(A)12 b(precompiler)f(for)h(embedded)g(SQL)g(in)h
  2158. (C.)273 1129 y Fo(17)25 b Ft(An)12 b(ODBC)h(interface.)273
  2159. 1225 y Fo(17)25 b Ft(A)12 b(JDBC)h(interface.)273 1322
  2160. y Fo(17)25 b Ft(A)12 b(Tcl/Tk)h(interface.)273 1419
  2161. y Fo(17)25 b Ft(A)12 b(Perl)g(interface.)198 1586 y
  2162. Fi(2.3)71 b(Wher)o(e)17 b(to)h(Get)f(P)o(ostgr)o(eSQL)198
  2163. 1697 y Ft(PostgreSQL)26 b(is)h(a)o(v)o(ailable)f(as)i(source)e(distrib)
  2164. o(ution)g((v6.3.2)g(at)h(the)g(time)f(of)g(writing))f(from)198
  2165. 1757 y Fr(ftp://ftp.postgresql.org/pub/)p Ft(.)63 b(There)30
  2166. b(is)f(also)h(an)f(of)o(02cial)f(homepage)h(for)198
  2167. 1817 y(PostgreSQL)15 b(at)g Fr(http://www.postgresgl.org/)p
  2168. Ft(.)21 b(There)15 b(are)g(a)g(lot)g(of)g(hosts)g(mirroring)198
  2169. 1877 y(the)d(contents)h(of)f(the)g(abo)o(v)o(e)h(mentioned)f(ones)h
  2170. (all)f(o)o(v)o(er)g(the)h(world.)198 2008 y Fn(Copyright)e(of)h(P)o
  2171. (ostgr)o(eSQL)198 2101 y Ft(PostgreSQL)17 b(is)h(not)f(public)g(domain)
  2172. g(software.)30 b(It)17 b(is)h(copyrighted)e(by)h(the)h(Uni)o(v)o
  2173. (ersity)e(of)h(Cali-)198 2161 y(fornia)e(b)o(ut)h(may)g(be)g(used)h
  2174. (according)f(to)g(the)g(licensing)g(terms)g(of)g(the)g(the)g(copyright)
  2175. e(included)i(in)198 2221 y(e)o(v)o(ery)h(distrib)o(ution)g((refer)f
  2176. (to)h(the)h(02le)f Fr(COPYRIGHT)g Ft(included)g(in)g(e)o(v)o(ery)h
  2177. (distrib)o(ution)e(for)h(more)198 2281 y(information).)198
  2178. 2412 y Fn(Support)11 b(f)o(or)h(P)o(ostgr)o(eSQL)198
  2179. 2506 y Ft(There)g(is)g(no)g(of)o(02cial)e(support)i(for)f
  2180. (PostgreSQL.)g(That)h(means)h(there)e(is)h(no)g(obligation)e(for)h(an)o
  2181. (ybody)198 2565 y(to)h(pro)o(vide)g(maintenance,)h(support,)f(updates,)
  2182. h(enhancements)g(or)f(modi02cations)g(to)g(the)g(code.)17
  2183. b(The)198 2625 y(whole)c(PostgreSQL)g(project)g(is)h(maintained)e
  2184. (through)h(v)o(olunteer)f(ef)o(fort)g(only)m(.)18 b(Ho)o(we)o(v)o(er)13
  2185. b(there)g(are)198 2685 y(man)o(y)f(mailing)g(lists)h(which)f(can)h(be)f
  2186. (subscribed)h(to)f(in)g(case)h(of)f(problems:)198 2804
  2187. y(Support)f(Mailing)h(Lists:)273 2864 y Fr(announce@postgreSQL.org)e
  2188. Ft(for)h(announcements.)273 2924 y Fr(ports@postgreSQL.org)f
  2189. Ft(for)h(OS-speci02c)h(b)o(ugs.)273 2984 y Fr(bugs@postgreSQL.org)e
  2190. Ft(for)i(other)f(unsolv)o(ed)i(b)o(ugs.)273 3044 y Fr
  2191. (questions@postgreSQL.org)c Ft(for)j(general)g(discussion.)198
  2192. 3163 y(Mailing)g(Lists)i(for)d(De)o(v)o(elopers:)273
  2193. 3223 y Fr(hackers@postgreSQL.org)f Ft(for)h(serv)o(er)i(internals)f
  2194. (discussion.)273 3283 y Fr(docs@postgreSQL.org)e Ft(for)i(the)g
  2195. (documentation)f(project.)273 3342 y Fr(patches@postgreSQL.org)f
  2196. Ft(for)h(patches)i(and)f(discussion.)273 3402 y Fr
  2197. (mirrors@postgreSQL.org)e Ft(for)h(mirror)g(site)i(announcements.)p
  2198. eop
  2199. %%Page: 28 28
  2200. 28 27 bop 270 60 a Ft(28)307 b Fm(CHAPTER)14 b(2.)28
  2201. b(POSTGRESQL)13 b(FR)n(OM)f(THE)i(USER'S)e(POINT)g(OF)g(VIEW)270
  2202. 234 y Ft(T)l(o)i(subscribe)h(to)f(the)g(mailing)f(list)h
  2203. Fr(questions@postgreSQL.org)d Ft(for)i(e)o(xample)i(just)f(send)270
  2204. 294 y(an)e(email)h(to)f Fr(questions-request@postgreSQL.o)o(rg)e
  2205. Ft(with)i(the)g(lines)360 401 y Fr(subscribe)360 461
  2206. y(end)270 567 y Ft(in)g(the)h(body)f((not)f(the)i(subject)f(line).)
  2207. 270 746 y Fi(2.4)71 b(Ho)o(w)18 b(to)g(use)f(P)o(ostgr)o(eSQL)270
  2208. 861 y Ft(Before)11 b(we)h(can)g(use)g(PostgreSQL)g(we)g(ha)o(v)o(e)g
  2209. (to)f(get)h(and)g(install)f(it.)16 b(W)l(e)c(won')o(t)e(talk)i(about)g
  2210. (installing)270 921 y(PostgreSQL)g(here)h(because)g(the)g(installation)
  2211. f(procedure)g(is)h(straight)g(forward)e(and)i(described)f(v)o(ery)270
  2212. 980 y(detailed)h(in)h(the)f(02le)g Fr(INSTALL)g Ft(contained)g(in)g
  2213. (the)h(distrib)o(ution.)k(W)l(e)13 b(want)g(to)h(concentrate)f(on)g
  2214. (the)270 1040 y(basic)g(usage)g(of)f(PostgreSQL)g(after)f(a)i
  2215. (successful)g(setup)g(has)g(taken)e(place.)270 1194 y
  2216. Fh(2.4.1)59 b(Starting)14 b(The)h(P)o(ostmaster)270 1291
  2217. y Ft(As)j(mentioned)g(earlier)f(PostgreSQL)g(uses)i(a)f(traditional)f
  2218. (client/serv)o(er)h(architecture)f(to)h(pro)o(vide)270
  2219. 1351 y(multi)c(user)g(access.)24 b(The)15 b(serv)o(er)g(is)g
  2220. (represented)f(by)g(a)h(program)e(called)i Fr(postmaster)e
  2221. Ft(which)i(is)270 1410 y(started)c(only)h(once)f(at)h(each)g(host.)j
  2222. (This)e(master)e(serv)o(er)h(process)g(listens)g(at)f(a)h(speci02ed)g
  2223. (TCP/IP)f(port)270 1470 y(for)j(incoming)h(connections)g(by)g(a)h
  2224. (client.)24 b(F)o(or)15 b(e)o(v)o(ery)g(incoming)f(connection)h(the)g
  2225. Fr(postmaster)270 1530 y Ft(spa)o(wns)e(a)e(ne)o(w)h(serv)o(er)g
  2226. (process)g(()p Fr(postgres)p Ft())e(and)h(continues)h(listening)f
  2227. (for)g(further)g(connections.)270 1590 y(Ev)o(ery)18
  2228. b(serv)o(er)f(process)g(spa)o(wned)h(in)f(this)h(way)f(handles)g(e)o
  2229. (xactly)g(one)h(connection)f(to)g(one)g(client.)270 1649
  2230. y(The)f Fr(postgres)e Ft(serv)o(er)i(processes)g(communicate)f(with)f
  2231. (each)i(other)f(using)g(UNIX)g(semaphores)270 1709 y(and)k(shared)h
  2232. (memory)e(to)i(ensure)f(data)h(inte)o(grity)e(throughout)g(concurrent)h
  2233. (data)g(access.)38 b((F)o(or)19 b(a)270 1769 y(more)d(detailed)g
  2234. (description)f(on)h(these)h(architectural)e(concepts)h(see)h(chapter)f
  2235. (3)g Fp(P)l(ostgr)n(eSQL)h(fr)n(om)270 1829 y(the)12
  2236. b(Pr)n(ogr)o(ammer')n(s)i(P)l(oint)e(of)g(V)l(ie)o(w)p
  2237. Ft(.))270 1948 y(T)l(o)h(start)f(the)g(master)h(serv)o(er)f(process)h
  2238. (use)g(the)f(follo)o(wing)f(command:)330 2056 y Fr($)30
  2239. b(nohup)f(postmaster)g(>)g(server.log)g(2>&1)h(&)270
  2240. 2161 y Ft(which)11 b(will)g(start)g Fr(postmaster)g Ft(in)g(the)g
  2241. (background)g(and)g(e)o(v)o(en)h(if)f(you)g(log)g(out)g(of)g(the)g
  2242. (system)h(the)270 2221 y(process)h(remains)f(acti)o(v)o(e.)k(All)c
  2243. (errors)g(and)g(messages)i(will)e(be)g(logged)g(to)g(the)h(02le)f
  2244. Fr(server.log)p Ft(.)270 2341 y Fn(Note:)35 b Ft(The)23
  2245. b Fr(postmaster)e Ft(process)i(is)g(usually)g(started)f(by)g(a)h
  2246. (special)g Fp(database)g(superuser)270 2401 y Ft(called)c
  2247. Fr(postgres)f Ft(which)h(is)g(a)g(normal)g(UNIX)f(user)h(b)o(ut)g(has)g
  2248. (more)g(rights)f(concerning)h(Post-)270 2460 y(greSQL.)f(F)o(or)g
  2249. (security)g(reasons)h(it)f(is)g(strongly)g(recommended)f(not)h(to)g
  2250. (run)g(the)g Fr(postmaster)270 2520 y Ft(process)13 b(as)g(the)f
  2251. Fp(system)h(super)h(user)f Fr(root)p Ft(.)270 2674 y
  2252. Fh(2.4.2)59 b(Cr)o(eating)14 b(a)h(New)g(Database)270
  2253. 2771 y Ft(Once)c(the)g Fr(postmaster)f Ft(daemon)g(is)i(running)e(we)h
  2254. (can)g(create)g(a)g(ne)o(w)f(database)i(using)f(the)g(follo)o(w-)270
  2255. 2830 y(ing)h(command:)330 2938 y Fr($)30 b(createdb)f(testdb)270
  2256. 3044 y Ft(which)22 b(will)g(create)g(a)g(database)h(called)f
  2257. Fr(testdb)p Ft(.)45 b(The)23 b(user)f(e)o(x)o(ecuting)h(the)f(command)f
  2258. (will)270 3103 y(become)12 b(the)f(database)h(administrator)f(and)g
  2259. (will)g(therefore)g(be)h(the)f(only)g(user)h((e)o(xcept)g(the)f
  2260. Fp(database)270 3163 y(superuser)j Fr(postgres)p Ft())d(who)h(can)h
  2261. (destroy)e(the)i(database)g(again.)270 3283 y Fn(Note:)35
  2262. b Ft(T)l(o)22 b(create)h(the)f(database)h(you)f(don')o(t)g(need)g(to)g
  2263. (kno)o(w)g(an)o(ything)g(about)g(the)g(tables)h((re-)270
  2264. 3342 y(lations))16 b(that)h(will)f(be)h(used)h(within)e(the)h
  2265. (database.)29 b(The)18 b(tables)f(will)f(be)h(de02ned)g(later)f
  2266. (using)h(the)270 3402 y(SQL)c(statements)f(sho)o(wn)h(in)f(section)g
  2267. (2.4.4)h Fp(De02ning)f(and)h(P)l(opulating)f(T)-5 b(ables)p
  2268. Ft(.)p eop
  2269. %%Page: 29 29
  2270. 29 28 bop 198 60 a Fm(2.4.)29 b(HO)n(W)12 b(T)o(O)h(USE)g(POSTGRESQL)
  2271. 1018 b Ft(29)198 234 y Fh(2.4.3)59 b(Connecting)15 b(T)-5
  2272. b(o)14 b(a)h(Database)198 335 y Ft(After)g(ha)o(ving)g(created)h(at)g
  2273. (least)g(one)g(database)g(we)g(can)g(make)g(our)f(02rst)g(client)h
  2274. (connection)f(to)h(the)198 395 y(database)g(system)g(to)f(be)g(able)g
  2275. (to)g(de02ne)g(tables,)i(populate)e(them,)h(retrie)o(v)o(e)f(data,)h
  2276. (update)f(data)g(etc.)198 455 y(Note)20 b(that)g(most)f(database)i
  2277. (manipulation)e(is)h(done)g(this)g(way)f((just)h(creating)f(and)h
  2278. (destroying)f(a)198 514 y(database)11 b(is)f(done)g(by)g(separate)h
  2279. (commands)f(which)g(are)g(in)g(fact)f(just)i(shell)f(scripts)g(also)h
  2280. (using)f Fr(psql)p Ft())198 634 y(The)j(connection)f(to)g(the)g(DBMS)h
  2281. (is)g(established)g(by)f(the)g(follo)o(wing)f(command:)258
  2282. 749 y Fr($)30 b(psql)f(testdb)198 861 y Ft(which)18 b(will)f(make)g(a)h
  2283. (connection)g(to)f(a)h(database)g(called)g Fr(testdb)p
  2284. Ft(.)32 b Fr(psql)17 b Ft(is)h(a)g(command)f(line)198
  2285. 920 y(interface)d(using)h(GNU)g(readline.)23 b(It)15
  2286. b(can)g(handle)g(a)g(connection)g(to)f(only)h(one)g(database)h(at)f(a)g
  2287. (time.)198 980 y(When)d(the)h(connection)f(is)g(established)h
  2288. Fr(psql)f Ft(presents)h(itself)f(as)h(follo)o(ws:)258
  2289. 1095 y Fr(Welcome)29 b(to)h(the)f(POSTGRESQL)g(interactive)g(sql)g
  2290. (monitor:)318 1155 y(Please)g(read)g(the)h(file)f(COPYRIGHT)g(for)h
  2291. (copyright)f(terms)g(of)318 1215 y(POSTGRESQL)347 1334
  2292. y(type)h(\?)g(for)f(help)h(on)f(slash)h(commands)347
  2293. 1394 y(type)g(\q)g(to)f(quit)347 1454 y(type)h(\g)g(or)f(terminate)g
  2294. (with)h(semicolon)e(to)i(execute)f(query)288 1514 y(You)g(are)h
  2295. (currently)f(connected)g(to)g(the)h(database:)f(testdb)258
  2296. 1633 y(testdb=>)198 1745 y Ft(No)o(w)16 b(you)g(can)g(either)g(enter)g
  2297. (an)o(y)g(v)o(alid)g(SQL)g(statement)h(terminated)e(by)h(a)g(';')i(or)d
  2298. (use)i(one)f(of)g(the)198 1805 y Fp(slash)d(commands)p
  2299. Ft(.)j(A)c(list)h(of)f(all)g(a)o(v)o(ailable)g Fp(slash)h(commands)f
  2300. Ft(can)h(be)f(obtained)g(by)h(typing)e Fr(')p Fo(n)p
  2301. Fr(?')p Ft(.)198 1924 y(Here)h(is)h(a)f(list)h(of)f(the)g(most)g
  2302. (important)g Fp(slash)h(commands)p Ft(:)273 2035 y Fo(17)25
  2303. b(n)p Fr(?)f Ft(lists)13 b(all)f(a)o(v)o(ailable)g Fp(slash)h(commands)
  2304. g Ft(and)f(gi)o(v)o(es)h(a)f(short)g(description.)273
  2305. 2151 y Fo(17)25 b(n)p Fr(q)f Ft(quits)13 b Fr(psql)p
  2306. Ft(.)273 2266 y Fo(17)25 b(n)p Fr(d)f Ft(lists)13 b(all)f(tables,)h
  2307. (vie)o(ws)g(and)f(inde)o(x)o(es)h(e)o(xisting)g(in)f(the)g(current)g
  2308. (database.)273 2381 y Fo(17)25 b(n)p Fr(dt)f Ft(lists)13
  2309. b(only)f(tables.)273 2497 y Fo(17)25 b(n)p Fr(dT)f
  2310. Ft(lists)13 b(all)f(a)o(v)o(ailable)g(data)h(types.)273
  2311. 2612 y Fo(17)25 b(n)p Fr(i)k Fk(<)p Fr(filename)p Fk(>)24
  2312. b Ft(reads)12 b(and)h(e)o(x)o(ecutes)g(the)f(queries)h(contained)f(in)g
  2313. Fr(filename)p Ft(.)273 2727 y Fo(17)25 b(n)p Fr(l)f
  2314. Ft(lists)13 b(all)f(a)o(v)o(ailable)g(databases)i(kno)o(wn)d(to)i(the)f
  2315. (system.)273 2843 y Fo(17)25 b(n)p Fr(connect)k Fk(<)p
  2316. Fr(database)p Fk(>)37 b Ft(terminates)19 b(the)g(current)g(connection)g
  2317. (and)g(opens)h(a)f(ne)o(w)323 2902 y(connection)12 b(to)g
  2318. Fr(database)p Ft(.)273 3018 y Fo(17)25 b(n)p Fr(o)k
  2319. Fl([)p Fk(<)p Fr(filename)p Fk(>)p Fl(])23 b Ft(sends)14
  2320. b(all)e(query)g(output)f(to)i Fr(file)p Ft(.)198 3182
  2321. y Fh(2.4.4)59 b(De02ning)15 b(and)g(P)o(opulating)f(T)-5
  2322. b(ables)198 3283 y Ft(De02ning)13 b(tables)i(and)f(inserting)f
  2323. (tuples)h(is)g(done)g(by)g(the)g(SQL)g(statements)g Fr(CREATE)30
  2324. b(TABLE)13 b Ft(and)198 3342 y Fr(INSERT)29 b(INTO)p
  2325. Ft(.)14 b(F)o(or)f(a)g(detailed)h(description)e(on)i(the)f(syntax)h(of)
  2326. f(these)h(commands)f(refer)g(to)g(sec-)198 3402 y(tion)f(1.3.2)h
  2327. Fp(Data)f(De02nition)p Ft(.)p eop
  2328. %%Page: 30 30
  2329. 30 29 bop 270 60 a Ft(30)310 b Fm(CHAPTER)14 b(2.)25
  2330. b(POSTGRESQL)13 b(FR)n(OM)f(THE)i(USER'S)e(POINT)g(OF)g(VIEW)270
  2331. 234 y Fn(Example)h(2.1)25 b Ft(T)l(o)12 b(create)g(and)g(populate)g
  2332. (the)g(table)g(SUPPLIER)g(used)g(in)g(02gure)g(1.1)g
  2333. Fp(The)g(suppliers)270 294 y(and)g(parts)h(database)f
  2334. Ft(we)h(could)f(use)h(the)f(follo)o(wing)f(session:)330
  2335. 403 y Fr($)30 b(psql)f(testdb)330 522 y(Welcome)g(to)h(the)f
  2336. (POSTGRESQL)g(interactive)g(sql)g(monitor:)390 582 y(Please)g(read)g
  2337. (the)h(file)f(COPYRIGHT)g(for)h(copyright)f(terms)g(of)390
  2338. 642 y(POSTGRESQL)419 761 y(type)h(\?)g(for)f(help)h(on)f(slash)h
  2339. (commands)419 821 y(type)g(\q)g(to)f(quit)419 881 y(type)h(\g)g(or)f
  2340. (terminate)g(with)h(semicolon)e(to)i(execute)f(query)360
  2341. 941 y(You)g(are)h(currently)f(connected)g(to)g(the)h(database:)f
  2342. (testdb)330 1060 y(testdb=>)g(create)g(table)g(supplier)g((sno)h
  2343. (int4,)330 1120 y(testdb->)f(sname)g(varchar(20),)330
  2344. 1180 y(testdb->)g(city)g(varchar(20));)330 1239 y(CREATE)330
  2345. 1299 y(testdb=>)g(insert)g(into)g(supplier)g((sno,)h(sname,)f(city))
  2346. 330 1359 y(testdb->)g(values)g((1,'Smith','London');)330
  2347. 1419 y(INSERT)g(26187)g(1)330 1479 y(testdb=>)g(insert)g(into)g
  2348. (supplier)g((sno,)h(sname,)f(city))330 1538 y(testdb->)g(values)g
  2349. ((2,'Jones','Paris');)330 1598 y(INSERT)g(26188)g(1)330
  2350. 1658 y(testdb=>)g(insert)g(into)g(supplier)g((sno,)h(sname,)f(city))
  2351. 330 1718 y(testdb->)g(values)g((3,'Adams','Vienna');)330
  2352. 1777 y(INSERT)g(26189)g(1)330 1837 y(testdb=>)g(insert)g(into)g
  2353. (supplier)g((sno,)h(sname,)f(city))330 1897 y(testdb->)g(values)g
  2354. ((4,'Blake','Rome');)330 1957 y(INSERT)g(26190)g(1)330
  2355. 2017 y(testdb=>)270 2123 y Ft(If)12 b(you)g(02rst)g(put)g(all)g(the)h
  2356. (abo)o(v)o(e)f(commands)h(into)f(a)g(02le)g(you)h(can)f(easily)h(e)o
  2357. (x)o(ecute)g(the)f(statements)h(by)270 2183 y(the)f Fp(slash)h(command)
  2358. 25 b Fo(n)p Fr(i)k Fk(<)p Fr(file)p Fk(>)p Ft(.)270 2302
  2359. y(Note:)34 b(The)22 b(data)g(type)f Fr(int4)h Ft(is)g(not)f(part)g(of)h
  2360. (the)f(SQL92)h(standard.)44 b(It)21 b(is)h(a)g(b)o(uilt)f(in)h(Post-)
  2361. 270 2362 y(greSQL)13 b(type)g(denoting)g(a)g(four)f(byte)h(signed)g
  2362. (inte)o(ger)m(.)18 b(F)o(or)13 b(information)f(on)h(which)g(data)g
  2363. (types)g(are)270 2422 y(a)o(v)o(ailable)g(you)h(can)g(use)g(the)f
  2364. Fo(n)p Fr(dT)h Ft(command)f(which)h(will)f(gi)o(v)o(e)g(a)h(list)g(and)
  2365. f(short)h(description)f(of)g(all)270 2482 y(datatypes)g(currently)e
  2366. (kno)o(wn)h(to)g(PostgreSQL.)270 2637 y Fh(2.4.5)59 b(Retrie)o(ving)13
  2367. b(Data)i(Fr)o(om)f(The)g(Database)270 2734 y Ft(After)19
  2368. b(ha)o(ving)g(de02ned)h(and)f(populated)h(the)f(tables)h(in)g(the)g
  2369. (database)g Fr(testdb)f Ft(we)h(are)f(able)h(to)270 2794
  2370. y(retrie)o(v)o(e)10 b(data)h(by)g(formulating)e(queries)i(using)g
  2371. Fr(psql)p Ft(.)k(Ev)o(ery)d(query)e(has)h(to)g(be)g(terminated)f(by)h
  2372. (a)h(';'.)270 2927 y Fn(Example)h(2.2)25 b Ft(W)l(e)f(assume)h(that)f
  2373. (all)g(the)g(tables)g(form)f(02gure)g(1.1)i Fp(The)e(suppliers)i(and)
  2374. f(parts)270 2987 y(database)19 b Ft(e)o(xist)h(in)f(the)g(database)g
  2375. Fr(testdb)p Ft(.)36 b(If)18 b(we)i(want)e(to)h(kno)o(w)g(all)g(parts)g
  2376. (that)g(are)g(sold)g(in)270 3047 y(London)12 b(we)h(use)g(the)f(follo)o
  2377. (wing)f(session:)330 3155 y Fr(testdb=>)29 b(select)g(p.pname)330
  2378. 3215 y(testdb->)g(from)g(supplier)g(s,)h(sells)f(se,)h(part)f(p)330
  2379. 3275 y(testdb->)g(where)g(s.sno=se.sno)g(and)330 3335
  2380. y(testdb->)208 b(p.pno=se.pno)29 b(and)330 3395 y(testdb->)208
  2381. b(s.city='London';)p eop
  2382. %%Page: 31 31
  2383. 31 30 bop 198 60 a Fm(2.5.)29 b(SOME)12 b(OF)h(POSTGRESQL)-5
  2384. b('S)12 b(SPECIAL)h(FEA)-6 b(TURES)14 b(IN)e(DET)-5 b(AIL)340
  2385. b Ft(31)258 234 y Fr(pname)258 294 y(-----)258 354 y(Screw)258
  2386. 413 y(Nut)258 473 y((2)29 b(rows))258 593 y(testdb=>)198
  2387. 729 y Fn(Example)13 b(2.3)25 b Ft(W)l(e)18 b(use)h(again)f(the)g
  2388. (tables)g(gi)o(v)o(en)g(in)g(02gure)f(1.1.)33 b(No)o(w)18
  2389. b(we)g(want)g(to)g(retrie)o(v)o(e)f(all)198 789 y(suppliers)12
  2390. b(selling)h(no)f(parts)g(at)h(all)f((to)g(remo)o(v)o(e)g(them)g(from)f
  2391. (the)i(suppliers)f(table)g(for)g(e)o(xample):)258 900
  2392. y Fr(testdb=>)29 b(select)g(*)h(from)f(supplier)g(s)258
  2393. 960 y(testdb->)g(where)g(not)h(exists)258 1020 y(testdb->)507
  2394. b((select)29 b(sno)h(from)f(sells)g(se)258 1080 y(testdb->)537
  2395. b(where)29 b(se.sno)g(=)h(s.sno);)258 1139 y(sno|sname|city)258
  2396. 1199 y(---+-----+----)258 1259 y((0)f(rows))258 1378
  2397. y(testdb=>)198 1487 y Ft(The)15 b(result)f(relation)g(is)h(empty)f(in)h
  2398. (our)f(e)o(xample)h(telling)f(us)h(that)f(e)o(v)o(ery)g(supplier)g
  2399. (contained)h(in)f(the)198 1546 y(database)e(sells)f(at)g(least)h(one)f
  2400. (part.)k(Note)c(that)g(we)g(used)g(a)h(nested)f(subselect)h(to)f
  2401. (formulate)e(the)i(query)m(.)198 1730 y Fi(2.5)71 b(Some)18
  2402. b(of)f(P)o(ostgr)o(eSQL)-8 b(')m(s)16 b(Special)i(F)n(eatur)o(es)e(in)i
  2403. (Detail)198 1847 y Ft(T)n(raditional)23 b(relational)g(database)h
  2404. (management)g(systems)g((RDMSs))g(pro)o(vide)f(only)g(v)o(ery)h(fe)o
  2405. (w)198 1907 y(datatypes)16 b(including)e(03oating)h(point)g(numbers,)
  2406. h(inte)o(gers,)g(character)f(strings,)i(mone)o(y)m(,)f(and)f(dates.)198
  2407. 1967 y(This)j(makes)f(the)g(implementation)f(of)h(man)o(y)g
  2408. (applications)g(v)o(ery)g(dif)o(02cult)e(and)j(that')m(s)f(why)g
  2409. (Post-)198 2026 y(greSQL)12 b(of)o(fers)e(substantial)i(additional)f
  2410. (po)o(wer)h(by)f(incorporating)f(the)i(follo)o(wing)f(additional)g
  2411. (basic)198 2086 y(concepts)i(in)f(such)h(a)f(way)g(that)g(users)h(can)g
  2412. (easily)f(e)o(xtend)h(the)f(system:)273 2194 y Fo(17)25
  2413. b Ft(inheritance)273 2305 y Fo(17)g Ft(user)12 b(de02ned)g
  2414. (functions)273 2416 y Fo(17)25 b Ft(user)12 b(de02ned)g(types)273
  2415. 2527 y Fo(17)25 b Ft(rules)198 2636 y(Some)11 b(other)g(features,)h
  2416. (implemented)e(in)h(most)h(modern)e(RDBMSs)j(pro)o(vide)e(additional)f
  2417. (po)o(wer)h(and)198 2695 y(03e)o(xibility:)273 2804
  2418. y Fo(17)25 b Ft(constraints)12 b((gi)o(v)o(en)g(in)g(the)g
  2419. Fr(create)29 b(table)12 b Ft(command))273 2915 y Fo(17)25
  2420. b Ft(triggers)273 3026 y Fo(17)g Ft(transaction)12
  2421. b(inte)o(grity)198 3184 y Fh(2.5.1)59 b(Inheritance)198
  2422. 3283 y Ft(Inheritance)14 b(is)h(a)g(feature)f(well)g(kno)o(wn)g(from)g
  2423. (object)h(oriented)f(programming)e(languages)j(such)h(as)198
  2424. 3342 y(Smalltalk)c(or)g(C++.)18 b(PostgreSQL)13 b(refers)f(to)h(tables)
  2425. g(as)g Fp(classes)h Ft(and)f(the)g(de02nition)f(of)h(a)g
  2426. Fp(class)g Ft(may)198 3402 y(inherit)f(the)g(contents)g(of)g(another)g
  2427. Fp(class)p Ft(:)p eop
  2428. %%Page: 32 32
  2429. 32 31 bop 270 60 a Ft(32)307 b Fm(CHAPTER)14 b(2.)28
  2430. b(POSTGRESQL)13 b(FR)n(OM)f(THE)i(USER'S)e(POINT)g(OF)g(VIEW)270
  2431. 234 y Fn(Example)h(2.4)25 b Ft(First)12 b(we)g(de02ne)g(a)h(table)f
  2432. ((class))h Fr(city)p Ft(:)330 320 y Fr(testdb=>)29
  2433. b(create)g(table)g(city)h(()330 380 y(testdb->)f(name)g
  2434. (varchar(20),)330 440 y(testdb->)g(population)g(int4,)330
  2435. 500 y(testdb->)g(altitude)g(int4);)330 560 y(CREATE)330
  2436. 619 y(testdb=>)270 706 y Ft(No)o(w)17 b(we)g(de02ne)f(a)i(ne)o(w)e
  2437. (table)h((class))g Fr(capital)f Ft(that)h(inherits)f(all)h(attrib)o
  2438. (utes)g(from)f Fr(city)g Ft(and)270 765 y(adds)d(a)f(ne)o(w)h(attrib)o
  2439. (ute)e Fr(country)h Ft(storing)g(the)g(country)f(which)i(it)f(is)g(the)
  2440. h(capital)f(of.)330 852 y Fr(testdb=>)29 b(create)g(table)g(capital)g
  2441. (()330 912 y(testdb->)g(country)g(varchar(20))330
  2442. 971 y(testdb->)g())h(inherits)f((city);)330 1031 y(CREATE)330
  2443. 1091 y(testdb=>)270 1177 y Fn(Note)p Ft(:)23 b(The)17
  2444. b(class)g Fr(capital)f Ft(inherits)g(only)g(the)g(attrib)o(utes)g(of)g
  2445. Fr(city)g Ft((not)g(the)g(tuples)h(stored)f(in)270 1237
  2446. y Fr(city)p Ft().)f(The)e(ne)o(w)f(table)g(can)h(be)g(used)f(as)h(if)f
  2447. (it)g(were)g(de02ned)h(without)e(using)i(inheritance:)330
  2448. 1323 y Fr(testdb=>)29 b(insert)g(into)g(capital)h((name,)f
  2449. (population,)330 1383 y(testdb->)656 b(altitude,)29 b(state))330
  2450. 1443 y(testdb->)g(values)g(('Vienna',)g(1500000,)g(200,)g
  2451. ('Austria');)330 1503 y(INSERT)g(26191)g(1)330 1562
  2452. y(testdb=>)270 1649 y Ft(Let')m(s)18 b(assume)g(that)f(the)g(tables)h
  2453. Fr(city)f Ft(and)g Fr(capital)g Ft(ha)o(v)o(e)h(been)f(populated)g(in)g
  2454. (the)h(follo)o(wing)270 1709 y(way:)330 1795 y Fr(city)179
  2455. b(name)149 b(|)29 b(population)g(|)h(altitude)629 1855
  2456. y(---------+------------+------)o(---)629 1914 y(Linz)149
  2457. b(|)g(200000)29 b(|)179 b(270)629 1974 y(Graz)149 b(|)g(250000)29
  2458. b(|)179 b(350)629 2034 y(Villach)59 b(|)179 b(50000)29
  2459. b(|)179 b(500)629 2094 y(Salzburg)29 b(|)149 b(150000)29
  2460. b(|)179 b(420)330 2273 y(capital)89 b(name)149 b(|)29
  2461. b(population)g(|)h(altitude)f(|)60 b(country)629 2333
  2462. y(---------+------------+------)o(----+----)o(-----)629
  2463. 2393 y(Vienna)89 b(|)119 b(1500000)29 b(|)179 b(200)30
  2464. b(|)60 b(Austria)270 2479 y Ft(Standard)12 b(SQL92)g(queries)g(against)
  2465. h(the)f(abo)o(v)o(e)h(tables)f(beha)o(v)o(e)h(e)o(xactly)g(as)g(e)o
  2466. (xpected:)330 2565 y Fr(testdb=>)29 b(select)g(*)h(from)f(city)330
  2467. 2625 y(testdb->)g(where)g(altitude)g(>)h(400;)330 2685
  2468. y(name)149 b(|)30 b(population)e(|)i(altitude)330 2745
  2469. y(---------+------------+-------)o(--)330 2804 y(Villach)59
  2470. b(|)179 b(50000)29 b(|)180 b(500)330 2864 y(Salzburg)29
  2471. b(|)149 b(150000)29 b(|)180 b(420)330 2924 y((2)29 b(rows))330
  2472. 3044 y(testdb=>)g(select)g(*)h(from)f(capital;)330 3103
  2473. y(name)149 b(|)30 b(population)e(|)i(altitude)f(|)60
  2474. b(country)330 3163 y(---------+------------+-------)o(---+-----)o(----)
  2475. 330 3223 y(Vienna)89 b(|)119 b(1500000)29 b(|)180 b(200)29
  2476. b(|)60 b(Austria)330 3283 y((1)29 b(row))330 3402 y(testdb=>)p
  2477. eop
  2478. %%Page: 33 33
  2479. 33 32 bop 198 60 a Fm(2.5.)29 b(SOME)12 b(OF)h(POSTGRESQL)-5
  2480. b('S)12 b(SPECIAL)h(FEA)-6 b(TURES)14 b(IN)e(DET)-5 b(AIL)340
  2481. b Ft(33)198 234 y(If)11 b(we)g(want)g(to)g(kno)o(w)g(the)g(names)h(of)f
  2482. (all)g(cities)h((including)e(capitals))h(that)g(are)g(located)h(at)f
  2483. (an)h(altitude)198 294 y(o)o(v)o(er)g(100)h(meters)f(the)g(query)g(is:)
  2484. 258 376 y Fr(testdb=>)29 b(select)g(*)h(from)f(city*)258
  2485. 436 y(testdb->)g(where)g(altitude)g(>)h(100;)258 495
  2486. y(name)149 b(|)30 b(population)e(|)i(altitude)258 555
  2487. y(---------+------------+-------)o(--)258 615 y(Linz)149
  2488. b(|)g(200000)29 b(|)180 b(270)258 675 y(Graz)149 b(|)g(250000)29
  2489. b(|)180 b(350)258 734 y(Villach)59 b(|)179 b(50000)29
  2490. b(|)180 b(500)258 794 y(Salzburg)29 b(|)149 b(150000)29
  2491. b(|)180 b(420)258 854 y(Vienna)89 b(|)119 b(1500000)29
  2492. b(|)180 b(200)258 914 y((5)29 b(rows))258 1033 y(testdb=>)198
  2493. 1115 y Ft(Here)14 b(the)h('*')f(after)g Fr(city)g Ft(indicates)h(that)f
  2494. (the)g(query)h(should)f(be)h(run)f(o)o(v)o(er)g Fr(city)h
  2495. Ft(and)f(all)h(classes)198 1175 y(belo)o(w)i Fr(city)g
  2496. Ft(in)g(the)g(inheritance)f(hierarchy)m(.)29 b(Man)o(y)18
  2497. b(of)e(the)i(commands)f(that)g(we)g(ha)o(v)o(e)g(already)198
  2498. 1235 y(discussed)c((SELECT)l(,)i(UPD)n(A)-6 b(TE,)14
  2499. b(DELETE,)h(etc))d(support)g(this)g('*')g(notation.)198
  2500. 1373 y Fh(2.5.2)59 b(User)15 b(De02ned)g(Functions)198
  2501. 1467 y Ft(PostgreSQL)i(allo)o(ws)g(the)g(de02nition)f(and)h(usage)h
  2502. (of)e Fp(user)i(de02ned)f(functions)p Ft(.)30 b(The)17
  2503. b(ne)o(w)g(de02ned)198 1527 y(functions)12 b(can)g(be)h(used)g
  2504. (within)e(e)o(v)o(ery)i(query)m(.)i(PostgreSQL)d(pro)o(vides)g(two)g
  2505. (types)g(of)g(functions:)273 1608 y Fo(17)25 b Ft(Query)11
  2506. b(Language)i((SQL))f(Functions:)j(functions)d(written)f(in)h(SQL.)273
  2507. 1699 y Fo(17)25 b Ft(Programming)14 b(Language)j(Functions:)22
  2508. b(functions)16 b(written)f(in)h(a)h Fp(compiled)f Ft(language)g(such)
  2509. 323 1759 y(as)c(C.)198 1888 y Fn(Query)g(Language)g((SQL))f
  2510. (Functions)198 1981 y Ft(These)k(functions)d(are)i(de02ned)f(using)h
  2511. (SQL.)g(Note)f(that)g Fp(query)h(language)e(functions)h
  2512. Ft(do)h(not)f(e)o(xtend)198 2041 y(the)k Fp(e)o(xpr)n(essive)h(power)g
  2513. Ft(of)e(the)h(SQL92)g(standard.)29 b(Ev)o(ery)17 b Fp(query)g(language)
  2514. f(function)g Ft(can)h(be)g(re-)198 2100 y(placed)10 b(by)g(an)g
  2515. (appropriate)f(nested)h(query)f(()p Fp(subselect)p Ft())h(without)f
  2516. (changing)h(the)f(semantical)h(meaning)198 2160 y(of)j(the)g(whole)g
  2517. (query)m(.)k(Ho)o(we)o(v)o(er)n(,)d(since)f(PostgreSQL)g(does)h(not)f
  2518. (allo)o(w)f Fp(subselects)j Ft(in)e(the)g Fp(selectlist)198
  2519. 2220 y Ft(at)g(the)f(moment)g(b)o(ut)h(does)g(allo)o(w)f(the)g(usage)h
  2520. (of)g Fp(query)g(language)e(functions)p Ft(,)i(the)f
  2521. Fp(e)o(xpr)n(essive)i(power)198 2280 y Ft(of)e(PostgreSQL)-5
  2522. b(')m(s)13 b(current)e(SQL)i(implementation)e(is)i(e)o(xtended.)273
  2523. 2340 y(The)44 b(de02nition)f(of)h Fp(query)g(language)e(functions)i
  2524. Ft(is)g(done)g(using)g(the)g(command)198 2399 y Fr(create)29
  2525. b(function)g Fk(<)p Fr(function)p 958 2399 15 2 v 17
  2526. w(name)p Fk(>)o Ft(.)d(Ev)o(ery)16 b(function)f(can)h(take)f(zero)g(or)
  2527. h(more)f(ar)o(-)198 2459 y(guments.)23 b(The)16 b(type)f(of)f(e)o(v)o
  2528. (ery)h(ar)o(gument)f(is)h(speci02ed)h(in)e(the)h(list)g(of)g(ar)o
  2529. (guments)f(in)h(the)g(function)198 2519 y(de02nition.)28
  2530. b(The)17 b(type)f(of)h(the)f(function')m(s)g(result)h(is)f(gi)o(v)o(en)
  2531. h(after)f(the)g(ke)o(yword)g Fr(returns)g Ft(in)g(the)198
  2532. 2579 y(function)d(de02nition.)20 b(The)15 b(types)f(used)g(for)g(the)
  2533. g(ar)o(guments)f(and)h(the)g(return)g(v)o(alue)f(of)h(the)g(function)
  2534. 198 2638 y(can)i(either)f(be)g Fp(base)h(types)g Ft((e.g.)25
  2535. b(int4,)17 b(v)o(archar)n(,)f(.)7 b(.)g(.)g())27 b(or)15
  2536. b Fp(composite)g(types)p Ft(.)26 b((F)o(or)15 b(each)g(class)i((ta-)
  2537. 198 2698 y(ble))c(that)g(is)h(created,)g(a)g(corresponding)f
  2538. Fp(composite)g(type)h Ft(is)g(de02ned.)19 b Fr(supplier)12
  2539. b Ft(and)i Fr(part)f Ft(are)198 2758 y(e)o(xamples)g(for)e
  2540. Fp(composite)i(types)g Ft(after)e(the)i(tables)f Fr(supplier)g
  2541. Ft(and)g Fr(part)g Ft(ha)o(v)o(e)h(been)g(created.))198
  2542. 2864 y Fn(Example)g(2.5)25 b Ft(This)13 b(is)g(an)f(e)o(xample)g(using)
  2543. h(only)f Fp(base)h(types)p Ft(.)198 2984 y(Before)29
  2544. b(PostgreSQL)g(was)g(e)o(xtended)g(to)h(support)e(nested)i(subqueries)f
  2545. (user)h(de02ned)f(query)198 3044 y(language)11 b((SQL))f(functions)
  2546. h(could)g(be)g(used)g(to)g(simulate)g(them.)k(Consider)c(e)o(xample)h
  2547. (2.3)f(where)g(we)198 3103 y(ha)o(v)o(e)k(wanted)g(to)f(kno)o(w)h(the)f
  2548. (names)i(of)e(all)h(suppliers)f(that)h(do)g(not)f(sell)i(an)o(y)f(part)
  2549. f(at)h(all.)23 b(Normally)198 3163 y(we)13 b(would)f(formulate)g(the)h
  2550. (query)f(as)i(we)f(did)g(in)f(e)o(xample)i(2.3.)j(Here)c(we)g(want)g
  2551. (to)g(sho)o(w)g(a)g(possible)198 3223 y(way)h(of)g(formulating)f(the)h
  2552. (query)g(without)g(using)g(a)h(subquery)m(.)21 b(This)15
  2553. b(is)g(done)f(in)h(two)e(steps.)23 b(In)14 b(the)198
  2554. 3283 y(02rst)j(step)h(we)f(de02ne)h(the)f(function)f
  2555. Fr(my)p 930 3283 V 18 w(exists)p Ft(.)30 b(In)17 b(the)h(second)g(step)
  2556. f(we)h(formulate)e(a)i(query)198 3342 y(using)12 b(the)h(ne)o(w)f
  2557. (function.)p eop
  2558. %%Page: 34 34
  2559. 34 33 bop 270 60 a Ft(34)307 b Fm(CHAPTER)14 b(2.)28
  2560. b(POSTGRESQL)13 b(FR)n(OM)f(THE)i(USER'S)e(POINT)g(OF)g(VIEW)270
  2561. 234 y Ft(In)f(the)h(02rst)f(step)h(we)g(de02ne)g(the)f(ne)o(w)h
  2562. (function)f Fr(my)p 1188 234 15 2 v 18 w(exists(int4))f
  2563. Ft(which)i(takes)f(an)h(inte)o(ger)g(as)270 294 y(ar)o(gument:)330
  2564. 374 y Fr(testdb=>)29 b(create)g(function)g(my_exists(int4))f(returns)
  2565. h(int4)330 434 y(testdb->)g(as)g('select)h(count(pno))e(from)i(sells)
  2566. 330 494 y(testdb->)148 b(where)30 b(sno)f(=)h($1;')f(language)g('sql';)
  2567. 330 554 y(CREATE)330 613 y(testdb=>)270 694 y Ft(Here)12
  2568. b(is)h(the)f(second)h(step)g(which)f(performs)f(the)i(intended)f
  2569. (retrie)o(v)o(e:)330 774 y Fr(testdb=>)29 b(select)g(s.sname)g(from)h
  2570. (supplier)f(s)330 834 y(testdb->)g(where)g(my_exists(s.sno))f(=)i(0;)
  2571. 330 894 y(sname)330 953 y(-----)330 1013 y((0)f(rows))330
  2572. 1133 y(testdb=>)270 1213 y Ft(No)o(w)12 b(let')m(s)h(ha)o(v)o(e)f(a)h
  2573. (look)f(at)g(what)h(is)f(happening)g(here.)k(The)d(function)e
  2574. Fr(my)p 1582 1213 V 18 w(exists(int4))g Ft(takes)270
  2575. 1273 y(one)j(ar)o(gument)f(which)h(must)g(be)g(of)f(type)h(inte)o(ger)m
  2576. (.)20 b(W)n(ithin)13 b(the)h(function)f(de02nition)g(this)h(ar)o
  2577. (gument)270 1332 y(can)20 b(be)f(refered)g(to)g(using)h(the)f($1)h
  2578. (notation)f((if)f(there)h(were)h(furhter)e(ar)o(guments)h(the)o(y)h
  2579. (could)f(be)270 1392 y(referred)13 b(to)i(by)f($2,)h($3,)h(.)7
  2580. b(.)g(.)g().)25 b Fr(my)p 889 1392 V 17 w(exists(int4))14
  2581. b Ft(returns)g(the)g(number)g(of)g(tuples)h(from)e(table)270
  2582. 1452 y Fr(sells)19 b Ft(where)f(the)h(attrib)o(ute)f
  2583. Fr(sno)h Ft(is)h(equal)f(to)f(the)h(gi)o(v)o(en)g(ar)o(gument)g($1)f
  2584. (()p Fr(sno)30 b(=)f($1)p Ft().)36 b(The)270 1512 y(ke)o(yword)12
  2585. b Fr(language)29 b('sql')13 b Ft(tells)h(PostgreSQL)f(that)h(the)f(ne)o
  2586. (w)h(function)e(is)i(a)g(query)f(language)270 1572 y(function.)345
  2587. 1631 y(The)e(query)f(in)g(the)h(second)g(step)g(e)o(xamines)g(e)o(v)o
  2588. (ery)f(tuple)h(from)e(table)i Fr(supplier)f Ft(and)g(checks)i(if)270
  2589. 1691 y(it)f(sati02es)g(the)g(gi)o(v)o(en)g(quali02cation.)j(It)d
  2590. (does)g(so)g(by)g(taking)g(the)f(supplier)h(id)g Fr(sno)f
  2591. Ft(of)h(e)o(v)o(ery)f(tuple)h(and)270 1751 y(gi)o(ving)g(it)i(as)f(an)h
  2592. (ar)o(gument)e(to)i(the)f(function)f Fr(my)p 1127 1751
  2593. V 18 w(exists(int4))p Ft(.)j(In)e(other)g(words)g(the)g(function)270
  2594. 1811 y Fr(my)p 333 1811 V 18 w(exists(int4))17 b Ft(is)h(called)h
  2595. (once)f(for)g(e)o(v)o(ery)g(tuple)g(of)g(table)g Fr(supplier)p
  2596. Ft(.)33 b(The)19 b(function)270 1870 y(returns)10 b(the)h(number)f(of)h
  2597. (tuples)g(ha)o(ving)f(the)h(gi)o(v)o(en)f(supplier)h(id)g
  2598. Fr(sno)f Ft(contained)h(in)f(table)h Fr(sells)p Ft(.)k(A)270
  2599. 1930 y(result)c(of)f(zero)h(means)h(that)f(no)g(such)g(tuple)g(is)g(a)o
  2600. (v)o(ailable)g(meaning)g(that)f(the)h(corresponding)g(supplier)270
  2601. 1990 y(does)i(not)g(sell)g(a)g(single)g(part.)k(W)l(e)c(can)h(see)f
  2602. (that)g(this)g(query)f(is)i(semantically)e(equi)o(v)o(alent)g(to)h(the)
  2603. g(one)270 2050 y(gi)o(v)o(en)f(in)g(e)o(xample)h(2.3.)270
  2604. 2155 y Fn(Example)g(2.6)25 b Ft(This)13 b(e)o(xample)f(sho)o(ws)h(ho)o
  2605. (w)f(to)g(use)h(a)g Fp(composite)f(type)h Ft(in)f(a)g(function)g
  2606. (de02nition.)270 2274 y(Imagine)21 b(that)g(the)h(price)f(of)g(e)o(v)
  2607. o(ery)g(part)g(was)h(doubled)f(o)o(v)o(er)h(night.)42
  2608. b(If)21 b(you)h(want)e(to)i(look)f(at)270 2334 y(the)d(part)f(table)h
  2609. (with)f(the)h(ne)o(w)g(v)o(alues)f(you)h(could)g(use)g(the)g(follo)o
  2610. (wing)e(function)h(which)g(uses)i(the)270 2394 y Fp(composite)12
  2611. b(type)h Fr(part)f Ft(for)f(its)i(ar)o(gument:)330 2474
  2612. y Fr(testdb=>)29 b(create)g(function)g(new_price(part))f(returns)h
  2613. (float)330 2534 y(testdb->)g(as)g('select)h($1.price)f(*)g(2;')h
  2614. (language)f('sql';)330 2594 y(CREATE)330 2654 y(testdb=>)g(select)g
  2615. (pno,)g(pname,)h(new_price(price))e(as)h(new_price)330
  2616. 2713 y(testdb->)g(from)g(part;)330 2773 y(pno)g(|)60
  2617. b(pname)f(|)h(new_price)330 2833 y(----+---------+-----------)360
  2618. 2893 y(1)f(|)h(Screw)f(|)269 b(20)360 2952 y(2)59 b(|)h(Nut)119
  2619. b(|)269 b(16)360 3012 y(3)59 b(|)h(Bolt)89 b(|)269 b(30)360
  2620. 3072 y(4)59 b(|)h(Cam)119 b(|)269 b(50)330 3132 y((4)29
  2621. b(rows))330 3251 y(testdb=>)270 3332 y Ft(Note)12 b(that)h(this)g
  2622. (could)f(ha)o(v)o(e)h(been)g(done)f(by)g(a)h(normal)f(query)g
  2623. ((without)g(using)g(a)h(user)g(de02ned)f(func-)270
  2624. 3391 y(tion))g(as)g(well)h(b)o(ut)f(it')m(s)g(an)h(easy)g(to)f
  2625. (understand)g(e)o(xample)g(for)g(the)g(usage)h(of)f(functions.)p
  2626. eop
  2627. %%Page: 35 35
  2628. 35 34 bop 198 60 a Fm(2.5.)29 b(SOME)12 b(OF)h(POSTGRESQL)-5
  2629. b('S)12 b(SPECIAL)h(FEA)-6 b(TURES)14 b(IN)e(DET)-5 b(AIL)340
  2630. b Ft(35)198 234 y Fn(Pr)o(ogramming)13 b(Language)f(Functions)198
  2631. 328 y Ft(PostgreSQL)h(also)g(supports)g Fp(user)g(de02ned)g
  2632. (functions)g Ft(written)f(in)h(C.)g(This)h(is)f(a)g(v)o(ery)g(po)o
  2633. (werful)f(fea-)198 387 y(ture)18 b(because)h(you)g(can)f(add)h(an)o(y)g
  2634. (function)e(that)i(can)f(be)h(formulated)e(in)i(C.)g(F)o(or)f(e)o
  2635. (xample)h(Post-)198 447 y(greSQL)c(lacks)h(the)f(function)f
  2636. Fr(sqrt())g Ft(b)o(ut)h(it)g(can)h(be)f(easily)g(added)h(using)f(a)g
  2637. (programming)f(lan-)198 507 y(guage)e(function.)198 626
  2638. y Fn(Example)h(2.7)25 b Ft(W)l(e)18 b(sho)o(w)g(ho)o(w)g(to)g(realize)g
  2639. (the)g(user)g(de02ned)g(function)f Fr(pg)p 1594 626
  2640. 15 2 v 18 w(my)p 1672 626 V 18 w(sqrt(int4))p Ft(.)198
  2641. 686 y(The)c(implementation)e(can)i(be)f(di)o(vided)g(into)g(three)g
  2642. (steps:)273 785 y Fo(17)25 b Ft(formulating)10 b(the)j(ne)o(w)f
  2643. (function)f(in)h(C)273 885 y Fo(17)25 b Ft(compiling)11
  2644. b(and)h(linking)g(it)g(to)g(a)h(shared)f(library)273
  2645. 984 y Fo(17)25 b Ft(making)11 b(the)i(ne)o(w)f(function)f(kno)o(wn)h
  2646. (to)g(PostgreSQL)198 1093 y Fn(F)o(ormulating)g(the)g(New)g(Function)f
  2647. (in)h(C:)25 b Ft(W)l(e)16 b(create)g(a)h(ne)o(w)e(02le)h(called)g
  2648. Fr(sqrt.c)g Ft(and)g(add)g(the)323 1153 y(follo)o(wing)10
  2649. b(lines:)382 1272 y Fr(#include)29 b(<postgres.h>)382
  2650. 1332 y(#include)g(<utils/palloc.h>)382 1392 y(#include)g(<math.h>)382
  2651. 1511 y(int4)h(pg_my_sqrt(int4)e(arg1))382 1571 y({)442
  2652. 1631 y(return)h((ceil(sqrt(arg1)));)382 1691 y(})323
  2653. 1810 y Ft(The)17 b(function)g Fr(pg)p 664 1810 V 18 w(my)p
  2654. 742 1810 V 17 w(sqrt())g Ft(takes)h(one)f(ar)o(gument)g(of)g(type)g
  2655. Fr(int4)g Ft(which)g(is)h(a)g(Post-)323 1870 y(greSQL)i(type)g
  2656. (de02ned)h(in)f Fr(postgres.h)f Ft(and)i(returns)f(the)h(inte)o(ger)f
  2657. (v)o(alue)g(ne)o(xt)h(to)f(the)323 1929 y(square)c(root)g(of)g(the)g
  2658. (ar)o(gument.)27 b(As)17 b(with)f Fp(query)h(language)d(functions)i
  2659. Ft((see)h(pre)o(vious)f(sec-)323 1989 y(tion))c(the)h(ar)o(guments)g
  2660. (can)g(be)h(of)e Fp(base)i Ft(or)f(of)f Fp(composite)i(type)p
  2661. Ft(.)k(Special)13 b(care)g(must)g(be)h(taken)323 2049
  2662. y(when)d(using)g Fp(base)h(types)g Ft(that)f(are)h(lar)o(ger)e(than)i
  2663. (four)e(bytes)i(in)f(length.)k(PostgreSQL)c(supports)323
  2664. 2109 y(three)h(types)g(of)g(passing)h(a)g(v)o(alue)f(to)g(the)g(user)h
  2665. (de02ned)f(function:)382 2208 y Fo(17)25 b Ft(pass)13
  2666. b(by)g(v)o(alue,)f(02x)o(ed)h(length)382 2288 y Fo(17)25
  2667. b Ft(pass)13 b(by)g(reference,)f(02x)o(ed)g(length)382
  2668. 2367 y Fo(17)25 b Ft(pass)13 b(by)g(reference,)f(v)o(ariable)f
  2669. (length)323 2467 y(Only)k(data)h(types)g(that)g(are)g(1,)h(2)f(or)f(4)h
  2670. (bytes)g(in)g(length)g(can)g(be)g Fp(passed)g(by)g(value)p
  2671. Ft(.)27 b(W)l(e)16 b(just)323 2527 y(gi)o(v)o(e)d(an)g(e)o(xample)g
  2672. (for)g(the)g(usage)h(of)f Fp(base)g(types)h Ft(that)f(can)h(be)f(used)h
  2673. (for)e Fp(pass)i(by)g(value)f Ft(here.)323 2586 y(F)o(or)j(information)
  2674. g(on)h(ho)o(w)g(to)g(use)h(types)f(that)g(require)g Fp(pass)h(by)f(r)n
  2675. (efer)n(ence)i Ft(or)e(ho)o(w)g(to)g(use)323 2646 y Fp(composite)12
  2676. b(types)h Ft(refer)e(to)h([LOCK98].)198 2746 y Fn(Compiling)g(and)f
  2677. (Linking)h(It)g(to)g(a)h(Shar)o(ed)e(Library:)25 b Ft(PostgreSQL)14
  2678. b(binds)i(the)f(ne)o(w)g(function)f(to)323 2805 y(the)f(runtime)g
  2679. (system)i(by)f(using)g(a)g(shared)g(library)f(containing)g(the)h
  2680. (function.)20 b(Therefore)13 b(we)323 2865 y(ha)o(v)o(e)i(to)g(create)g
  2681. (a)g(shared)g(library)f(out)g(of)h(the)g(object02le(s))f
  2682. (containing)g(the)h(function(s).)23 b(It)323 2925 y(depends)18
  2683. b(on)f(the)h(system)g(and)g(the)f(compiler)g(ho)o(w)h(this)f(can)h(be)g
  2684. (done.)32 b(On)18 b(a)g(Linux)f(ELF)323 2985 y(system)12
  2685. b(using)h Fr(gcc)f Ft(it)g(can)h(be)f(done)g(by)h(using)f(the)g(follo)o
  2686. (wing)f(commands:)382 3104 y Fr($)30 b(gcc)g(-I$PGROOT/include)e(-fpic)
  2687. h(-c)59 b(sqrt.c)30 b(-o)f(sqrt.o)382 3164 y($)h(gcc)g(-shared)f
  2688. (sqrt.o)g(-o)h(sqrt.so)323 3283 y Ft(where)17 b Fr($PGROOT)g
  2689. Ft(is)g(the)h(path)f(PostgreSQL)g(was)h(installed)f(to.)31
  2690. b(The)18 b(important)e(options)323 3342 y(gi)o(v)o(en)11
  2691. b(to)g Fr(gcc)g Ft(here)g(are)g Fr(-fpic)g Ft(in)g(the)g(02rst)g
  2692. (line)g(which)g(tells)g Fr(gcc)g Ft(to)g(produce)g Fp(position)g(in-)
  2693. 323 3402 y(dependent)e(code)h Ft(that)g(can)g(be)g(loaded)g(to)f(an)o
  2694. (y)h(address)h(of)e(the)h(process)g(image)g(and)g Fr(-shared)p
  2695. eop
  2696. %%Page: 36 36
  2697. 36 35 bop 270 60 a Ft(36)307 b Fm(CHAPTER)14 b(2.)28
  2698. b(POSTGRESQL)13 b(FR)n(OM)f(THE)i(USER'S)e(POINT)g(OF)g(VIEW)395
  2699. 234 y Ft(in)g(the)g(second)h(line)g(telling)f Fr(gcc)g
  2700. Ft(to)g(produce)h(a)f(shared)h(library)m(.)i(If)d(you)g(got)h(another)f
  2701. (system)395 294 y(where)k(the)g(abo)o(v)o(e)h(described)f(steps)h(do)f
  2702. (not)g(work)g(you)g(will)g(ha)o(v)o(e)g(to)h(refer)e(to)h(the)g(manual)
  2703. 395 354 y(pages)i(of)g(your)g(c-compiler)f((often)g
  2704. Fr(man)30 b(cc)p Ft())18 b(and)g(your)f(linker)h(()p
  2705. Fr(man)29 b(ld)p Ft())17 b(to)i(see)f(ho)o(w)395 413
  2706. y(shared)12 b(libraries)g(can)g(be)h(b)o(uilt.)270 599
  2707. y Fn(Making)f(the)f(New)i(Function)e(Known)g(to)h(P)o(ostgr)o(eSQL:)25
  2708. b Ft(No)o(w)f(we)g(ha)o(v)o(e)g(to)g(tell)f(PostgreSQL)395
  2709. 659 y(about)18 b(the)g(ne)o(w)h(function.)34 b(W)l(e)18
  2710. b(do)h(so)g(by)f(using)h(the)g Fr(create)29 b(function)18
  2711. b Ft(command)395 719 y(within)11 b Fr(psql)h Ft(as)h(we)g(did)f(for)f
  2712. Fp(query)i(language)e(functions)p Ft(:)454 924 y Fr(testdb=>)29
  2713. b(create)h(function)f(pg_my_sqrt(int4))f(returns)h(int4)454
  2714. 984 y(testdb->)g(as)h('/<where_ever_you_put_it>/sqrt.)o(so')454
  2715. 1044 y(testdb->)f(language)g('c';)454 1103 y(CREATE)454
  2716. 1163 y(testdb=>)395 1369 y Ft(From)13 b(no)o(w)h(on)g(the)g(function)f
  2717. Fr(pg)p 998 1369 15 2 v 18 w(my)p 1076 1369 V 17 w(sqrt(int4))h
  2718. Ft(can)g(be)g(used)h(in)f(e)o(v)o(ery)g(query)m(.)20
  2719. b(Here)395 1429 y(is)12 b(a)h(query)f(against)g(table)g
  2720. Fr(part)g Ft(using)h(the)f(ne)o(w)g(function:)454 1634
  2721. y Fr(testdb=>)29 b(select)h(pname,)f(price,)g(pg_my_sqrt(price))454
  2722. 1694 y(testdb->)g(from)h(part)454 1754 y(testdb->)f(where)h
  2723. (pg_my_sqrt(price))e(<)h(10;)454 1813 y(pname)149 b
  2724. (|price|pg_my_sqrt)454 1873 y(----------+-----+----------)454
  2725. 1933 y(Screw)g(|)60 b(10)30 b(|)239 b(4)454 1993 y(Nut)209
  2726. b(|)90 b(8)30 b(|)239 b(3)454 2053 y(Bolt)179 b(|)60
  2727. b(15)30 b(|)239 b(4)454 2112 y(Cam)209 b(|)60 b(25)30
  2728. b(|)239 b(5)454 2172 y((4)30 b(rows))454 2292 y(testdb=>)270
  2729. 2552 y Fh(2.5.3)59 b(User)15 b(De02ned)g(T)l(ypes)270
  2730. 2687 y Ft(Adding)10 b(a)g(ne)o(w)g(data)h(type)f(to)g(PostgreSQL)g
  2731. (also)h(requires)e(the)i(de02nition)e(of)h(an)g Fp(input)g
  2732. Ft(and)g(an)h Fp(output)270 2746 y(function)p Ft(.)19
  2733. b(These)c(functions)e(are)g(implemented)g(using)h(the)f(techniques)h
  2734. (presented)g(in)f(the)h(pre)o(vious)270 2806 y(section)f
  2735. Fp(Pr)n(ogr)o(amming)f(Language)f(Functions)p Ft(.)16
  2736. b(The)d(functions)f(determine)f(ho)o(w)h(the)h(type)f(appears)270
  2737. 2866 y(in)19 b(strings)g((for)f(input)h(by)g(the)g(user)g(and)g
  2738. (output)g(to)g(the)g(user))g(and)g(ho)o(w)g(the)g(type)g(is)h(or)o
  2739. (ganized)270 2926 y(in)g(memory)m(.)36 b(The)20 b(input)g(function)f
  2740. (takes)g(a)h(null-delimited)e(character)h(string)h(as)g(its)g(input)f
  2741. (and)270 2986 y(returns)14 b(the)g(internal)g((in)f(memory))g
  2742. (representation)h(of)g(the)g(type.)22 b(The)15 b(output)e(function)h
  2743. (takes)g(the)270 3045 y(internal)d(representation)g(of)g(the)g(type)h
  2744. (and)f(returns)g(a)h(null)f(delimited)g(character)g(string.)k(Besides)e
  2745. (the)270 3105 y(de02nition)c(of)g Fp(input)h Ft(and)f
  2746. Fp(output)h(functions)f Ft(it)h(is)g(often)f(necessary)i(to)e(enhance)i
  2747. (operators)e((e.g.)16 b Fr('+')p Ft())270 3165 y(and)10
  2748. b(aggre)o(gate)g(functions)f(for)h(the)g(ne)o(w)g(data)g(type.)15
  2749. b(Ho)o(w)9 b(this)h(is)h(done)f(is)g(described)g(in)g(section)g(2.5.4)
  2750. 270 3225 y Fp(Extending)i(Oper)o(ators)h Ft(and)g(section)f(2.5.5)h
  2751. Fp(Extending)g(Aggr)n(e)n(gates)p Ft(.)p eop
  2752. %%Page: 37 37
  2753. 37 36 bop 198 60 a Fm(2.5.)29 b(SOME)12 b(OF)h(POSTGRESQL)-5
  2754. b('S)12 b(SPECIAL)h(FEA)-6 b(TURES)14 b(IN)e(DET)-5 b(AIL)340
  2755. b Ft(37)198 234 y Fn(Example)13 b(2.8)25 b Ft(Suppose)13
  2756. b(we)h(want)f(to)g(de02ne)h(a)g(comple)o(x)f(type)g(which)h
  2757. (represents)f(comple)o(x)h(num-)198 294 y(bers.)i(Therefore)c(we)g
  2758. (create)h(a)f(ne)o(w)g(02le)g(called)h Fr(complex.c)e
  2759. Ft(with)h(the)h(follo)o(wing)e(contents:)258 381 y Fr(#include)29
  2760. b(<postgres.h>)258 441 y(#include)g(<utils/palloc.h>)258
  2761. 500 y(#include)g(<math.h>)258 620 y(/*)g(Type)h(definition)f(of)g
  2762. (Complex)g(*/)258 680 y(typedef)g(struct)g(Complex)g({)377
  2763. 739 y(double)179 b(x;)377 799 y(double)g(y;)258 859 y(})30
  2764. b(Complex;)258 979 y(/*)f(Input)h(function:)f(takes)g(a)h(char)f
  2765. (string)g(of)h(the)g(from)288 1038 y(*)f('x,y')h(as)f(argument)g(where)
  2766. h(x)g(and)f(y)h(must)f(be)h(string)288 1098 y(*)f(representations)g(of)
  2767. g(double)h(numbers.)f(It)g(returns)g(a)288 1158 y(*)g(pointer)h(to)f
  2768. (an)h(instance)f(of)h(structure)e(Complex)i(that)288
  2769. 1218 y(*)f(is)h(setup)f(with)h(the)f(given)h(x)g(and)f(y)h(values.)f
  2770. (*/)258 1277 y(Complex)g(*)258 1337 y(complex_in(char)f(*str))258
  2771. 1397 y({)318 1457 y(double)h(x,)g(y;)318 1517 y(Complex)g(*result;)318
  2772. 1636 y(/*)g(scan)h(the)f(input)h(string)f(and)g(set)h(x)g(and)f(y)h(to)
  2773. g(the)347 1696 y(*)g(corresponding)f(double)g(numbers)g(*/)318
  2774. 1756 y(if)g((sscanf(str,)g(")h(()f(45lf)h(,)g(45lf)f()",)h(&x,)
  2775. f(&y))h(!=)g(2))f({)377 1815 y(elog(ERROR,)g("complex_in:)g(error)g
  2776. (in)h(parsing");)377 1875 y(return)g(NULL;)318 1935
  2777. y(})318 1995 y(/*)f(reserve)g(memory)h(for)f(the)h(Complex)f(data)g
  2778. (structure)347 2055 y(*)h(Note:)g(we)f(use)h(palloc)f(here)g(because)h
  2779. (the)f(memory)347 2114 y(*)h(allocated)f(using)g(palloc)h(is)f(freed)h
  2780. (automatically)347 2174 y(*)g(by)g(PostgreSQL)f(when)g(it)h(is)f(not)h
  2781. (used)f(any)h(more)f(*/)318 2234 y(result)g(=)h((Complex)f
  2782. (*)palloc(sizeof(Complex));)318 2294 y(result->x)f(=)i(x;)318
  2783. 2353 y(result->y)e(=)i(y;)318 2413 y(return)f((result);)258
  2784. 2473 y(})258 2593 y(/*)g(Output)h(Function)f(*/)258 2652
  2785. y(/*)g(Takes)h(a)g(pointer)f(to)g(an)h(instance)f(of)h(structure)f
  2786. (Complex)288 2712 y(*)g(as)h(argument)f(and)h(returns)f(a)h(character)e
  2787. (pointer)i(to)f(a)288 2772 y(*)g(string)h(representation)e(of)i(the)f
  2788. (given)h(argument)f(*/)258 2832 y(char)g(*)258 2891 y
  2789. (complex_out(Complex)f(*complex))258 2951 y({)318 3011