internals.ps
上传用户:blenddy
上传日期:2007-01-07
资源大小:6495k
文件大小:626k
- %!PS-Adobe-2.0
- %%Creator: dvipsk 5.58f Copyright 1986, 1994 Radical Eye Software
- %%Title: diplarb.dvi
- %%Pages: 117
- %%PageOrder: Ascend
- %%BoundingBox: 0 0 596 842
- %%DocumentFonts: Times-Roman Courier Times-Bold Times-Italic
- %%DocumentPaperSizes: A4
- %%EndComments
- %DVIPSCommandLine: dvips diplarb.dvi
- %DVIPSParameters: dpi=360, comments removed
- %DVIPSSource: TeX output 1998.11.29:1121
- %%BeginProcSet: tex.pro
- /TeXDict 250 dict def TeXDict begin /N{def}def /B{bind def}N /S{exch}N
- /X{S N}B /TR{translate}N /isls false N /vsize 11 72 mul N /hsize 8.5 72
- mul N /landplus90{false}def /@rigin{isls{[0 landplus90{1 -1}{-1 1}
- ifelse 0 0 0]concat}if 72 Resolution div 72 VResolution div neg scale
- isls{landplus90{VResolution 72 div vsize mul 0 exch}{Resolution -72 div
- hsize mul 0}ifelse TR}if Resolution VResolution vsize -72 div 1 add mul
- TR[matrix currentmatrix{dup dup round sub abs 0.00001 lt{round}if}
- forall round exch round exch]setmatrix}N /@landscape{/isls true N}B
- /@manualfeed{statusdict /manualfeed true put}B /@copies{/#copies X}B
- /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{
- /nn 8 dict N nn begin /FontType 3 N /FontMatrix fntrx N /FontBBox FBB N
- string /base X array /BitMaps X /BuildChar{CharBuilder}N /Encoding IE N
- end dup{/foo setfont}2 array copy cvx N load 0 nn put /ctr 0 N[}B /df{
- /sf 1 N /fntrx FMat N df-tail}B /dfs{div /sf X /fntrx[sf 0 0 sf neg 0 0]
- N df-tail}B /E{pop nn dup definefont setfont}B /ch-width{ch-data dup
- length 5 sub get}B /ch-height{ch-data dup length 4 sub get}B /ch-xoff{
- 128 ch-data dup length 3 sub get sub}B /ch-yoff{ch-data dup length 2 sub
- get 127 sub}B /ch-dx{ch-data dup length 1 sub get}B /ch-image{ch-data
- dup type /stringtype ne{ctr get /ctr ctr 1 add N}if}B /id 0 N /rw 0 N
- /rc 0 N /gp 0 N /cp 0 N /G 0 N /sf 0 N /CharBuilder{save 3 1 roll S dup
- /base get 2 index get S /BitMaps get S get /ch-data X pop /ctr 0 N ch-dx
- 0 ch-xoff ch-yoff ch-height sub ch-xoff ch-width add ch-yoff
- setcachedevice ch-width ch-height true[1 0 0 -1 -.1 ch-xoff sub ch-yoff
- .1 sub]{ch-image}imagemask restore}B /D{/cc X dup type /stringtype ne{]}
- if nn /base get cc ctr put nn /BitMaps get S ctr S sf 1 ne{dup dup
- length 1 sub dup 2 index S get sf div put}if put /ctr ctr 1 add N}B /I{
- cc 1 add D}B /bop{userdict /bop-hook known{bop-hook}if /SI save N @rigin
- 0 0 moveto /V matrix currentmatrix dup 1 get dup mul exch 0 get dup mul
- add .99 lt{/QV}{/RV}ifelse load def pop pop}N /eop{SI restore userdict
- /eop-hook known{eop-hook}if showpage}N /@start{userdict /start-hook
- known{start-hook}if pop /VResolution X /Resolution X 1000 div /DVImag X
- /IE 256 array N 0 1 255{IE S 1 string dup 0 3 index put cvn put}for
- 65781.76 div /vsize X 65781.76 div /hsize X}N /p{show}N /RMat[1 0 0 -1 0
- 0]N /BDot 260 string N /rulex 0 N /ruley 0 N /v{/ruley X /rulex X V}B /V
- {}B /RV statusdict begin /product where{pop product dup length 7 ge{0 7
- getinterval dup(Display)eq exch 0 4 getinterval(NeXT)eq or}{pop false}
- ifelse}{false}ifelse end{{gsave TR -.1 .1 TR 1 1 scale rulex ruley false
- RMat{BDot}imagemask grestore}}{{gsave TR -.1 .1 TR rulex ruley scale 1 1
- false RMat{BDot}imagemask grestore}}ifelse B /QV{gsave newpath transform
- round exch round exch itransform moveto rulex 0 rlineto 0 ruley neg
- rlineto rulex neg 0 rlineto fill grestore}B /a{moveto}B /delta 0 N /tail
- {dup /delta X 0 rmoveto}B /M{S p delta add tail}B /b{S p tail}B /c{-4 M}
- 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{
- 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{
- 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
- a}B /bos{/SS save N}B /eos{SS restore}B end
- %%EndProcSet
- %%BeginFont: Times-Roman
- % @@psencodingfile@{
- % author = "S. Rahtz, P. MacKay, Alan Jeffrey, B. Horn, K. Berry",
- % version = "0.6",
- % date = "22 June 1996",
- % filename = "8r.enc",
- % email = "kb@@mail.tug.org",
- % address = "135 Center Hill Rd. // Plymouth, MA 02360",
- % codetable = "ISO/ASCII",
- % checksum = "119 662 4424",
- % docstring = "Encoding for TrueType or Type 1 fonts to be used with TeX."
- % @}
- %
- % Idea is to have all the characters normally included in Type 1 fonts
- % available for typesetting. This is effectively the characters in Adobe
- % Standard Encoding + ISO Latin 1 + extra characters from Lucida.
- %
- % Character code assignments were made as follows:
- %
- % (1) the Windows ANSI characters are almost all in their Windows ANSI
- % positions, because some Windows users cannot easily reencode the
- % fonts, and it makes no difference on other systems. The only Windows
- % ANSI characters not available are those that make no sense for
- % typesetting -- rubout (127 decimal), nobreakspace (160), softhyphen
- % (173). quotesingle and grave are moved just because it's such an
- % irritation not having them in TeX positions.
- %
- % (2) Remaining characters are assigned arbitrarily to the lower part
- % of the range, avoiding 0, 10 and 13 in case we meet dumb software.
- %
- % (3) Y&Y Lucida Bright includes some extra text characters; in the
- % hopes that other PostScript fonts, perhaps created for public
- % consumption, will include them, they are included starting at 0x12.
- %
- % (4) Remaining positions left undefined are for use in (hopefully)
- % upward-compatible revisions, if someday more characters are generally
- % available.
- %
- % (5) hyphen appears twice for compatibility with both ASCII and Windows.
- %
- /TeXBase1Encoding [
- % 0x00 (encoded characters from Adobe Standard not in Windows 3.1)
- /.notdef /dotaccent /fi /fl
- /fraction /hungarumlaut /Lslash /lslash
- /ogonek /ring /.notdef
- /breve /minus /.notdef
- % These are the only two remaining unencoded characters, so may as
- % well include them.
- /Zcaron /zcaron
- % 0x10
- /caron /dotlessi
- % (unusual TeX characters available in, e.g., Lucida Bright)
- /dotlessj /ff /ffi /ffl
- /.notdef /.notdef /.notdef /.notdef
- /.notdef /.notdef /.notdef /.notdef
- % very contentious; it's so painful not having quoteleft and quoteright
- % at 96 and 145 that we move the things normally found there down to here.
- /grave /quotesingle
- % 0x20 (ASCII begins)
- /space /exclam /quotedbl /numbersign
- /dollar /percent /ampersand /quoteright
- /parenleft /parenright /asterisk /plus /comma /hyphen /period /slash
- % 0x30
- /zero /one /two /three /four /five /six /seven
- /eight /nine /colon /semicolon /less /equal /greater /question
- % 0x40
- /at /A /B /C /D /E /F /G /H /I /J /K /L /M /N /O
- % 0x50
- /P /Q /R /S /T /U /V /W
- /X /Y /Z /bracketleft /backslash /bracketright /asciicircum /underscore
- % 0x60
- /quoteleft /a /b /c /d /e /f /g /h /i /j /k /l /m /n /o
- % 0x70
- /p /q /r /s /t /u /v /w
- /x /y /z /braceleft /bar /braceright /asciitilde
- /.notdef % rubout; ASCII ends
- % 0x80
- /.notdef /.notdef /quotesinglbase /florin
- /quotedblbase /ellipsis /dagger /daggerdbl
- /circumflex /perthousand /Scaron /guilsinglleft
- /OE /.notdef /.notdef /.notdef
- % 0x90
- /.notdef /.notdef /.notdef /quotedblleft
- /quotedblright /bullet /endash /emdash
- /tilde /trademark /scaron /guilsinglright
- /oe /.notdef /.notdef /Ydieresis
- % 0xA0
- /.notdef % nobreakspace
- /exclamdown /cent /sterling
- /currency /yen /brokenbar /section
- /dieresis /copyright /ordfeminine /guillemotleft
- /logicalnot
- /hyphen % Y&Y (also at 45); Windows' softhyphen
- /registered
- /macron
- % 0xD0
- /degree /plusminus /twosuperior /threesuperior
- /acute /mu /paragraph /periodcentered
- /cedilla /onesuperior /ordmasculine /guillemotright
- /onequarter /onehalf /threequarters /questiondown
- % 0xC0
- /Agrave /Aacute /Acircumflex /Atilde /Adieresis /Aring /AE /Ccedilla
- /Egrave /Eacute /Ecircumflex /Edieresis
- /Igrave /Iacute /Icircumflex /Idieresis
- % 0xD0
- /Eth /Ntilde /Ograve /Oacute
- /Ocircumflex /Otilde /Odieresis /multiply
- /Oslash /Ugrave /Uacute /Ucircumflex
- /Udieresis /Yacute /Thorn /germandbls
- % 0xE0
- /agrave /aacute /acircumflex /atilde
- /adieresis /aring /ae /ccedilla
- /egrave /eacute /ecircumflex /edieresis
- /igrave /iacute /icircumflex /idieresis
- % 0xF0
- /eth /ntilde /ograve /oacute
- /ocircumflex /otilde /odieresis /divide
- /oslash /ugrave /uacute /ucircumflex
- /udieresis /yacute /thorn /ydieresis
- ] def
- %%EndFont
- %%BeginProcSet: texps.pro
- TeXDict begin /rf{findfont dup length 1 add dict begin{1 index /FID ne 2
- index /UniqueID ne and{def}{pop pop}ifelse}forall[1 index 0 6 -1 roll
- exec 0 exch 5 -1 roll VResolution Resolution div mul neg 0 0]/Metrics
- exch def dict begin Encoding{exch dup type /integertype ne{pop pop 1 sub
- dup 0 le{pop}{[}ifelse}{FontMatrix 0 get div Metrics 0 get div def}
- ifelse}forall Metrics /Metrics currentdict end def[2 index currentdict
- end definefont 3 -1 roll makefont /setfont load]cvx def}def
- /ObliqueSlant{dup sin S cos div neg}B /SlantFont{4 index mul add}def
- /ExtendFont{3 -1 roll mul exch}def /ReEncodeFont{/Encoding exch def}def
- end
- %%EndProcSet
- %%BeginProcSet: special.pro
- TeXDict begin /SDict 200 dict N SDict begin /@SpecialDefaults{/hs 612 N
- /vs 792 N /ho 0 N /vo 0 N /hsc 1 N /vsc 1 N /ang 0 N /CLIP 0 N /rwiSeen
- false N /rhiSeen false N /letter{}N /note{}N /a4{}N /legal{}N}B
- /@scaleunit 100 N /@hscale{@scaleunit div /hsc X}B /@vscale{@scaleunit
- div /vsc X}B /@hsize{/hs X /CLIP 1 N}B /@vsize{/vs X /CLIP 1 N}B /@clip{
- /CLIP 2 N}B /@hoffset{/ho X}B /@voffset{/vo X}B /@angle{/ang X}B /@rwi{
- 10 div /rwi X /rwiSeen true N}B /@rhi{10 div /rhi X /rhiSeen true N}B
- /@llx{/llx X}B /@lly{/lly X}B /@urx{/urx X}B /@ury{/ury X}B /magscale
- true def end /@MacSetUp{userdict /md known{userdict /md get type
- /dicttype eq{userdict begin md length 10 add md maxlength ge{/md md dup
- length 20 add dict copy def}if end md begin /letter{}N /note{}N /legal{}
- N /od{txpose 1 0 mtx defaultmatrix dtransform S atan/pa X newpath
- clippath mark{transform{itransform moveto}}{transform{itransform lineto}
- }{6 -2 roll transform 6 -2 roll transform 6 -2 roll transform{
- itransform 6 2 roll itransform 6 2 roll itransform 6 2 roll curveto}}{{
- closepath}}pathforall newpath counttomark array astore /gc xdf pop ct 39
- 0 put 10 fz 0 fs 2 F/|______Courier fnt invertflag{PaintBlack}if}N
- /txpose{pxs pys scale ppr aload pop por{noflips{pop S neg S TR pop 1 -1
- scale}if xflip yflip and{pop S neg S TR 180 rotate 1 -1 scale ppr 3 get
- ppr 1 get neg sub neg ppr 2 get ppr 0 get neg sub neg TR}if xflip yflip
- not and{pop S neg S TR pop 180 rotate ppr 3 get ppr 1 get neg sub neg 0
- TR}if yflip xflip not and{ppr 1 get neg ppr 0 get neg TR}if}{noflips{TR
- pop pop 270 rotate 1 -1 scale}if xflip yflip and{TR pop pop 90 rotate 1
- -1 scale ppr 3 get ppr 1 get neg sub neg ppr 2 get ppr 0 get neg sub neg
- TR}if xflip yflip not and{TR pop pop 90 rotate ppr 3 get ppr 1 get neg
- sub neg 0 TR}if yflip xflip not and{TR pop pop 270 rotate ppr 2 get ppr
- 0 get neg sub neg 0 S TR}if}ifelse scaleby96{ppr aload pop 4 -1 roll add
- 2 div 3 1 roll add 2 div 2 copy TR .96 dup scale neg S neg S TR}if}N /cp
- {pop pop showpage pm restore}N end}if}if}N /normalscale{Resolution 72
- div VResolution 72 div neg scale magscale{DVImag dup scale}if 0 setgray}
- N /psfts{S 65781.76 div N}N /startTexFig{/psf$SavedState save N userdict
- maxlength dict begin /magscale true def normalscale currentpoint TR
- /psf$ury psfts /psf$urx psfts /psf$lly psfts /psf$llx psfts /psf$y psfts
- /psf$x psfts currentpoint /psf$cy X /psf$cx X /psf$sx psf$x psf$urx
- psf$llx sub div N /psf$sy psf$y psf$ury psf$lly sub div N psf$sx psf$sy
- scale psf$cx psf$sx div psf$llx sub psf$cy psf$sy div psf$ury sub TR
- /showpage{}N /erasepage{}N /copypage{}N /p 3 def @MacSetUp}N /doclip{
- psf$llx psf$lly psf$urx psf$ury currentpoint 6 2 roll newpath 4 copy 4 2
- roll moveto 6 -1 roll S lineto S lineto S lineto closepath clip newpath
- moveto}N /endTexFig{end psf$SavedState restore}N /@beginspecial{SDict
- begin /SpecialSave save N gsave normalscale currentpoint TR
- @SpecialDefaults count /ocount X /dcount countdictstack N}N /@setspecial
- {CLIP 1 eq{newpath 0 0 moveto hs 0 rlineto 0 vs rlineto hs neg 0 rlineto
- closepath clip}if ho vo TR hsc vsc scale ang rotate rwiSeen{rwi urx llx
- sub div rhiSeen{rhi ury lly sub div}{dup}ifelse scale llx neg lly neg TR
- }{rhiSeen{rhi ury lly sub div dup scale llx neg lly neg TR}if}ifelse
- CLIP 2 eq{newpath llx lly moveto urx lly lineto urx ury lineto llx ury
- lineto closepath clip}if /showpage{}N /erasepage{}N /copypage{}N newpath
- }N /@endspecial{count ocount sub{pop}repeat countdictstack dcount sub{
- end}repeat grestore SpecialSave restore end}N /@defspecial{SDict begin}
- N /@fedspecial{end}B /li{lineto}B /rl{rlineto}B /rc{rcurveto}B /np{
- /SaveX currentpoint /SaveY X N 1 setlinecap newpath}N /st{stroke SaveX
- SaveY moveto}N /fil{fill SaveX SaveY moveto}N /ellipse{/endangle X
- /startangle X /yrad X /xrad X /savematrix matrix currentmatrix N TR xrad
- yrad scale 0 0 1 startangle endangle arc savematrix setmatrix}N end
- %%EndProcSet
- TeXDict begin 39158280 55380996 1000 360 360 (diplarb.dvi)
- @start /Fa 1 106 df<0C0E0C00000000305898983030606464683007127D910D>105
- D E /Fb 4 96 df<70000000000EF8000000001FF8000000001FF8000000001FF8000000
- 001FF8000000001FF8000000001FF8000000001FF8000000001FF8000000001FF8000000
- 001FF8000000001FF8000000001FF8000000001FF8000000001FF8000000001FF8000000
- 001FF8000000001FF8000000001FF8000000001FF8000000001FF8000000001FF8000000
- 001FF8000000001FF8000000001FF8000000001FF8000000001FF8000000001FF8000000
- 001FF8000000001FF8000000001FF8000000001FF8000000001FF8000000001FF8000000
- 001FF8000000001FF8000000001FF8000000001FF8000000001FF8000000001FF8000000
- 001FF8000000001FF8000000001FF8000000001FF8000000001FF8000000001FF8000000
- 001FF8000000001FF8000000001FF8000000001FFC000000003F7C000000003E7C000000
- 003E7E000000007E3E000000007C3F00000000FC1F00000000F81F80000001F80FC00000
- 03F00FE0000007F007F000000FE003F800001FC001FE00007F8000FF8001FF00007FF00F
- FE00003FFFFFFC00000FFFFFF0000007FFFFE0000000FFFF000000001FF8000030467D7F
- 37>91 D<00001FF800000000FFFF00000007FFFFE000000FFFFFF000003FFFFFFC00007F
- F00FFE0000FF8001FF0001FE00007F8003F800001FC007F000000FE00FE0000007F00FC0
- 000003F01F80000001F81F00000000F83F00000000FC3E000000007C7E000000007E7C00
- 0000003E7C000000003EFC000000003FF8000000001FF8000000001FF8000000001FF800
- 0000001FF8000000001FF8000000001FF8000000001FF8000000001FF8000000001FF800
- 0000001FF8000000001FF8000000001FF8000000001FF8000000001FF8000000001FF800
- 0000001FF8000000001FF8000000001FF8000000001FF8000000001FF8000000001FF800
- 0000001FF8000000001FF8000000001FF8000000001FF8000000001FF8000000001FF800
- 0000001FF8000000001FF8000000001FF8000000001FF8000000001FF8000000001FF800
- 0000001FF8000000001FF8000000001FF8000000001FF8000000001FF8000000001FF800
- 0000001FF8000000001FF8000000001FF8000000001FF8000000001FF8000000001FF800
- 0000001FF8000000001FF8000000001FF8000000001F70000000000E30467D7F37>I<00
- 0001C00000000003C00000000007E00000000007E00000000007E0000000000FF0000000
- 000FF0000000000FF0000000001FF8000000001FF8000000001FF8000000003FFC000000
- 003E7C000000003E7C000000007E7E000000007C3E000000007C3E00000000FC3F000000
- 00F81F00000000F81F00000001F81F80000001F00F80000001F00F80000003F00FC00000
- 03E007C0000003E007C0000007E007E0000007C003E0000007C003E000000FC003F00000
- 0F8001F000000F8001F000001F8001F800001F0000F800001F0000F800003F0000FC0000
- 3E00007C00003E00007C00007E00007E00007C00003E00007C00003E0000FC00003F0000
- F800001F0000F800001F0001F800001F8001F000000F8001F000000F8003F000000FC003
- E0000007C003E0000007C007E0000007E007C0000003E007C0000003E00FC0000003F00F
- 80000001F00F80000001F01F80000001F81F00000000F81F00000000F83F00000000FC3E
- 000000007C3E000000007C7E000000007E7C000000003E7C000000003EFC000000003FF8
- 000000001FF8000000001FF8000000001F70000000000E30467D7F37>94
- D<70000000000EF8000000001FF8000000001FF8000000001FFC000000003F7C00000000
- 3E7C000000003E7E000000007E3E000000007C3E000000007C3F00000000FC1F00000000
- F81F00000000F81F80000001F80F80000001F00F80000001F00FC0000003F007C0000003
- E007C0000003E007E0000007E003E0000007C003E0000007C003F000000FC001F000000F
- 8001F000000F8001F800001F8000F800001F0000F800001F0000FC00003F00007C00003E
- 00007C00003E00007E00007E00003E00007C00003E00007C00003F0000FC00001F0000F8
- 00001F0000F800001F8001F800000F8001F000000F8001F000000FC003F0000007C003E0
- 000007C003E0000007E007E0000003E007C0000003E007C0000003F00FC0000001F00F80
- 000001F00F80000001F81F80000000F81F00000000F81F00000000FC3F000000007C3E00
- 0000007C3E000000007E7E000000003E7C000000003E7C000000003FFC000000001FF800
- 0000001FF8000000001FF8000000000FF0000000000FF0000000000FF00000000007E000
- 00000007E00000000007E00000000003C00000000001C0000030467D7F37>I
- E /Fc 1 49 df<060F0F0F1E1E1C3C38383870706060E0C04008127E920B>48
- D E /Fd 1 49 df<081C1C3838383070706060C0C0060D7E8D0B>48
- D E /Fe 1 50 df<C0000018E0000038F0000078F80000F8DC0001D8CE000398C7000718
- C3800E18C1C01C18C0E03818C0707018C038E018C01DC018C00F8018C00F8018C01DC018
- C038E018C0707018C0E03818C1C01C18C3800E18C7000718CE000398DC0001D8F80000F8
- F0000078E0000038C00000181D1C7D9E24>49 D E /Ff 27 120
- df<60F0F06004047C830C>58 D<60F0F07010101020204040040B7C830C>I<0000300000
- 007000000078000000F8000001F8000001F800000378000003780000067800000E780000
- 0C780000187C0000183C0000303C0000603C0000603C0000FFFC0000FFFC0001803C0003
- 003C0003003E0006001E000E001E007F80FFC0FF81FFC01A197E981E>65
- D<07FFFE0007FFFF8000F007C000F003C000F001E000F001E001E001C001E003C001E007
- 8001E00F0003C03E0003FFF80003C01E0003C00F00078007800780078007800780078007
- 800F000F000F000F000F003E000F007C00FFFFF000FFFFC0001B187E971E>I<000FE040
- 003FF8C000F81DC001E00780078007800F0003801E0003801C0003003C00030078000300
- 78000000F0000000F0000000F0000000F0000000F0000000E0000C00E0000C00F0001800
- F000180070003000780060003C00C0001F0380000FFF000003F800001A1A7D981D>I<07
- FFFE0007FFFF8000F003E000F000F000F0007000F0007801E0007801E0003801E0003801
- E0003803C0007803C0007803C0007803C00078078000F0078000F0078001E0078001C00F
- 0003C00F0007800F000E000F007C00FFFFF000FFFFC0001D187E9721>I<07FFFFE007FF
- FFE000F001E000F000C000F000C000F000C001E000C001E030C001E030C001E0700003C0
- 600003FFE00003FFE00003C0E0000780C1800780C1800780C300078003000F0006000F00
- 06000F001E000F007C00FFFFFC00FFFFF8001B187E971D>I<03FFC003FF800078000078
- 0000780000780000F00000F00000F00000F00001E00001E00001E00001E00003C00003C0
- 0003C00003C0000780000780000780000780007FF000FFF00012187E9712>73
- D<07FF8007FF8000F00000F00000F00000F00001E00001E00001E00001E00003C00003C0
- 0003C00003C00007800C07800C07800C0780180F00180F00380F00700F01F0FFFFE0FFFF
- E016187E971B>76 D<07FC0003FC07FC0007FC00FC000FC000DE000FC000DE001BC000DE
- 0033C0019E003780019E006780019E00C780018F00C780030F018F00030F030F00030F03
- 0F00030F060F00060F0C1E0006078C1E000607981E000607B01E000C07B03C000C07E03C
- 000C07C03C001C03C03C00FF8383FF80FF8303FF8026187E9726>I<07F801FF07FC01FF
- 00FC003800FE003000DE003000CF0030018F006001878060018780600183C0600303E0C0
- 0301E0C00301F0C00300F0C00600F9800600798006007D8006003D800C003F000C001F00
- 0C000F001C000F00FF800600FF80060020187E9720>I<07FFFC0007FFFF0000F0078000
- F003C000F001C000F001C001E003C001E003C001E003C001E0078003C00F0003C01E0003
- FFF80003C00000078000000780000007800000078000000F0000000F0000000F0000000F
- 000000FFE00000FFE000001A187E9719>80 D<07FFF80007FFFE0000F00F0000F0078000
- F0038000F003C001E0078001E0078001E0070001E00E0003C0380003FFE00003C0700003
- C0380007803C0007803C0007803C0007803C000F0078000F0078000F0078600F007860FF
- E078C0FFE0388000000F001B197E971E>82 D<001F84007FCC01E0FC0380380300380700
- 380700380F00300F00000F800007F00007FE0003FF8000FFC0001FC00003E00001E00000
- E03000E06001C06001C0700380700300FC0E00CFFC0083F000161A7D9818>I<1FFFFFC0
- 1FFFFFC03C0F03C0300F0180700F0180600F0180601E0180C01E0180C01E0180001E0000
- 003C0000003C0000003C0000003C00000078000000780000007800000078000000F00000
- 00F0000000F0000000F000003FFF00003FFF00001A187E9718>I<FFE03FE0FFE03FE01E
- 0007001E0006001E0006001E0006003C000C003C000C003C000C003C000C007800180078
- 0018007800180078001800F0003000F0003000F0003000F0006000F0006000F000C000F0
- 01C000700380003C0E00001FFC000007F000001B197D971B>I<03FF87FC03FF87FC003C
- 03C0003E0300001E0600001F0E00000F1C00000FB800000FF0000007E0000007C0000003
- C0000003E0000007E000000DF0000018F0000030F0000060F80000C0780001807C000300
- 3C000F003E00FFC0FFC0FFC1FFC01E187E9721>88 D<07980C781878303870386070E070
- E070E070C0E1C0E3C0E3C1E663E43C38100F7D8E16>97 D<03E00E301878307870706000
- E000E000E000C000C000C010603060E01F800D0F7D8E12>99 D<03E00E30181830187030
- E070FFC0E000E000E000E000E010603030E01F800D0F7D8E13>101
- D<018003C003800380000000000000000000001C0027004700C700C7000E000E001C001C
- 001C4038C038C0398039001E000A187E970E>105 D<001C001C003C0018000000000000
- 0000000001E0033006380C380C38007000700070007000E000E000E000E001C001C001C0
- 01C06380F380F700E60078000E1F7F9710>I<1F801F8007000700070007000E000E000E
- 000E0E1C371C4F1C8F1D063A003F003BC038E070E170E370E370E6E064603810187D9715
- >I<3C1F00666380478180C781C0C701C00E03800E03800E03800E07001C07081C07181C
- 0E181C0E303806601803C0150F7E8E19>110 D<3C7C66C7478FC70FC7060E000E000E00
- 0E001C001C001C001C0038001800100F7E8E12>114 D<03E00C300878187818701F001F
- E00FF003F06030F030F030E06060C03F000D0F7D8E13>I<1E0183002303878063038380
- C7038380C7038380070703000E0703000E0703000E0703001C0E06001C0E06001C0E0400
- 0C0E08000617180003E1E000190F7E8E1D>119 D E /Fg 4 62 df<03000F00FF00F700
- 07000700070007000700070007000700070007000700070007000700070007000700FFF0
- FFF00C177D9614>49 D<0F803FE070F06078F83CF83CF83C703C003C00380078007000E0
- 01C0038003000600080C100C201C7FF8FFF8FFF80E177E9614>I<0F801FE038F0707078
- 78787878783078007000E001C00F8000E000700038003C703CF83CF83CF838707870F03F
- E00F800E187E9614>I<FFFFFF80FFFFFF80000000000000000000000000000000000000
- 000000000000FFFFFF80FFFFFF80190A7E8D1F>61 D E /Fh 133[27
- 30 30 43 30 33 20 23 27 1[33 30 33 50 17 33 1[17 33 30
- 20 27 33 27 33 30 9[60 43 43 40 33 43 47 37 47 43 56
- 40 2[23 47 47 37 40 43 43 1[43 8[30 30 30 30 30 30 30
- 30 2[15 20 15 2[20 20 37[33 2[{ TeXBase1Encoding ReEncodeFont }58
- 60.000002 /Times-Bold rf /Fi 133[32 36 36 52 36 40 24
- 28 32 1[40 36 40 60 20 2[20 40 36 24 32 40 32 40 36 9[72
- 1[52 48 40 52 56 44 56 1[68 48 2[28 56 56 44 48 52 52
- 1[52 8[36 36 36 36 36 36 36 36 1[20 18 1[18 4[24 39[{
- TeXBase1Encoding ReEncodeFont }53 71.999969 /Times-Bold
- rf /Fj 139[34 1[46 1[57 7[57 2[46 3[52 29[75 15[52 52
- 52 49[{ TeXBase1Encoding ReEncodeFont }10 103.700026
- /Times-Bold rf /Fk 43 123 df<07FFFFC00FFFFFC01FFFFFC0383060006070C000C0
- 60C000C060C0000060C00000E1C00000C1C00001C1C00001C1C00001C1C0000381C00003
- 81C0000781E0000701E0000F01E0000F01F0000E00F0000C00E0001A157F941C>25
- D<007FFF8001FFFF8003FFFF800783C0000F01C0001E01E0003C01E0003C01E0007801E0
- 007801E0007801E000F003C000F003C000F003C000F0078000F0070000700F0000700E00
- 00301800001870000007C0000019157E941C>27 D<78FCFCFCFC7806067C850E>58
- D<78FCFCFEFE7A0202020404040810204007107C850E>I<0000000C0000003C000000F0
- 000003C000000F0000003C000000F0000003C000000F0000003C000000F0000003C00000
- 0F0000003C000000F0000000F00000003C0000000F00000003C0000000F00000003C0000
- 000F00000003C0000000F00000003C0000000F00000003C0000000F00000003C0000000C
- 1E1E7C9A27>I<C0000000F00000003C0000000F00000003C0000000F00000003C000000
- 0F00000003C0000000F00000003C0000000F00000003C0000000F00000003C0000003C00
- 0000F0000003C000000F0000003C000000F0000003C000000F0000003C000000F0000003
- C000000F0000003C000000F0000000C00000001E1E7C9A27>62 D<000001C000000001C0
- 00000003C000000003C000000007C00000000FC00000000FC00000001FC00000001FE000
- 000037E000000033E000000063E0000000C3E0000000C3E000000183E000000183E00000
- 0303E000000703E000000603E000000C03E000000C03F000001801F000001801F000003F
- FFF000007FFFF000006001F00000C001F00000C001F000018001F000038001F000030001
- F000070001F8001F0001F800FFE01FFF80FFC01FFF8021237EA225>65
- D<00FFFFFC0000FFFFFF000007C00FC00007C003C0000F8003E0000F8001E0000F8001F0
- 000F8001F0001F0001E0001F0003E0001F0003E0001F0007C0003E000780003E001F0000
- 3E003E00003E00F800007FFFF000007C003C00007C001E00007C001F0000F8000F0000F8
- 000F0000F8000F8000F8000F8001F0000F0001F0001F0001F0001F0001F0003E0003E000
- 7C0003E0007C0003E001F80007E007E000FFFFFFC000FFFFFE000024227FA126>I<0000
- 7F00C00003FFC180000FC0E380001F003380007C001F8000F0000F0001E0000F0003C000
- 0F000780000F000F800006000F000006001F000006003E000006003E00000C007C000000
- 007C000000007C00000000F800000000F800000000F800000000F800000000F800000000
- F000000000F000003000F000003000F000006000F800006000F80000C000780000C00078
- 000180003C000300001E000600000F001C000007C070000003FFE00000007F0000002224
- 7DA224>I<00FFFFFC0000FFFFFF800007C00FC00007C003E0000F8001F0000F8000F000
- 0F800078000F800078001F000078001F00007C001F00007C001F00007C003E00007C003E
- 00007C003E00007C003E00007C007C000078007C0000F8007C0000F8007C0000F800F800
- 01F000F80001F000F80001E000F80003E001F00003C001F000078001F0000F8001F0000F
- 0003E0001E0003E0007C0003E000F00007E007E000FFFFFF8000FFFFFC000026227FA129
- >I<00FFFFFFF000FFFFFFF00007C001F00007C000F0000F800070000F800070000F8000
- 60000F800060001F000060001F006060001F006060001F006060003E00C000003E00C000
- 003E03C000003FFFC000007FFF8000007C038000007C038000007C03800000F803000000
- F80300C000F80300C000F800018001F000018001F000030001F000030001F000070003E0
- 00060003E0000E0003E0003C0007E000FC00FFFFFFFC00FFFFFFF80024227FA125>I<00
- FFFFFFE000FFFFFFE00007C003E00007C001E0000F8000E0000F8000E0000F8000C0000F
- 8000C0001F0000C0001F0000C0001F00C0C0001F00C0C0003E018000003E018000003E03
- 8000003E078000007FFF0000007FFF0000007C070000007C07000000F806000000F80600
- 0000F806000000F806000001F000000001F000000001F000000001F000000003E0000000
- 03E000000003E000000007E0000000FFFF800000FFFF00000023227EA120>I<007FFE00
- FFFE0007C00007C0000F80000F80000F80000F80001F00001F00001F00001F00003E0000
- 3E00003E00003E00007C00007C00007C00007C0000F80000F80000F80000F80001F00001
- F00001F00001F00003E00003E00003E00007E0007FFE00FFFE0017227FA116>73
- D<00FFFF0000FFFF000007C0000007C000000F8000000F8000000F8000000F8000001F00
- 00001F0000001F0000001F0000003E0000003E0000003E0000003E0000007C0000007C00
- 00007C0000007C000000F8000000F8000C00F8000C00F8001801F0001801F0001801F000
- 3001F0003003E0007003E000E003E003E007E00FE0FFFFFFC0FFFFFFC01E227FA122>76
- D<00FFE00003FF8000FFE00003FF800007E00007F0000007E0000DF000000DE0000FE000
- 000DE0001BE000000DE0001BE000000DE00033E0000019E00067C0000019E00067C00000
- 18F000C7C0000018F000C7C0000030F0018F80000030F0030F80000030F0030F80000030
- F0060F80000060F0061F00000060F00C1F00000060F0181F0000006078181F000000C078
- 303E000000C078303E000000C078603E000000C078C03E0000018078C07C000001807980
- 7C0000018079807C000001807B007C000003007E00F8000003003E00F8000003003C00F8
- 00000F803C01F80000FFF0383FFF8000FFF0303FFF800031227EA130>I<007FE001FFC0
- 00FFE003FFC00007F0003C000007F0003800000DF0003000000DF8003000000CF8003000
- 000CFC00300000187C00600000187C00600000183E00600000183E00600000303F00C000
- 00301F00C00000301F80C00000300F80C00000600F81800000600FC18000006007C18000
- 006007E1800000C003E3000000C003E3000000C001F3000000C001F30000018001FE0000
- 018000FE0000018000FE00000180007E00000300007C00000300007C00000300003C0000
- 0F80003C00007FF000180000FFF0001800002A227FA128>I<00007F00000003C1E00000
- 0E007000003C0038000078001C0000E0001E0001E0000E0003C0000F000780000F000F00
- 000F000F00000F801E00000F803E00000F803E00000F807C00000F807C00000F807C0000
- 0F80F800001F00F800001F00F800001F00F800001E00F800003E00F000003E00F000007C
- 00F000007C00F00000F800F00000F000F80001F000780003E000780003C0003800078000
- 3C000E00001E001C00000F007800000381E0000000FF00000021247DA226>I<00FFFFFC
- 0000FFFFFF000007C00F800007C003C0000F8003E0000F8001E0000F8001E0000F8001E0
- 001F0003E0001F0003E0001F0003E0001F0003C0003E0007C0003E000780003E000F0000
- 3E001E00007C00F800007FFFE000007C000000007C00000000F800000000F800000000F8
- 00000000F800000001F000000001F000000001F000000001F000000003E000000003E000
- 000003E000000007E0000000FFFE000000FFFE00000023227FA120>I<00FFFFF00000FF
- FFFC000007C03F000007C00F80000F8007C0000F8003C0000F8003C0000F8003C0001F00
- 07C0001F0007C0001F0007C0001F000F80003E000F00003E001E00003E007800003E01E0
- 00007FFF0000007C03C000007C01E000007C00F00000F800F80000F800F80000F800F800
- 00F800F80001F001F00001F001F00001F001F00001F001F00003E003E00003E003E06003
- E003E06007E001E0C0FFFE01E0C0FFFE00F1800000003E0023237EA126>82
- D<0001F8180007FE30001E0770003C01F0007801F000F000E000E000E001E000E001E000
- E003E000C003E000C003E0000003E0000003F0000003FF000001FFE00001FFF80000FFFC
- 00007FFE00000FFE000000FE0000003F0000001F0000001F0000001F0030001E0030001E
- 0030001E0030001C0070003C0078003800780070007C00E000EF03C000C3FF800080FE00
- 001D247DA21F>I<1FFFFFFF1FFFFFFF1F01F01F3C01F0073803E0073003E0077003E006
- 6003E0066007C006C007C006C007C006C007C006000F8000000F8000000F8000000F8000
- 001F0000001F0000001F0000001F0000003E0000003E0000003E0000003E0000007C0000
- 007C0000007C0000007C000000F8000000F8000000F8000001F80000FFFFE000FFFFE000
- 20227EA11D>I<3FFF00FFE07FFF01FFE003E0001E0003E0001C0007C000180007C00018
- 0007C000180007C00018000F800030000F800030000F800030000F800030001F00006000
- 1F000060001F000060001F000060003E0000C0003E0000C0003E0000C0003E0000C0007C
- 000180007C000180007C000180007C000180007800030000F80003000078000600007800
- 06000078000C000078001800003C003000001E00E000000F03C0000007FF00000001FC00
- 000023237EA122>I<007FFE0FFF007FFE0FFF0007F003F00003E001C00003F003800003
- F007000001F00E000001F80C000000F818000000FC30000000FC600000007CC00000007F
- 800000007F800000003F000000003F000000001F000000001F800000003F800000006F80
- 000000CFC00000018FC000000387C000000707E000000E03E000000C03F000001803F000
- 003001F000006001F80000C001F80001C000F80007C001FC00FFF00FFFC0FFF00FFFC028
- 227FA129>88 D<007C6001C6F00303F00601E00E01E01C01E03C01E03803C07803C07803
- C07803C0F00780F00780F00784F00786F00F0C700F0C701F083037181867100F81E01715
- 7E941A>97 D<01E0003FC0003FC00003C00003C0000780000780000780000780000F0000
- 0F00000F00000F00001E00001E7C001EC6001F03003E03803C03C03C03C03C03C07803C0
- 7803C07803C07803C0F00780F00780F00780F00F00F00E00701E00701C00303800186000
- 0F800012237EA215>I<003F0000E1800381C00703C00E07C01C07C03C03803C00007800
- 00780000780000F00000F00000F00000F000007000407000C03001803807001C1C0007F0
- 0012157E9416>I<00000F0001FE0001FE00001E00001E00003C00003C00003C00003C00
- 00780000780000780000780000F0007CF001C6F00303F00601E00E01E01C01E03C01E038
- 03C07803C07803C07803C0F00780F00780F00784F00786F00F0C700F0C701F0830371818
- 67100F81E018237EA21A>I<007E000383000701800E01801C0180380180780300700600
- FFF800F00000F00000E00000E00000E00000E00000E00080E00180700300300E00183800
- 0FE00011157D9417>I<007000F800F800F000E000000000000000000000000000000000
- 0F00118021C061C0C3C0C3C0C3C0078007800F000F000F001E001E101E183C303C303C60
- 384018C00F000D227FA111>105 D<0078000FF0000FF00000F00000F00001E00001E000
- 01E00001E00003C00003C00003C00003C00007800007807807818C07821C0F043C0F087C
- 0F107C0F20381EC0001F00001FF0001E3C003C1E003C1E003C0F083C0F0C781E18781E18
- 781E10780E30F006206003C016237EA21A>107 D<00F00FE01FE001E001E003C003C003
- C003C007800780078007800F000F000F000F001E001E001E001E003C003C003C003C0078
- 007800788078C0F180F180F180730073001C000C237EA20F>I<1E03F000338C380063D8
- 1C0063E01E00C3E01E00C3C01E00C3C01E0007803C0007803C0007803C0007803C000F00
- 78000F0078000F00F0400F00F0601E00F0C01E01E0C01E01E1801E00E1003C00E2001800
- 3C001B157F941E>110 D<003F0000E1C00380E00700700E00701C00783C00783C007878
- 0078780078780078F000F0F000F0F000E0F001E07001C0700380300700380E001C3C0007
- E00015157E9418>I<03C0F80006718C000C7E06000C7C07001878078018780780187807
- 8000F0078000F0078000F0078000F0078001E00F0001E00F0001E00F0001E01E0003C01C
- 0003C03C0003E0380003E0700007B0C000078F000007800000078000000F0000000F0000
- 000F0000000F0000001E0000001E000000FFE00000FFE00000191F819419>I<007C1001
- C6700303F00601E00E01E01C01E03C01E03803C07803C07803C07803C0F00780F00780F0
- 0780F00780F00F00700F00701F00303F00187E000F9E00001E00001E00003C00003C0000
- 3C00003C0000780000780007FF8007FF80141F7E9416>I<1F078033984063F0E063E1E0
- C3C3E0C3C3E0C3C1C00780000780000780000780000F00000F00000F00000F00001E0000
- 1E00001E00001E00003C000018000013157F9416>I<007E0000C3000181800303800707
- 8007078007020007E00007FC0007FE0003FF0001FF80001F80300780780780F80700F807
- 00F00600600C003038000FE00011157E9417>I<00E001E001E001E001E003C003C003C0
- 03C00780FFFCFFFC07800F000F000F000F001E001E001E001E003C003C003C083C0C7818
- 78107830386038C00F000E1F7F9E12>I<0F807019C0F031E0F861E078C1E038C1E038C3
- C03803C0300780300780300780300F00600F00600F00400F00C00F00800F01800F010007
- 0200038C0001F00015157F9418>118 D<0F80180E19C03C1E31E03C1F61E0780FC1E078
- 07C1E07807C3C0780703C0F0060780F0060780F0060780F0060F01E00C0F01E00C0F01E0
- 0C0F01E0180F01E0180F01E0100F03E0200702E060038470C000F81F0020157F9424>I<
- 03E0F00C3318183E1C303E3C203C7C603C7C603C3800780000780000780000780000F000
- 00F00000F00830F00C79E018F9E018F9E030F360606230C03C1F0016157E941C>I<0F80
- 0C19C01E31E01E61E03CC1E03CC1E03CC3C03C03C0780780780780780780780F00F00F00
- F00F00F00F00F00F01E00F01E00F01E00703E0030FC001F3C00003C00003C00007803C07
- 007C0F007C0E00781C0060380030E0001F8000171F7F9418>I<00E03003F03007F86007
- FFC00C01800C0300000600000C0000180000300000600000C0000180000300400600600C
- 00C01803C03FFF8071FF0060FE00C0780014157E9417>I E /Fl
- 14 94 df<00200040008001800300060006000E000C001C001800380038003800700070
- 0070007000F000F000F000F000F000F000F000F000F000F000F000F000F000F000700070
- 007000700038003800380018001C000C000E0006000600030001800080004000200B327C
- A413>40 D<800040002000300018000C000C000E0006000700030003800380038001C001
- C001C001C001E001E001E001E001E001E001E001E001E001E001E001E001E001E001C001
- C001C001C00380038003800300070006000E000C000C00180030002000400080000B327D
- A413>I<0001800000018000000180000001800000018000000180000001800000018000
- 0001800000018000000180000001800000018000000180000001800000018000FFFFFFFF
- FFFFFFFF0001800000018000000180000001800000018000000180000001800000018000
- 000180000001800000018000000180000001800000018000000180000001800020227D9C
- 27>43 D<01F800070E000E07001C03803C03C03801C07801E07801E07801E07801E0F801
- F0F801F0F801F0F801F0F801F0F801F0F801F0F801F0F801F0F801F0F801F0F801F0F801
- F0F801F07801E07801E07801E07801E03C03C03C03C01C03800E0700070E0001F8001422
- 7EA019>48 D<00C001C007C0FFC0FBC003C003C003C003C003C003C003C003C003C003C0
- 03C003C003C003C003C003C003C003C003C003C003C003C003C003C003C003C0FFFFFFFF
- 10217CA019>I<03F8000FFE001C1F803007C06003C06003E0F801E0FC01F0FC01F0FC01
- F07801F03001F00001E00003E00003E00007C0000780000F00000E00001C000038000070
- 0000E0000180000300300600300400300800701000603FFFE07FFFE0FFFFE0FFFFE01421
- 7EA019>I<01F8000FFE001E0F803807C03803C07C03E07C03E07C03E03C03E01803E000
- 03C0000780000780000E00001C0003F800000E000007800003C00003E00001E00001F000
- 01F03001F07801F0FC01F0FC01F0FC01E0F803E06003C03007801C0F000FFE0003F80014
- 227EA019>I<000180000380000380000780000F80001F80001780003780006780004780
- 00C7800187800107800307800607800407800C0780180780300780200780600780C00780
- FFFFFCFFFFFC00078000078000078000078000078000078000078000FFFC00FFFC16217F
- A019>I<1000401E03801FFF001FFE001FFC001FF0001800001800001800001800001800
- 0018000018F8001B0E001C07001803801003C00001E00001E00001F00001F00001F07001
- F0F801F0F801F0F801F0F801E0C001E06003C07003C03807801C1F000FFC0003F0001422
- 7EA019>I<003E0000FF8003C1C00780E00F01E01E03E01C03E03C01C03C000078000078
- 0000780000F8F800F90E00FA0300FC0380FC01C0FC01E0F801E0F801F0F801F0F801F0F8
- 01F0F801F07801F07801F07801E03801E03C01E01C03C01E03800F0F0003FE0001F80014
- 227EA019>I<78FCFCFCFC7800000000000000000078FCFCFCFC7806157C940E>58
- D<FFFFFFFFFFFFFFFF000000000000000000000000000000000000000000000000000000
- 0000000000FFFFFFFFFFFFFFFF200C7D9127>61 D<FFFFC0C0C0C0C0C0C0C0C0C0C0C0C0
- C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0FFFF0831
- 7CA40E>91 D<FFFF03030303030303030303030303030303030303030303030303030303
- 0303030303030303030303030303030303FFFF08317FA40E>93 D
- E /Fm 165[30 1[36 47 36 36 30 28 33 36 28 36 36 44 30
- 2[17 36 36 28 30 36 33 1[36 8[25 25 25 25 25 25 25 25
- 1[14 12 1[12 4[17 39[{ .167 SlantFont TeXBase1Encoding ReEncodeFont }34
- 50.000002 /Times-Roman rf /Fn 105[25 27[22 25 25 36 25
- 28 17 19 22 28 28 25 28 41 14 28 1[14 28 25 17 22 28
- 22 28 25 10[36 36 33 28 36 39 30 39 36 47 33 39 25 19
- 39 39 30 33 36 36 1[36 6[17 25 25 25 25 25 25 25 25 25
- 25 14 12 1[12 2[17 17 17 36[28 2[{ TeXBase1Encoding ReEncodeFont }65
- 50.000002 /Times-Bold rf /Fo 22 111 df<FFFFFFFCFFFFFFFC1E027C8C27>0
- D<C00003E0000770000E38001C1C00380E00700700E00381C001C38000E700007E00003C
- 00003C00007E0000E70001C3800381C00700E00E00701C003838001C70000EE00007C000
- 031818799727>2 D<00C00000E00000C00000C00040C080E0C1C0F8C7C07CCF801EDE00
- 03F00000C00003F0001EDE007CCF80F8C7C0E0C1C040C08000C00000C00000E00000C000
- 12157D9619>I[<00038000000FE000000FE000000FE000000FE000000FE0000003800000
- 0000000000000000000000000000000000000000000000FFFFFFFEFFFFFFFE0000000000
- 0000000000000000000000000000000000000000038000000FE000000FE000000FE00000
- 0FE000000FE00000038000>31 28 125 153 38 I<03F0000FFC001FFE003FFF007FFF80
- 7FFF80FFFFC0FFFFC0FFFFC0FFFFC0FFFFC0FFFFC0FFFFC0FFFFC07FFF807FFF803FFF00
- 1FFE000FFC0003F00012147D9519>15 D<001FFFFC00FFFFFC01E00000078000000E0000
- 001C0000003800000030000000700000006000000060000000E0000000C0000000C00000
- 00C0000000C0000000C0000000C0000000E0000000600000006000000070000000300000
- 00380000001C0000000E0000000780000001E0000000FFFFFC001FFFFC00000000000000
- 000000000000000000000000000000000000000000000000007FFFFFFC7FFFFFFC1E287C
- 9F27>18 D<0000000C0000003C000000F0000003C000000F0000003C000000F0000003C0
- 00000F0000003C000000F0000003C000000F0000003C000000F0000000F00000003C0000
- 000F00000003C0000000F00000003C0000000F00000003C0000000F00000003C0000000F
- 00000003C0000000F00000003C0000000C00000000000000000000000000000000000000
- 00000000000000000000000000FFFFFFFCFFFFFFFC1E287C9F27>20
- D<C0000000F00000003C0000000F00000003C0000000F00000003C0000000F00000003C0
- 000000F00000003C0000000F00000003C0000000F00000003C0000003C000000F0000003
- C000000F0000003C000000F0000003C000000F0000003C000000F0000003C000000F0000
- 003C000000F0000000C00000000000000000000000000000000000000000000000000000
- 000000000000000000FFFFFFFCFFFFFFFC1E287C9F27>I<000000600000000000300000
- 0000003000000000001800000000001800000000000C0000000000060000000000030000
- FFFFFFFF8000FFFFFFFFE000000000007000000000001C00000000000F800000000003E0
- 000000000780000000001E00000000003800000000006000FFFFFFFFC000FFFFFFFF8000
- 0000000300000000000600000000000C0000000000180000000000180000000000300000
- 0000003000000000006000002B1C7D9932>41 D<001FFF00FFFF01E0000780000E00001C
- 0000380000300000700000600000600000E00000C00000C00000FFFFFFFFFFFFC00000C0
- 0000E000006000006000007000003000003800001C00000E000007800001E00000FFFF00
- 1FFF181E7C9A21>50 D<00000300000300000700000600000E00000C00001C0000180000
- 380000300000700000600000E00000C00001C0000180000380000300000700000600000E
- 00000C00001C0000180000180000380000300000700000600000E00000C00001C0000180
- 000380000300000700000600000E00000C00001C00001800003800003000007000006000
- 00E00000C00000C00000183079A300>54 D<C0000030C0000030E0000070600000607000
- 00E0300000C0300000C0380001C018000180180001801C0003800C0003000E00070007FF
- FE0007FFFE0007000E0003000C0003000C0003801C000180180001C0380000C0300000C0
- 300000E07000006060000070E0000030C0000030C0000039C0000019800000198000001F
- 8000000F0000000F000000060000000600001C2480A21D>56 D<FFFFF8FFFFF800001800
- 001800001800001800001800001800001800001800001800001800001800001800001800
- 00183FFFF87FFFF800001800001800001800001800001800001800001800001800001800
- 0018000018000018000018000018000018FFFFF8FFFFF815237DA21C>I<FFFFFFC0FFFF
- FFC0000000C0000000C0000000C0000000C0000000C0000000C0000000C0000000C00000
- 00C0000000C0000000C01A0D7D9121>I<C00000C0C00000C0C00000C0C00000C0C00000
- C0C00000C0C00000C0C00000C0C00000C0C00000C0C00000C0C00000C0C00000C0C00000
- C0C00000C0C00000C0C00000C0C00000C0C00000C0C00000C0C00000C0C00000C0C00000
- C0E00001C06000018070000380380007001C000E000F807C0003FFF000007F80001A1F7D
- 9D21>91 D<007F800003FFF0000F807C001C000E00380007007000038060000180E00001
- C0C00000C0C00000C0C00000C0C00000C0C00000C0C00000C0C00000C0C00000C0C00000
- C0C00000C0C00000C0C00000C0C00000C0C00000C0C00000C0C00000C0C00000C0C00000
- C0C00000C0C00000C0C00000C0C00000C0C00000C01A1F7D9D21>I<000C0000000C0000
- 001E0000001E0000003F00000033000000330000007380000061800000E1C00000C0C000
- 01C0E000018060000180600003807000030030000700380006001800060018000E001C00
- 0C000C001C000E00180006003800070030000300300003007000038060000180E00001C0
- C00000C0C00000C01A1F7D9D21>94 D<C00000C0C00000C0E00001C06000018070000380
- 300003003000030038000700180006001C000E000C000C000E001C000600180006001800
- 070038000300300003807000018060000180600001C0E00000C0C00000E1C00000618000
- 007380000033000000330000003F0000001E0000001E0000000C0000000C00001A1F7D9D
- 21>I<0007C0003E0000780000F00001E00001E00001E00001E00001E00001E00001E000
- 01E00001E00001E00001E00001E00001E00001E00001E00001E00001E00003C000078000
- 1F0000F800001F000007800003C00001E00001E00001E00001E00001E00001E00001E000
- 01E00001E00001E00001E00001E00001E00001E00001E00001E00001E00000F000007800
- 003E000007C012317DA419>102 D<F800001F000007800003C00001E00001E00001E000
- 01E00001E00001E00001E00001E00001E00001E00001E00001E00001E00001E00001E000
- 01E00001E00000F000007800003E000007C0003E0000780000F00001E00001E00001E000
- 01E00001E00001E00001E00001E00001E00001E00001E00001E00001E00001E00001E000
- 01E00001E00003C0000780001F0000F8000012317DA419>I<C0C0C0C0C0C0C0C0C0C0C0
- C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0
- C0C002317AA40E>106 D<C00000C00000E0000060000060000070000030000030000038
- 00001800001800001C00000C00000C00000E000006000006000007000003000003000003
- 800001800001800001C00000C00000E00000600000600000700000300000300000380000
- 1800001800001C00000C00000C00000E0000060000060000070000030000030000038000
- 01800001800001C00000C00000C012317DA419>110 D E /Fp 133[19
- 22 22 33 22 25 14 19 19 25 25 25 25 36 14 22 14 14 25
- 25 14 22 25 22 25 25 9[41 30 36 28 25 30 36 30 36 33
- 41 28 33 1[17 36 36 30 30 36 33 30 30 3[34 3[25 6[25
- 25 1[14 12 17 12 2[17 17 17 36[25 2[{ TeXBase1Encoding ReEncodeFont }60
- 50.000002 /Times-Italic rf /Fq 134[62 1[89 1[69 41 48
- 55 1[69 62 69 103 34 2[34 69 62 41 55 1[55 69 62 10[89
- 89 1[69 1[96 76 3[83 5[76 2[89 83 89 25[41 39[{
- TeXBase1Encoding ReEncodeFont }30 124.400017 /Times-Bold
- rf /Fr 119[30 10[30 30 30 30 30 30 30 30 30 30 30 30
- 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 1[30
- 1[30 30 30 1[30 30 30 30 30 30 30 30 30 30 30 30 30 30
- 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30
- 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30
- 30 30 30 30 30 30 30 33[{ TeXBase1Encoding ReEncodeFont }91
- 50.000002 /Courier rf /Fs 134[30 2[30 1[17 23 20 2[30
- 30 47 17 2[17 1[30 20 27 2[30 27 11[43 1[33 2[33 43 43
- 53 1[43 3[43 2[43 2[43 7[30 30 5[30 30 2[15 1[15 44[{
- TeXBase1Encoding ReEncodeFont }31 60.000002 /Times-Roman
- rf /Ft 87[17 19[22 25[22 25 25 36 25 25 14 19 17 25 25
- 25 25 39 14 25 14 14 25 25 17 22 25 22 25 22 3[17 1[17
- 1[36 36 47 36 36 30 28 33 36 28 36 36 44 30 36 19 17
- 36 36 28 30 36 33 33 36 1[22 1[28 1[14 14 25 25 25 25
- 25 25 25 25 25 25 14 12 17 12 28 25 17 17 17 2[25 2[17
- 29[28 28 2[{ TeXBase1Encoding ReEncodeFont }82 50.000002
- /Times-Roman rf /Fu 139[24 33 29 1[43 43 43 67 24 2[24
- 43 43 29 38 1[38 1[38 13[48 1[62 48 1[62 1[53 2[29 3[53
- 3[62 65[{ TeXBase1Encoding ReEncodeFont }23 86.399998
- /Times-Roman rf /Fv 139[20 1[24 1[36 36 1[56 20 2[20
- 3[32 2[36 32 28[52 68[{ TeXBase1Encoding ReEncodeFont }11
- 71.999969 /Times-Roman rf end
- %%EndProlog
- %%BeginSetup
- %%Feature: *Resolution 360dpi
- TeXDict begin
- %%PaperSize: A4
- %%EndSetup
- %%Page: 1 1
- 1 0 bop 907 899 a Fv(Diplomarbeit)221 1151 y Fu(Enhancement)22
- b(of)f(the)h(ANSI)f(SQL)g(Implementation)h(of)888 1260
- y(PostgreSQL)629 1492 y Ft(ausgef)t(250)-21 b(uhrt)12
- b(am)g(Institut)g(f)t(250)-21 b(ur)11 b(Informationssysteme)761
- 1552 y(der)h(T)m(echnischen)h(Uni)o(v)o(ersit)s(250)-20
- b(at)11 b(W)n(ien)860 1612 y(unter)h(der)g(Anleitung)f(v)o(on)726
- 1771 y Fs(O.Uni)o(v)l(.Prof.Dr)m(.)17 b(Geor)o(g)d(Gottlob)1061
- 1831 y Ft(und)762 1891 y Fs(Uni)o(v)l(.Ass.)k(Mag.)g(Katrin)c(Se)o(yr)
- 671 1950 y Ft(als)f(v)o(erantwortlicher)d(Uni)o(v)o(ersit)s(250)-20
- b(atsassistentin)1041 2110 y(durch)859 2269 y Fr(Stefan)29
- b(Simkovics)814 2329 y(Paul)h(Petersgasse)e(36)799 2389
- y(A)i(-)g(2384)f(Breitenfurt)244 2749 y Fs(No)o(v)o(ember)14
- b(29,)g(1998)p 244 2766 475 2 v 414 2819 a Ft(Datum)p
- 1431 2730 567 2 v 1594 2800 a(Unterschrift)p eop
- %%Page: 2 2
- 2 1 bop eop
- %%Page: 3 3
- 3 2 bop 198 633 a Fq(Abstract)198 892 y Ft(PostgreSQL)14
- b(is)i(an)f Fp(object-r)n(elational)f Ft(database)h(management)g
- (system)g(that)g(runs)f(on)h(almost)g(an)o(y)198 951
- y(UNIX)g(based)i(operating)e(system)h(and)g(is)g(distrib)o(uted)f(as)h
- (C-source)g(code.)26 b(It)15 b(is)h(neither)f Fp(fr)n(ee)o(war)n(e)198
- 1011 y Ft(nor)f Fp(public)h(domain)f Ft(software.)23
- b(It)14 b(is)h(copyrighted)e(by)i(the)g(Uni)o(v)o(ersity)f(of)h
- (California)f(b)o(ut)g(may)h(be)198 1071 y(used,)e(modi 02ed)e(and)i
- (distrib)o(uted)e(as)i(long)f(as)g(the)h(licensing)f(terms)g(of)f(the)i
- (copyright)d(are)i(accepted.)273 1131 y(As)g(the)f(name)g(already)h
- (suggests,)h(PostgreSQL)e(uses)h(an)g(e)o(xtended)f(subset)h(of)f(the)h
- (SQL92)f(stan-)198 1191 y(dard)17 b(as)i(the)f(query)f(language.)32
- b(At)18 b(the)g(time)f(of)h(writing)f(this)h(document)f(the)h(actual)g
- (v)o(ersion)g(of)198 1250 y(PostgreSQL)11 b(was)h(v6.3.2.)k(In)11
- b(this)h(v)o(ersion)g(the)f(implemented)g(part)g(of)g(SQL)h(did)f(not)h
- (support)f(some)198 1310 y(important)e(features)g(included)h(in)g(the)g
- (SQL92)g(standard.)k(T)l(wo)c(of)g(the)g(not)f(supported)h(features)f
- (were:)273 1410 y Fo( 17)25 b Ft(the)12 b Fp(having)g(clause)273
- 1509 y Fo( 17)25 b Ft(the)12 b(support)g(of)g(the)g(set)h(theoretic)f
- (operations)g Fp(intersect)g Ft(and)g Fp(e)o(xcept)198
- 1609 y Ft(It)e(was)g(the)h(author')m(s)f(task)g(to)g(add)h(the)f
- (support)g(for)g(the)g(two)f(missing)i(features)f(to)g(the)h(e)o
- (xisting)f(source)198 1669 y(code.)22 b(Before)14 b(the)g
- (implementation)g(could)g(be)g(started)h(an)f(intensi)o(v)o(e)h(study)f
- (of)g(the)g Fp(r)n(ele)o(vant)i(parts)198 1729 y(of)d(the)g(SQL92)f
- (standar)n(d)h Ft(and)g(the)g(implementation)f(of)g(the)h
- Fp(e)o(xisting)g(featur)n(es)h Ft(of)f(PostgreSQL)f(had)198
- 1788 y(been)h(necessary)m(.)19 b(This)13 b(document)g(will)g(not)g
- (present)g(only)f(the)h(results)h(of)e(the)h(implementation)f(b)o(ut)
- 198 1848 y(also)h(the)h(kno)o(wledge)e(collected)h(while)g(studying)g
- (the)g(SQL)g(language)h(and)f(the)g(source)g(code)g(of)g(the)198
- 1908 y(already)f(e)o(xisting)h(features.)273 1968 y(Chapter)i(1)h
- (presents)h(an)f(o)o(v)o(ervie)o(w)f(on)h(the)g(SQL92)g(standard.)26
- b(It)16 b(gi)o(v)o(es)g(a)g(description)g(of)f(the)198
- 2027 y Fp(r)n(elational)k(data)f(model)h Ft(and)g(the)g(theoretical)g
- ((mathematical))e(background)i(of)f(SQL.)i(Ne)o(xt)f(the)198
- 2087 y(SQL)13 b(language)g(itself)f(is)h(described.)18
- b(The)13 b(most)g(important)e(SQL)i(statements)h(are)e(presented)h(and)
- g(a)198 2147 y(lot)d(of)g(e)o(xamples)h(are)f(included)h(for)e(better)h
- (understanding.)15 b(The)c(information)d(gi)o(v)o(en)j(in)f(this)g
- (chapter)198 2207 y(has)j(mainly)f(been)g(taken)g(form)f(the)i(books)f
- ([D)n(A)-6 b(TE96)q(],)12 b([D)n(A)-6 b(TE94)q(])12 b(and)g([ULL88)q
- (].)273 2267 y(Chapter)18 b(2)g(gi)o(v)o(es)g(a)h(description)e(on)h
- (ho)o(w)g(to)g(use)h(PostgreSQL.)f(First)g(it)g(is)g(sho)o(wn)g(ho)o(w)
- g(the)198 2326 y Fp(bac)o(kend)e Ft((serv)o(er))g(can)h(be)g(started)
- g(and)f(ho)o(w)h(a)g(connection)f(from)g(a)h(client)f(to)h(the)f(serv)o
- (er)h(can)g(be)198 2386 y(established.)f(Ne)o(xt)c(some)g(basic)h
- (database)f(management)g(tasks)h(like)e(creating)g(a)h(database,)i
- (creating)198 2446 y(a)g(table)f(etc.)19 b(are)14 b(described.)19
- b(Finally)12 b(some)i(of)f(PostgreSQL)-5 b(')m(s)14 b(special)g
- (features)f(like)g Fp(user)h(de 02ned)198 2506 y(functions)p
- Ft(,)d Fp(user)h(de 02ned)f(types)p Ft(,)h(the)f Fp(rule)g(system)h
- Ft(etc.)j(are)c(presented)g(and)g(illustrated)f(using)h(a)g(lot)g(of)
- 198 2565 y(e)o(xamples.)16 b(The)d(information)d(gi)o(v)o(en)i(in)g
- (chapter)g(2)g(has)g(mainly)g(been)g(taken)f(from)g(the)h(PostgreSQL)
- 198 2625 y(documentation)17 b((see)i([LOCK98)o(]),)h(the)e
- (PostgreSQL)f(manual)h(pages)h(and)f(was)g(v)o(eri 02ed)f(by)h(the)198
- 2685 y(author)12 b(throughout)f(v)o(arious)h(e)o(xamples)h(which)f(ha)o
- (v)o(e)g(also)h(been)g(included.)273 2745 y(Chapter)h(3)g(concentrates)
- h(on)f(the)h(internal)e(structure)h(of)g(the)h(PostgreSQL)f
- Fp(bac)o(kend)p Ft(.)21 b(First)14 b(the)198 2804 y(stages)19
- b(that)g(a)g(query)f(has)h(to)f(pass)h(in)g(order)f(to)g(retrie)o(v)o
- (e)g(a)h(result)f(are)g(described)h(using)f(a)h(lot)g(of)198
- 2864 y( 02gures)h(to)f(illustrate)g(the)h(in)n(v)o(olv)o(ed)g(data)g
- (structures.)38 b(The)20 b(information)e(gi)o(v)o(en)i(in)f(that)h
- (part)g(of)198 2924 y(chapter)e(3)h(has)g(been)g(collected)g(while)f
- (intensi)o(v)o(ely)h(studying)f(the)h(source)f(code)h(of)f(the)h(rele)o
- (v)o(ant)198 2984 y(parts)13 b(of)g(PostgreSQL.)g(This)h(intensi)o(v)o
- (e)f(and)g(detailed)g(e)o(xamination)g(of)f(the)h(source)h(code)f(had)g
- (been)198 3044 y(necessary)h(to)f(be)g(able)g(to)g(add)g(the)g(missing)
- h(functionality)m(.)i(The)e(kno)o(wledge)f(gathered)f(during)g(that)198
- 3103 y(period)h(of)h(time)f(has)i(been)f(summarized)f(here)h(in)g
- (order)f(to)g(make)h(it)f(easier)i(for)e(programmers)f(who)198
- 3163 y(are)g(ne)o(w)g(to)h(PostgreSQL)f(to)g( 02nd)g(their)g(way)g
- (in.)273 3223 y(The)f(follo)o(wing)f(sections)i(co)o(v)o(er)f(the)g
- (author')m(s)g(ideas)h(for)e(the)h(implementation)f(of)h(the)g(two)f
- (miss-)198 3283 y(ing)i(SQL)h(features)f(mentioned)g(abo)o(v)o(e)g(and)
- h(a)f(description)g(of)g(the)g(implementation)g(itself.)273
- 3342 y(Section)e(3.7)h(deals)h(with)e(the)h(implementation)e(of)i(the)g
- Fp(having)f(logic)p Ft(.)15 b(As)c(mentioned)f(earlier)g(the)198
- 3402 y Fp(having)15 b(logic)f Ft(is)i(one)f(of)f(the)h(two)g(missing)g
- (SQL92)g(features)g(that)g(the)g(author)f(had)i(to)e(implement.)1086
- 3552 y(3)p eop
- %%Page: 4 4
- 4 3 bop 270 60 a Ft(4)270 234 y(The)13 b( 02rst)g(parts)g(of)f(the)h
- (chapter)f(describe)h(ho)o(w)g Fp(aggr)n(e)n(gate)f(functions)g
- Ft(are)h(realized)g(in)f(PostgreSQL)270 294 y(and)e(after)e(that)i(a)f
- (description)g(of)g(the)h(enhancements)g(applied)f(to)g(the)h(code)f
- (of)h(the)f Fp(planner/optimizer)270 354 y Ft(and)14
- b(the)f Fp(e)o(xecutor)i Ft(in)e(order)g(to)g(realize)h(the)g(ne)o(w)f
- (functionality)f(is)i(gi)o(v)o(en.)20 b(The)14 b(functions)f(and)h
- (data)270 413 y(structures)e(used)h(and)f(added)h(to)f(the)g(source)h
- (code)f(are)g(also)h(handled)f(here.)345 473 y(Section)19
- b(3.8)i(deals)g(with)e(the)i(implementation)e(of)g(the)h
- Fp(intersect)h Ft(and)f Fp(e)o(xcept)g Ft(functionality)270
- 533 y(which)d(was)h(the)f(second)h(missing)f(SQL92)g(feature)g(that)g
- (had)h(to)f(be)g(added)h(by)f(the)g(author)m(.)31 b(First)270
- 593 y(a)13 b(theoretical)f(description)g(of)g(the)h(basic)g(idea)g(is)g
- (gi)o(v)o(en.)j(The)d Fp(intersect)g Ft(and)g Fp(e)o(xcept)g
- Ft(logic)f(is)h(imple-)270 653 y(mented)i(using)f(a)i
- Fp(query)f(r)n(e)o(write)h Ft(technique)f((i.e.)23 b(a)15
- b(query)g(in)n(v)o(olving)f(an)h Fp(intersect)g Ft(and/or)f
- Fp(e)o(xcept)270 712 y Ft(operation)h(is)h Fp(r)n(e)o(written)h
- Ft(to)f(a)g(semantically)g(equi)o(v)o(alent)f(form)g(that)g(does)i(not)
- e(use)h(these)h Fp(set)f(oper)o(-)270 772 y(ations)e
- Ft(an)o(y)h(more).)21 b(After)14 b(presenting)g(the)g(basic)h(idea)g
- (the)f(changes)h(made)g(to)f(the)h Fp(parser)g Ft(and)f(the)270
- 832 y Fp(r)n(e)o(write)g(system)f Ft(are)f(described)h(and)f(the)g
- (added)h(functions)f(and)g(data)g(structures)h(are)f(presented.)p
- eop
- %%Page: 5 5
- 5 4 bop 198 633 a Fq(Contents)198 943 y Fn(1)50 b(SQL)1600
- b(9)273 1003 y Ft(1.1)52 b(The)13 b(Relational)f(Data)h(Model)27
- b(.)e(.)g(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h
- (.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)44 b(10)387 1063 y(1.1.1)61
- b(F)o(ormal)11 b(Notion)h(of)g(the)g(Relational)h(Data)f(Model)47
- b(.)25 b(.)g(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)44
- b(10)547 1123 y(Domains)12 b(vs.)k(Data)d(T)l(ypes)35
- b(.)25 b(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)
- h(.)f(.)h(.)f(.)g(.)h(.)44 b(11)273 1184 y(1.2)52 b(Operations)12
- b(in)h(the)f(Relational)g(Data)h(Model)22 b(.)k(.)f(.)g(.)h(.)f(.)g(.)h
- (.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)44 b(11)387
- 1244 y(1.2.1)61 b(Relational)12 b(Algebra)33 b(.)25 b(.)g(.)h(.)f(.)g
- (.)h(.)f(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)h(.)
- f(.)g(.)h(.)44 b(11)387 1304 y(1.2.2)61 b(Relational)12
- b(Calculus)20 b(.)25 b(.)g(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)f(.)g
- (.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)44
- b(14)547 1364 y(T)n(uple)12 b(Relational)g(Calculus)43
- b(.)25 b(.)h(.)f(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)
- f(.)h(.)f(.)g(.)h(.)44 b(14)387 1425 y(1.2.3)61 b(Relational)12
- b(Algebra)g(vs.)k(Relational)c(Calculus)43 b(.)26 b(.)f(.)g(.)h(.)f(.)g
- (.)h(.)f(.)h(.)f(.)g(.)h(.)44 b(14)273 1485 y(1.3)52
- b(The)13 b(SQL)g(Language)28 b(.)e(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h
- (.)f(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)
- g(.)h(.)44 b(14)387 1545 y(1.3.1)61 b(Select)27 b(.)e(.)h(.)f(.)h(.)f
- (.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)
- g(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)44 b(15)547 1605
- y(Simple)11 b(Selects)42 b(.)25 b(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)h
- (.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)
- 44 b(15)547 1665 y(Joins)j(.)25 b(.)h(.)f(.)h(.)f(.)g(.)h(.)f(.)g(.)h
- (.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)
- f(.)h(.)f(.)g(.)h(.)44 b(16)547 1726 y(Aggre)o(gate)12
- b(Operators)32 b(.)25 b(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)f(.)g(.)h
- (.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)44 b(17)547
- 1786 y(Aggre)o(gation)11 b(by)h(Groups)k(.)26 b(.)f(.)g(.)h(.)f(.)h(.)f
- (.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)44
- b(17)547 1846 y(Ha)o(ving)c(.)26 b(.)f(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f
- (.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)
- h(.)f(.)g(.)h(.)44 b(19)547 1906 y(Subqueries)39 b(.)26
- b(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)f(.)g(.)h
- (.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)44 b(19)547
- 1967 y(Union,)12 b(Intersect,)h(Except)39 b(.)25 b(.)g(.)h(.)f(.)h(.)f
- (.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)44
- b(20)387 2027 y(1.3.2)61 b(Data)12 b(De 02nition)27
- b(.)e(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f
- (.)g(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)44 b(21)547
- 2087 y(Create)12 b(T)l(able)48 b(.)25 b(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h
- (.)f(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)
- g(.)h(.)44 b(21)547 2147 y(Data)12 b(T)l(ypes)h(in)g(SQL)29
- b(.)c(.)g(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h
- (.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)44 b(21)547 2208 y(Create)12
- b(Inde)o(x)44 b(.)25 b(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)g
- (.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)44
- b(22)547 2268 y(Create)12 b(V)m(ie)o(w)j(.)26 b(.)f(.)g(.)h(.)f(.)g(.)h
- (.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)
- f(.)h(.)f(.)g(.)h(.)44 b(22)547 2328 y(Drop)12 b(T)l(able,)h(Drop)f
- (Inde)o(x,)g(Drop)g(V)m(ie)o(w)27 b(.)e(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f
- (.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)44 b(23)387 2388 y(1.3.3)61
- b(Data)12 b(Manipulation)36 b(.)25 b(.)g(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)
- g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)44
- b(23)547 2449 y(Insert)12 b(Into)17 b(.)25 b(.)h(.)f(.)g(.)h(.)f(.)g(.)
- h(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h
- (.)f(.)h(.)f(.)g(.)h(.)44 b(23)547 2509 y(Update)e(.)26
- b(.)f(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)f
- (.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)44
- b(24)547 2569 y(Delete)19 b(.)25 b(.)h(.)f(.)h(.)f(.)g(.)h(.)f(.)g(.)h
- (.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)
- f(.)h(.)f(.)g(.)h(.)44 b(24)387 2629 y(1.3.4)61 b(System)12
- b(Catalogs)40 b(.)26 b(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)f
- (.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)44
- b(24)387 2690 y(1.3.5)61 b(Embedded)12 b(SQL)17 b(.)25
- b(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g
- (.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)44 b(24)198 2800
- 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)
- f(of)g(V)n(iew)778 b(26)273 2860 y Ft(2.1)52 b(A)13 b(Short)e(History)h
- (of)g(PostgreSQL)k(.)26 b(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)f(.)g(.)h
- (.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)44 b(26)273
- 2920 y(2.2)52 b(An)13 b(Ov)o(ervie)o(w)e(on)i(the)f(Features)g(of)g
- (PostgreSQL)49 b(.)26 b(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)h(.)f
- (.)g(.)h(.)44 b(26)273 2981 y(2.3)52 b(Where)12 b(to)h(Get)f
- (PostgreSQL)46 b(.)25 b(.)g(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)f(.)g
- (.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)44
- b(27)547 3041 y(Copyright)11 b(of)h(PostgreSQL)48 b(.)25
- b(.)h(.)f(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)h
- (.)f(.)g(.)h(.)44 b(27)547 3101 y(Support)11 b(for)g(PostgreSQL)39
- b(.)25 b(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)
- h(.)f(.)h(.)f(.)g(.)h(.)44 b(27)273 3161 y(2.4)52 b(Ho)o(w)12
- b(to)h(use)f(PostgreSQL)i(.)25 b(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)h(.)
- f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)44
- b(28)387 3222 y(2.4.1)61 b(Starting)11 b(The)i(Postmaster)44
- b(.)25 b(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)
- h(.)f(.)h(.)f(.)g(.)h(.)44 b(28)387 3282 y(2.4.2)61 b(Creating)12
- b(a)g(Ne)o(w)h(Database)k(.)25 b(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)f(.)g(.)
- h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)44 b(28)387
- 3342 y(2.4.3)61 b(Connecting)12 b(T)l(o)h(a)f(Database)38
- b(.)25 b(.)h(.)f(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)
- f(.)h(.)f(.)g(.)h(.)44 b(29)387 3402 y(2.4.4)61 b(De 02ning)11
- b(and)i(Populating)e(T)l(ables)45 b(.)26 b(.)f(.)g(.)h(.)f(.)g(.)h(.)f
- (.)g(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)44 b(29)1086
- 3552 y(5)p eop
- %%Page: 6 6
- 6 5 bop 270 60 a Ft(6)1515 b Fm(CONTENTS)459 234 y Ft(2.4.5)61
- b(Retrie)o(ving)11 b(Data)i(From)e(The)i(Database)27
- b(.)e(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)44
- b(30)345 294 y(2.5)52 b(Some)12 b(of)g(PostgreSQL)-5
- b(')m(s)13 b(Special)f(Features)g(in)g(Detail)41 b(.)25
- b(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)44
- b(31)459 354 y(2.5.1)61 b(Inheritance)36 b(.)26 b(.)f(.)g(.)h(.)f(.)g
- (.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)
- h(.)f(.)h(.)f(.)g(.)h(.)44 b(31)459 413 y(2.5.2)61 b(User)12
- b(De 02ned)g(Functions)g(.)26 b(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)f(.)
- g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)44
- b(33)619 473 y(Query)12 b(Language)g((SQL))g(Functions)28
- b(.)d(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h
- (.)44 b(33)619 533 y(Programming)10 b(Language)j(Functions)18
- b(.)25 b(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)
- h(.)44 b(35)459 593 y(2.5.3)61 b(User)12 b(De 02ned)g(T)l(ypes)18
- b(.)25 b(.)g(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)
- h(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)44 b(36)459 653 y(2.5.4)61
- b(Extending)12 b(Operators)34 b(.)25 b(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)g
- (.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)44
- b(39)459 712 y(2.5.5)61 b(Extending)12 b(Aggre)o(gates)42
- b(.)26 b(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)
- g(.)h(.)f(.)h(.)f(.)g(.)h(.)44 b(40)459 772 y(2.5.6)61
- b(T)n(riggers)19 b(.)26 b(.)f(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h
- (.)f(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)
- g(.)h(.)44 b(43)459 832 y(2.5.7)61 b(Serv)o(er)11 b(Programming)g
- (Interface)g((SPI))23 b(.)i(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h
- (.)f(.)h(.)f(.)g(.)h(.)44 b(46)459 892 y(2.5.8)61 b(Rules)13
- b(in)f(PostgreSQL)27 b(.)e(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)f(.)g
- (.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)44
- b(49)270 1001 y Fn(3)50 b(P)o(ostgr)o(eSQL)12 b(fr)o(om)h(the)f(Pr)o
- (ogrammer')n(s)i(P)o(oint)e(of)g(V)n(iew)602 b(51)345
- 1061 y Ft(3.1)52 b(The)13 b(W)l(ay)g(of)f(a)g(Query)j(.)26
- b(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)f(.)g(.)h
- (.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)44 b(51)345
- 1121 y(3.2)52 b(Ho)o(w)12 b(Connections)h(are)f(Established)48
- b(.)25 b(.)h(.)f(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)
- f(.)h(.)f(.)g(.)h(.)44 b(52)345 1181 y(3.3)52 b(The)13
- b(P)o(arser)f(Stage)47 b(.)25 b(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h
- (.)f(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)
- g(.)h(.)44 b(52)459 1240 y(3.3.1)61 b(P)o(arser)25 b(.)g(.)h(.)f(.)h(.)
- f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f
- (.)g(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)44 b(53)459
- 1300 y(3.3.2)61 b(T)n(ransformation)11 b(Process)i(.)26
- b(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h
- (.)f(.)h(.)f(.)g(.)h(.)44 b(54)345 1360 y(3.4)52 b(The)13
- b(PostgreSQL)f(Rule)h(System)45 b(.)26 b(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)
- h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)44
- b(58)459 1420 y(3.4.1)61 b(The)13 b(Re)o(write)f(System)42
- b(.)25 b(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)
- f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)44 b(58)619 1479 y(T)m(echniques)12
- b(T)l(o)h(Implement)e(V)m(ie)o(ws)19 b(.)26 b(.)f(.)g(.)h(.)f(.)g(.)h
- (.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)44 b(58)345
- 1539 y(3.5)52 b(Planner/Optimizer)14 b(.)25 b(.)h(.)f(.)g(.)h(.)f(.)g
- (.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)
- h(.)f(.)h(.)f(.)g(.)h(.)44 b(59)459 1599 y(3.5.1)61 b(Generating)11
- b(Possible)i(Plans)40 b(.)25 b(.)h(.)f(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f
- (.)g(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)44 b(59)459
- 1659 y(3.5.2)61 b(Data)12 b(Structure)f(of)h(the)h(Plan)42
- b(.)25 b(.)h(.)f(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)
- f(.)h(.)f(.)g(.)h(.)44 b(59)345 1719 y(3.6)52 b(Ex)o(ecutor)18
- b(.)25 b(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)
- f(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)g
- (.)h(.)44 b(60)345 1778 y(3.7)52 b(The)13 b(Realization)g(of)e(the)i
- (Ha)o(ving)f(Clause)45 b(.)25 b(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h
- (.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)44 b(62)459 1838 y(3.7.1)61
- b(Ho)o(w)12 b(Aggre)o(gate)g(Functions)g(are)g(Implemented)23
- b(.)j(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)44
- b(62)619 1898 y(The)13 b(P)o(arser)f(Stage)36 b(.)26
- b(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h
- (.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)44 b(62)619 1958 y(The)13
- b(Re)o(write)f(System)42 b(.)25 b(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h
- (.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)44
- b(63)619 2017 y(Planner/Optimizer)d(.)25 b(.)g(.)h(.)f(.)g(.)h(.)f(.)h
- (.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)
- 44 b(63)619 2077 y(Ex)o(ecutor)h(.)25 b(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f
- (.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)
- h(.)f(.)g(.)h(.)44 b(65)459 2137 y(3.7.2)61 b(Ho)o(w)12
- b(the)g(Ha)o(ving)g(Clause)h(is)g(Implemented)25 b(.)g(.)g(.)h(.)f(.)g
- (.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)44 b(66)619 2197
- y(The)13 b(P)o(arser)f(Stage)36 b(.)26 b(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)
- h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h
- (.)44 b(66)619 2257 y(The)13 b(Re)o(write)f(System)42
- b(.)25 b(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)
- f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)44 b(68)619 2316 y(Planner/Optimizer)d
- (.)25 b(.)g(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h
- (.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)44 b(80)619 2376 y(Ex)o(ecutor)h(.)
- 25 b(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)f(.)
- g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)44
- b(87)345 2436 y(3.8)52 b(The)13 b(Realization)g(of)e(Union,)i
- (Intersect)f(and)g(Except)43 b(.)25 b(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h
- (.)f(.)h(.)f(.)g(.)h(.)44 b(89)459 2496 y(3.8.1)61 b(Ho)o(w)12
- b(Unions)g(ha)o(v)o(e)h(been)f(Realized)h(Until)f(V)-6
- b(ersion)13 b(6.3.2)42 b(.)25 b(.)h(.)f(.)h(.)f(.)g(.)h(.)44
- b(91)619 2555 y(The)13 b(P)o(arser)f(Stage)36 b(.)26
- b(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h
- (.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)44 b(91)619 2615 y(The)13
- b(Re)o(write)f(System)42 b(.)25 b(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h
- (.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)44
- b(92)619 2675 y(Planner/Optimizer)d(.)25 b(.)g(.)h(.)f(.)g(.)h(.)f(.)h
- (.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)
- 44 b(92)619 2735 y(Ex)o(ecutor)h(.)25 b(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f
- (.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)
- h(.)f(.)g(.)h(.)44 b(93)459 2795 y(3.8.2)61 b(Ho)o(w)12
- b(Intersect,)g(Except)h(and)f(Union)g(W)l(ork)g(T)l(ogether)34
- b(.)26 b(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)44 b(93)619
- 2854 y(Set)12 b(Operations)g(as)h(Propositional)e(Logic)i(F)o(ormulas)i
- (.)25 b(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)44 b(95)459
- 2914 y(3.8.3)61 b(Implementing)11 b(Intersect)h(and)g(Except)h(Using)f
- (the)h(Union)f(Capabilities)k(.)26 b(.)44 b(95)619 2974
- y(P)o(arser)25 b(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)
- f(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)g
- (.)h(.)44 b(98)619 3034 y(T)n(ransformations)h(.)26 b(.)f(.)g(.)h(.)f
- (.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)
- h(.)f(.)g(.)h(.)19 b(105)619 3093 y(The)13 b(Re)o(write)f(System)42
- b(.)25 b(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)
- f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)19 b(106)p eop
- %%Page: 7 7
- 7 6 bop 198 633 a Fq(List)32 b(of)f(Figur)n(es)273 892
- y Ft(1.1)52 b(The)13 b(suppliers)g(and)f(parts)g(database)36
- b(.)25 b(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)
- h(.)f(.)h(.)f(.)g(.)h(.)44 b(10)273 1001 y(3.1)52 b(Ho)o(w)12
- b(a)h(connection)f(is)h(established)42 b(.)25 b(.)g(.)h(.)f(.)h(.)f(.)g
- (.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)44
- b(52)273 1061 y(3.2)52 b Fp(T)-5 b(ar)n(getList)12 b
- Ft(and)h Fp(F)m(r)n(omList)g Ft(for)e(query)h(of)g(e)o(xample)h(3.1)35
- b(.)25 b(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)44
- b(54)273 1121 y(3.3)52 b Fp(Wher)n(eClause)14 b Ft(for)e(query)g(of)g
- (e)o(xample)g(3.1)23 b(.)i(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f
- (.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)44 b(55)273 1181 y(3.4)52
- b(T)n(ransformed)12 b Fp(T)-5 b(ar)n(getList)12 b Ft(and)h
- Fp(F)m(r)n(omList)g Ft(for)e(query)h(of)g(e)o(xample)h(3.1)28
- b(.)e(.)f(.)h(.)f(.)g(.)h(.)44 b(56)273 1240 y(3.5)52
- b(T)n(ransformed)12 b Fp(wher)n(e)i(clause)e Ft(for)g(query)g(of)g(e)o
- (xample)g(3.1)23 b(.)j(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)44
- b(57)273 1300 y(3.6)52 b Fp(Plan)13 b Ft(for)e(query)h(of)g(e)o(xample)
- h(3.1)45 b(.)26 b(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g
- (.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)44 b(61)273 1360
- y(3.7)52 b Fp(Querytr)n(ee)14 b Ft(b)o(uilt)e(up)g(for)f(the)i(query)f
- (of)g(e)o(xample)g(3.2)38 b(.)25 b(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f
- (.)h(.)f(.)g(.)h(.)44 b(63)273 1420 y(3.8)52 b Fp(Plantr)n(ee)13
- b Ft(for)f(the)g(query)g(of)g(e)o(xample)h(3.2)46 b(.)25
- b(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)g
- (.)h(.)44 b(64)273 1479 y(3.9)52 b(Data)13 b(structure)f(handed)g(back)
- g(by)h(the)f Fp(parser)49 b Ft(.)25 b(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h
- (.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)44 b(92)273 1539 y(3.10)27
- b Fp(Plan)13 b Ft(for)e(a)i(union)f(query)44 b(.)25 b(.)h(.)f(.)g(.)h
- (.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)
- f(.)h(.)f(.)g(.)h(.)44 b(93)273 1599 y(3.11)27 b Fp(Oper)o(ator)13
- b(tr)n(ee)g Ft(for)f Fl(()p Fk(A)g Fo([)f Fk(B)r Fl())p
- Fo(n)p Fl(()p Fk(C)k Fo(\)d Fk(D)q Fl())29 b Ft(.)d(.)f(.)h(.)f(.)g
- (.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)19
- b(101)273 1659 y(3.12)27 b(Data)13 b(structure)f(handed)g(back)g(by)h
- Fr(SelectStmt)e Ft(rule)48 b(.)26 b(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)h(.)f
- (.)g(.)h(.)19 b(102)273 1719 y(3.13)27 b(Data)13 b(structure)f(of)f
- Fl(()p Fk(A)h Fo([)g Fk(B)r Fl())p Fo(n)p Fk(C)k Ft(after)11
- b(transformation)g(to)h(DNF)50 b(.)25 b(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)
- 19 b(107)273 1778 y(3.14)27 b(Data)13 b(structure)f(of)f
- Fk(A)h Fo(\)f Fk(C)16 b Ft(after)c(query)f(re)o(writing)40
- b(.)26 b(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)19
- b(109)1086 3552 y(7)p eop
- %%Page: 8 8
- 8 7 bop eop
- %%Page: 9 9
- 9 8 bop 198 661 a Fj(Chapter)26 b(1)198 964 y Fq(SQL)198
- 1276 y Ft(SQL)10 b(has)h(become)f(one)g(of)g(the)g(most)g(popular)f
- (relational)g(query)h(languages)g(all)g(o)o(v)o(er)h(the)f(world.)k
- (The)198 1336 y(name)i(224SQL224)g(is)g(an)g(abbre)o(viation)f(for)g
- Fp(Structur)n(ed)h(Query)g(Language)p Ft(.)25 b(In)15
- b(1974)h(Donald)f(Cham-)198 1395 y(berlin)f(and)g(others)g(de 02ned)h
- (the)f(language)g(SEQUEL)h Fp((Structur)n(ed)g(English)g(Query)g
- (Language))d Ft(at)198 1455 y(IBM)f(Research.)16 b(This)11
- b(language)f(was)h( 02rst)f(implemented)f(in)i(an)f(IBM)h(prototype)e
- (called)i(SEQUEL-)198 1515 y(XRM)h(in)e(1974-75.)15 b(In)10
- b(1976-77)g(a)i(re)o(vised)e(v)o(ersion)h(of)g(SEQUEL)g(called)g
- (SEQUEL/2)g(was)g(de 02ned)198 1575 y(and)h(the)h(name)f(was)g
- (changed)h(to)f(SQL)h(subsequently)m(.)273 1688 y(A)j(ne)o(w)f
- (prototype)g(called)h(System)g(R)g(was)g(de)o(v)o(eloped)g(by)f(IBM)h
- (in)g(1977.)26 b(System)16 b(R)g(imple-)198 1748 y(mented)f(a)h(lar)o
- (ge)f(subset)h(of)f(SEQUEL/2)h((no)o(w)f(SQL))g(and)h(a)f(number)g
- (of)g(changes)h(were)g(made)f(to)198 1808 y(SQL)i(during)e(the)h
- (project.)28 b(System)16 b(R)h(was)f(installed)g(in)h(a)f(number)g(of)g
- (user)g(sites,)j(both)d(internal)198 1867 y(IBM)d(sites)h(and)f(also)g
- (some)h(selected)f(customer)g(sites.)19 b(Thanks)13 b(to)g(the)g
- (success)i(and)e(acceptance)h(of)198 1927 y(System)d(R)g(at)g(those)g
- (user)h(sites)f(IBM)g(started)g(to)g(de)o(v)o(elop)g(commercial)f
- (products)h(that)g(implemented)198 1987 y(the)h(SQL)h(language)f(based)
- h(on)f(the)h(System)f(R)g(technology)m(.)273 2100 y(Ov)o(er)g(the)g(ne)
- o(xt)g(years)h(IBM)f(and)h(also)f(a)h(number)e(of)h(other)g(v)o(endors)
- g(announced)g(SQL)g(products)198 2160 y(such)18 b(as)h(SQL/DS)e
- ((IBM),)h(DB2)g((IBM))f(ORA)n(CLE)i((Oracle)e(Corp.))32
- b(DG/SQL)18 b((Data)f(General)198 2220 y(Corp.))e(SYB)n(ASE)e
- ((Sybase)f(Inc.).)273 2333 y(SQL)i(is)h(also)g(an)g(of)o( 02cial)e
- (standard)h(no)o(w)m(.)22 b(In)14 b(1982)g(the)h(American)f(National)g
- (Standards)g(Insti-)198 2392 y(tute)g((ANSI))e(chartered)h(its)h
- (Database)h(Committee)e(X3H2)g(to)h(de)o(v)o(elop)g(a)g(proposal)f(for)
- g(a)h(standard)198 2452 y(relational)9 b(language.)16
- b(This)10 b(proposal)g(was)h(rati 02ed)e(in)h(1986)g(and)g(consisted)h
- (essentially)g(of)f(the)g(IBM)198 2512 y(dialect)j(of)f(SQL.)i(In)e
- (1987)g(this)h(ANSI)f(standard)h(was)g(also)g(accepted)g(as)h(an)f
- (international)e(standard)198 2572 y(by)h(the)g(International)f(Or)o
- (ganization)g(for)g(Standardization)g((ISO).)f(This)j(original)e
- (standard)h(v)o(ersion)198 2632 y(of)k(SQL)g(is)h(often)f(referred)f
- (to,)i(informally)m(,)f(as)h(224SQL/86224.)27 b(In)16
- b(1989)g(the)h(original)e(standard)h(was)198 2691 y(e)o(xtended)c(and)f
- (this)h(ne)o(w)f(standard)g(is)h(often,)g(again)f(informally)m(,)f
- (referred)h(to)g(as)h(224SQL/89224.)k(Also)11 b(in)198
- 2751 y(1989,)i(a)f(related)g(standard)g(called)h Fp(Database)f
- (Language)f(Embedded)i(SQL)f Ft(was)g(de)o(v)o(eloped.)273
- 2864 y(The)22 b(ISO)f(and)h(ANSI)f(committees)g(ha)o(v)o(e)i(been)f
- (working)e(for)h(man)o(y)h(years)g(on)f(the)h(de 02ni-)198
- 2924 y(tion)g(of)g(a)h(greatly)f(e)o(xpanded)h(v)o(ersion)g(of)f(the)h
- (original)e(standard,)26 b(referred)21 b(to)h(informally)g(as)198
- 2984 y(224SQL2224)17 b(or)f(224SQL/92224.)27 b(This)18
- b(v)o(ersion)e(became)g(a)h(rati 02ed)f(standard)g(-)g
- (224International)f(Standard)198 3044 y(ISO/IEC)d(9075:1992)o(,)f
- Fp(Database)f(Language)e(SQL)p Ft(224)h(-)h(in)g(late)g(1992.)k
- (224SQL/92224)c(is)g(the)g(v)o(ersion)g(nor)o(-)198
- 3103 y(mally)h(meant)g(when)g(people)h(refer)e(to)h(224the)h(SQL)f
- (standard224.)16 b(A)11 b(detailed)g(description)g(of)g
- (224SQL/92224)198 3163 y(is)18 b(gi)o(v)o(en)f(in)h([D)n(A)-6
- b(TE96)q(].)31 b(At)18 b(the)f(time)h(of)f(writing)g(this)g(document)h
- (a)g(ne)o(w)f(standard)h(informally)198 3223 y(referred)11
- b(to)i(as)g(224SQL3224)g(is)g(under)f(de)o(v)o(elopment.)17
- b(It)12 b(is)h(planned)f(to)h(make)f(SQL)h(a)g(turing-complete)198
- 3283 y(language,)e(i.e.)h(all)f(computable)f(queries)g((e.g.)16
- b(recursi)o(v)o(e)10 b(queries))g(will)h(be)f(possible.)16
- b(This)11 b(is)g(a)g(v)o(ery)198 3342 y(comple)o(x)h(task)h(and)g
- (therefore)e(the)h(completion)g(of)g(the)h(ne)o(w)f(standard)g(can)h
- (not)f(be)h(e)o(xpected)g(before)198 3402 y(1999.)1086
- 3552 y(9)p eop
- %%Page: 10 10
- 10 9 bop 270 60 a Ft(10)1351 b Fm(CHAPTER)14 b(1.)28
- b(SQL)270 234 y Fi(1.1)71 b(The)18 b(Relational)f(Data)g(Model)270
- 346 y Ft(As)10 b(mentioned)f(before,)h(SQL)g(is)g(a)g(relational)e
- (language.)15 b(That)10 b(means)g(it)g(is)g(based)g(on)f(the)h
- (224relational)270 405 y(data)j(model224)f( 02rst)g(published)h(by)f
- (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
- (description)g(of)g(the)270 465 y(relational)h(model)h(in)f(section)h
- (1.1.1)h Fp(F)-5 b(ormal)14 b(Notion)g(of)g(the)f(Relational)h(Data)g
- (Model)g Ft(b)o(ut)f( 02rst)h(we)270 525 y(want)e(to)g(ha)o(v)o(e)h(a)
- f(look)g(at)h(it)f(from)f(a)i(more)f(intuiti)o(v)o(e)f(point)h(of)g
- (vie)o(w)m(.)345 585 y(A)19 b Fp(r)n(elational)g(database)g
- Ft(is)h(a)f(database)h(that)f(is)h(percei)o(v)o(ed)f(by)g(its)g(users)h
- (as)g(a)f Fp(collection)g(of)270 645 y(tables)13 b Ft((and)f(nothing)g
- (else)i(b)o(ut)e(tables).)17 b(A)c(table)g(consists)h(of)e(ro)o(ws)h
- (and)f(columns)h(where)g(each)g(ro)o(w)270 704 y(represents)g(a)g
- (record)f(and)h(each)g(column)f(represents)h(an)g(attrib)o(ute)f(of)g
- (the)h(records)f(contained)h(in)f(the)270 764 y(table.)k(Figure)11
- b(1.1)i(sho)o(ws)g(an)f(e)o(xample)h(of)f(a)g(database)h(consisting)g
- (of)f(three)g(tables:)345 864 y Fo( 17)25 b Ft(SUPPLIER)16
- b(is)h(a)f(table)h(storing)e(the)i(number)f((SNO),)f(the)i(name)f
- ((SN)n(AME))g(and)h(the)f(city)395 924 y((CITY))11
- b(of)h(a)h(supplier)m(.)345 1024 y Fo( 17)25 b Ft(P)-5
- b(AR)m(T)10 b(is)g(a)g(table)g(storing)f(the)h(number)f((PNO))g(the)g
- (name)h((PN)n(AME))g(and)f(the)h(price)g((PRICE))395
- 1084 y(of)h(a)i(part.)345 1184 y Fo( 17)25 b Ft(SELLS)12
- b(stores)g(information)e(about)h(which)h(part)f((PNO))g(is)h(sold)f
- (by)h(which)f(supplier)h((SNO).)395 1243 y(It)f(serv)o(es)j(in)e(a)g
- (sense)i(to)e(connect)g(the)h(other)e(two)h(tables)h(together)m(.)360
- 1391 y Fr(SUPPLIER)88 b(SNO)30 b(|)60 b(SNAME)f(|)h(CITY)178
- b(SELLS)90 b(SNO)29 b(|)h(PNO)659 1451 y(-----+---------+--------)326
- b(-----+-----)718 1511 y(1)60 b(|)g(Smith)f(|)30 b(London)417
- b(1)60 b(|)g(1)718 1571 y(2)g(|)g(Jones)f(|)30 b(Paris)447
- b(1)60 b(|)g(2)718 1631 y(3)g(|)g(Adams)f(|)30 b(Vienna)417
- b(2)60 b(|)g(4)718 1690 y(4)g(|)g(Blake)f(|)30 b(Rome)477
- b(3)60 b(|)g(1)1764 1750 y(3)g(|)g(3)1764 1810 y(4)g(|)g(2)360
- 1870 y(PART)208 b(PNO)30 b(|)60 b(PNAME)f(|)h(PRICE)417
- b(4)60 b(|)g(3)659 1929 y(-----+---------+---------)355
- b(4)60 b(|)g(4)718 1989 y(1)g(|)g(Screw)f(|)89 b(10)718
- 2049 y(2)60 b(|)g(Nut)119 b(|)g(8)718 2109 y(3)60 b(|)g(Bolt)89
- b(|)g(15)718 2169 y(4)60 b(|)g(Cam)119 b(|)89 b(25)729
- 2328 y Ft(Figure)12 b(1.1:)j(The)e(suppliers)g(and)f(parts)g(database)
- 270 2448 y(The)h(tables)f(P)-5 b(AR)m(T)13 b(and)f(SUPPLIER)f(may)h(be)
- g(re)o(garded)g(as)g Fp(entities)g Ft(and)g(SELLS)h(may)f(be)g(re)o
- (garded)270 2507 y(as)h(a)g Fp(r)n(elationship)f Ft(between)g(a)h
- (particular)e(part)h(and)h(a)f(particular)f(supplier)m(.)345
- 2567 y(As)k(we)g(will)f(see)h(later)n(,)g(SQL)g(operates)g(on)f(tables)
- h(like)f(the)h(ones)g(just)g(de 02ned)f(b)o(ut)g(before)g(that)270
- 2627 y(we)f(will)e(study)i(the)f(theory)g(of)g(the)g(relational)g
- (model.)270 2770 y Fh(1.1.1)59 b(F)o(ormal)13 b(Notion)i(of)f(the)h
- (Relational)e(Data)i(Model)270 2864 y Ft(The)22 b(mathematical)f
- (concept)g(underlying)f(the)h(relational)g(model)g(is)g(the)h
- (set-theoretic)e Fp(r)n(elation)270 2924 y Ft(which)d(is)h(a)g(subset)g
- (of)g(the)f(Cartesian)h(product)f(of)g(a)h(list)f(of)g(domains.)32
- b(This)18 b(set-theoretic)f Fp(r)n(ela-)270 2983 y(tion)i
- Ft(gi)o(v)o(es)g(the)g(model)g(its)g(name)g((do)g(not)g(confuse)g(it)g
- (with)g(the)g(relationship)f(from)g(the)h Fp(Entity-)270
- 3043 y(Relationship)14 b(model)p Ft().)20 b(F)o(ormally)13
- b(a)h(domain)g(is)g(simply)g(a)g(set)g(of)g(v)o(alues.)21
- b(F)o(or)13 b(e)o(xample)h(the)g(set)h(of)270 3103 y(inte)o(gers)d(is)g
- (a)g(domain.)j(Also)c(the)h(set)g(of)f(character)h(strings)f(of)g
- (length)h(20)f(and)h(the)f(real)h(numbers)f(are)270 3163
- y(e)o(xamples)i(of)f(domains.)270 3283 y Fn(De 02nition)f(1.1)25
- b Ft(The)65 b Fp(Cartesian)g Ft(product)e(of)h(domains)h
- Fk(D)1580 3290 y Fg(1)1602 3283 y Fk(;)8 b(D)1665 3290
- y Fg(2)1688 3283 y Fk(;)g(:)g(:)g(:)h(;)f(D)1840 3290
- y Ff(k)1929 3283 y Ft(written)270 3342 y Fk(D)311 3349
- y Fg(1)345 3342 y Fo( 02)i Fk(D)435 3349 y Fg(2)469
- 3342 y Fo( 02)h Fk(:)d(:)g(:)j Fo( 02)g Fk(D)679 3349
- y Ff(k)757 3342 y Ft(is)54 b(the)g(set)g(of)f(all)h Fk(k)r
- Ft(-tuples)e Fl(()p Fk(v)1526 3349 y Fg(1)1549 3342
- y Fk(;)8 b(v)1595 3349 y Fg(2)1618 3342 y Fk(;)g(:)g(:)g(:)g(;)g(v)1752
- 3349 y Ff(k)1777 3342 y Fl())54 b Ft(such)g(that)270
- 3402 y Fk(v)294 3409 y Fg(1)330 3402 y Fo(2)14 b Fk(D)418
- 3409 y Fg(1)441 3402 y Fk(;)8 b(v)487 3409 y Fg(2)523
- 3402 y Fo(2)14 b Fk(D)611 3409 y Fg(2)634 3402 y Fk(;)8
- b(:)g(:)g(:)h(;)f(v)769 3409 y Ff(k)807 3402 y Fo(2)14
- b Fk(D)895 3409 y Ff(k)920 3402 y Ft(.)p eop
- %%Page: 11 11
- 11 10 bop 198 60 a Fm(1.2.)29 b(OPERA)-6 b(TIONS)12 b(IN)g(THE)i(RELA)
- -6 b(TION)n(AL)14 b(D)n(A)-6 b(T)h(A)14 b(MODEL)521 b
- Ft(11)198 234 y(F)o(or)16 b(e)o(xample,)h(when)f(we)g(ha)o(v)o(e)g
- Fk(k)22 b Fl(=)f(2)p Ft(,)c Fk(D)989 241 y Fg(1)1032
- 234 y Fl(=)j Fo(f)p Fl(0)p Fk(;)8 b Fl(1)p Fo(g)16 b
- Ft(and)g Fk(D)1358 241 y Fg(2)1401 234 y Fl(=)21 b Fo(f)p
- Fk(a;)8 b(b;)g(c)p Fo(g)p Ft(,)17 b(then)f Fk(D)1796
- 241 y Fg(1)1833 234 y Fo( 02)d Fk(D)1926 241 y Fg(2)1965
- 234 y Ft(is)198 294 y Fo(f)p Fl((0)p Fk(;)8 b(a)p Fl())p
- Fk(;)g Fl((0)p Fk(;)g(b)p Fl())p Fk(;)g Fl((0)p Fk(;)g(c)p
- Fl())p Fk(;)g Fl((1)p Fk(;)g(a)q Fl())p Fk(;)g Fl(()q(1)p
- Fk(;)g(b)p Fl())p Fk(;)h Fl((1)p Fk(;)f(c)p Fl())p
- Fo(g)p Ft(.)198 420 y Fn(De 02nition)j(1.2)25 b Ft(A)13
- b(Relation)g(is)h(an)o(y)g(subset)f(of)g(the)h(Cartesian)f(product)g
- (of)f(one)i(or)f(more)f(domains:)198 480 y Fk(R)i Fo( 22)e
- Fk(D)342 487 y Fg(1)376 480 y Fo( 02)f Fk(D)467 487
- y Fg(2)500 480 y Fo( 02)g Fk(:)d(:)g(:)j Fo( 02)g Fk(D)710
- 487 y Ff(k)198 584 y Ft(F)o(or)g(e)o(xample)h Fo(f)p
- Fl((0)p Fk(;)c(a)p Fl())p Fk(;)g Fl((0)p Fk(;)g(b)p
- Fl())p Fk(;)g Fl((1)p Fk(;)g(a)p Fl())p Fo(g)15 b
- Ft(is)d(a)g(relation,)f(it)g(is)h(in)g(fact)f(a)g(subset)i(of)e
- Fk(D)1635 591 y Fg(1)1666 584 y Fo( 02)d Fk(D)1754 591
- y Fg(2)1788 584 y Ft(mentioned)198 644 y(abo)o(v)o(e.)15
- b(The)10 b(members)g(of)f(a)h(relation)e(are)i(called)f(tuples.)15
- b(Each)10 b(relation)f(of)g(some)h(Cartesian)g(product)198
- 703 y Fk(D)239 710 y Fg(1)273 703 y Fo( 02)g Fk(D)363
- 710 y Fg(2)397 703 y Fo( 02)h Fk(:)d(:)g(:)j Fo( 02)g
- 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
- Fk(k)i Ft(and)f(is)f(therefore)f(a)i(set)g(of)f Fk(k)r
- Ft(-tuples.)273 764 y(A)j(relation)f(can)h(be)f(vie)o(wed)h(as)g(a)g
- (table)g((as)g(we)g(already)f(did,)i(remember)d( 02gure)i(1.1)g
- Fp(The)f(sup-)198 824 y(pliers)j(and)g(parts)h(database)p
- Ft())f(where)g(e)o(v)o(ery)g(tuple)g(is)g(represented)g(by)g(a)h(ro)o
- (w)e(and)i(e)o(v)o(ery)f(column)198 884 y(corresponds)c(to)h(one)f
- (component)g(of)g(a)h(tuple.)19 b(Gi)o(ving)13 b(names)h((called)f
- (attrib)o(utes))f(to)i(the)f(columns)198 944 y(leads)g(to)f(the)g
- (de 02nition)g(of)g(a)g Fp(r)n(elation)h(sc)o(heme)p
- Ft(.)198 1070 y Fn(De 02nition)e(1.3)25 b Ft(A)12 b
- Fp(r)n(elation)g(sc)o(heme)h Fk(R)g Ft(is)f(a)g( 02nite)g(set)g(of)g
- (attrib)o(utes)g Fo(f)p Fk(A)1507 1077 y Fg(1)1529 1070
- y Fk(;)c(A)1588 1077 y Fg(2)1611 1070 y Fk(;)g(:)g(:)g(:)h(;)f(A)1759
- 1077 y Ff(k)1784 1070 y Fo(g)p Ft(.)15 b(There)e(is)198
- 1130 y(a)h(domain)g Fk(D)439 1137 y Ff(i)470 1130 y Ft(for)g(each)g
- (attrib)o(ute)g Fk(A)865 1137 y Ff(i)882 1130 y Fk(;)8
- b Fl(1)17 b Fo( 24)g Fk(i)g Fo( 24)g Fk(k)f Ft(where)e(the)g(v)o
- (alues)h(of)f(the)g(attrib)o(utes)f(are)i(taken)198 1189
- y(from.)g(W)l(e)d(often)g(write)g(a)h(relation)e(scheme)i(as)g
- Fk(R)p Fl(()p Fk(A)1139 1196 y Fg(1)1162 1189 y Fk(;)8
- b(A)1221 1196 y Fg(2)1244 1189 y Fk(;)g(:)g(:)g(:)h(;)f(A)1392
- 1196 y Ff(k)1417 1189 y Fl())p Ft(.)198 1293 y Fn(Note:)21
- 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
- (template)g(whereas)h(a)g Fp(r)n(elation)f Ft(is)h(an)f(instance)h(of)f
- (a)198 1353 y Fp(r)n(elation)h(sc)o(heme)p Ft(.)26 b(The)17
- b Fp(r)n(elation)e Ft(consists)i(of)e(tuples)h((and)f(can)h(therefore)
- e(be)i(vie)o(wed)f(as)i(a)f(table))198 1413 y(not)c(so)h(the)f
- Fp(r)n(elation)h(sc)o(heme)p Ft(.)198 1552 y Fn(Domains)g(vs.)j(Data)c
- (T)l(ypes)198 1647 y Ft(W)l(e)j(often)g(talked)f(about)h
- Fp(domains)g Ft(in)g(the)g(last)g(section.)25 b(Recall)15
- b(that)g(a)g(domain)g(is,)h(formally)m(,)f(just)198 1707
- y(a)f(set)g(of)f(v)o(alues)h((e.g.,)h(the)e(set)h(of)g(inte)o(gers)f
- (or)g(the)h(real)f(numbers).)19 b(In)13 b(terms)h(of)f(database)h
- (systems)198 1767 y(we)f(often)f(talk)g(of)g Fp(data)h(types)g
- Ft(instead)g(of)f(domains.)k(When)d(we)g(de 02ne)f(a)h(table)g(we)f
- (ha)o(v)o(e)h(to)g(make)f(a)198 1827 y(decision)j(about)f(which)g
- (attrib)o(utes)g(to)g(include.)22 b(Additionally)14 b(we)g(ha)o(v)o(e)h
- (to)g(decide)f(which)g(kind)h(of)198 1886 y(data)f(is)f(going)g(to)h
- (be)f(stored)h(as)g(attrib)o(ute)e(v)o(alues.)20 b(F)o(or)13
- b(e)o(xample)g(the)h(v)o(alues)f(of)h(SN)n(AME)g(from)e(the)198
- 1946 y(table)g(SUPPLIER)f(will)g(be)h(character)f(strings,)h(whereas)g
- (SNO)f(will)h(store)f(inte)o(gers.)16 b(W)l(e)c(de 02ne)f(this)198
- 2006 y(by)f(assigning)f(a)h Fp(data)g(type)f Ft(to)h(each)g(attrib)o
- (ute.)k(The)c(type)f(of)h(SN)n(AME)g(will)f(be)h(V)-7
- b(ARCHAR(20))9 b((this)198 2066 y(is)14 b(the)f(SQL)h(type)f(for)g
- (character)g(strings)g(of)h(length)f Fo( 24)g Ft(20),)h(the)f(type)h
- (of)f(SNO)g(will)g(be)g(INTEGER.)198 2125 y(W)n(ith)i(the)h(assignment)
- 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
- (domain)f(for)f(an)i(attrib)o(ute.)25 b(The)198 2185
- y(domain)12 b(of)g(SN)n(AME)i(is)f(the)f(set)h(of)f(all)h(character)f
- (strings)h(of)f(length)g Fo( 24)h Ft(20,)g(the)f(domain)g(of)g(SNO)h
- (is)198 2245 y(the)f(set)h(of)f(all)g(inte)o(ger)g(numbers.)198
- 2419 y Fi(1.2)71 b(Operations)17 b(in)h(the)f(Relational)g(Data)g
- (Model)198 2533 y Ft(In)11 b(section)h(1.1.1)g(we)g(de 02ned)f(the)g
- (mathematical)g(notion)g(of)g(the)h(relational)f(model.)k(No)o(w)c(we)h
- (kno)o(w)198 2592 y(ho)o(w)j(the)g(data)h(can)g(be)f(stored)g(using)h
- (a)f(relational)g(data)g(model)g(b)o(ut)h(we)f(do)h(not)f(kno)o(w)g
- (what)g(to)g(do)198 2652 y(with)g(all)f(these)i(tables)f(to)g(retrie)o
- (v)o(e)f(something)g(from)g(the)h(database)g(yet.)24
- b(F)o(or)14 b(e)o(xample)h(somebody)198 2712 y(could)i(ask)g(for)f(the)
- h(names)g(of)g(all)g(suppliers)g(that)g(sell)g(the)g(part)f('Scre)o
- (w'.)28 b(Therefore)17 b(two)f(rather)198 2772 y(dif)o(ferent)11
- b(kinds)h(of)g(notations)g(for)g(e)o(xpressing)g(operations)g(on)h
- (relations)f(ha)o(v)o(e)g(been)h(de 02ned:)273 2875
- y Fo( 17)25 b Ft(The)14 b Fp(Relational)f(Algebr)o(a)g
- Ft(which)h(is)f(an)h(algebraic)f(notation,)g(where)h(queries)f(are)g(e)
- o(xpressed)323 2934 y(by)f(applying)g(specialized)g(operators)g(to)g
- (the)h(relations.)273 3039 y Fo( 17)25 b Ft(The)13 b
- Fp(Relational)f(Calculus)h Ft(which)f(is)h(a)g(logical)g(notation,)f
- (where)h(queries)f(are)h(e)o(xpressed)g(by)323 3098 y(formulating)d
- (some)j(logical)f(restrictions)g(that)g(the)g(tuples)h(in)f(the)g
- (answer)h(must)f(satisfy)m(.)198 3247 y Fh(1.2.1)59 b(Relational)14
- b(Algebra)198 3342 y Ft(The)20 b Fp(Relational)f(Algebr)o(a)h
- Ft(was)f(introduced)g(by)g(E.)i(F)l(.)e(Codd)h(in)f(1972.)37
- b(It)19 b(consists)h(of)f(a)h(set)g(of)198 3402 y(operations)12
- b(on)g(relations:)p eop
- %%Page: 12 12
- 12 11 bop 270 60 a Ft(12)1351 b Fm(CHAPTER)14 b(1.)28
- b(SQL)345 234 y Fo( 17)d Ft(SELECT)17 b(()p Fk( 33)r
- Ft():)j(e)o(xtracts)c Fp(tuples)g Ft(from)e(a)i(relation)e(that)i
- (satisfy)f(a)h(gi)o(v)o(en)f(restriction.)24 b(Let)16
- b Fk(R)395 294 y Ft(be)f(a)h(table)g(that)f(contains)h(an)g(attrib)o
- (ute)e Fk(A)p Ft(.)27 b Fk( 33)1227 301 y Ff(A)p Fg(=)p
- Ff(a)1312 294 y Fl(()p Fk(R)p Fl())21 b(=)e Fo(f)p
- Fk(t)h Fo(2)g Fk(R)g Fo(j)g Fk(t)p Fl(()p Fk(A)p Fl())h(=)f
- Fk(a)p Fo(g)c Ft(where)f Fk(t)395 354 y Ft(denotes)d(a)h(tuple)f(of)g
- Fk(R)g Ft(and)h Fk(t)p Fl(()p Fk(A)p Fl())g Ft(denotes)g(the)f(v)o
- (alue)g(of)g(attrib)o(ute)g Fk(A)h Ft(of)f(tuple)g Fk(t)p
- Ft(.)345 471 y Fo( 17)25 b Ft(PR)n(OJECT)17 b(()p Fk( 31)r
- Ft():)22 b(e)o(xtracts)16 b(speci 02ed)g Fp(attrib)o(utes)g
- Ft((columns))f(from)g(a)h(relation.)26 b(Let)17 b Fk(R)f
- Ft(be)g(a)395 530 y(relation)10 b(that)h(contains)g(an)g(attrib)o(ute)f
- Fk(X)t Ft(.)16 b Fk( 31)1156 537 y Ff(X)1194 530 y Fl(()p
- Fk(R)p Fl())f(=)f Fo(f)p Fk(t)p Fl(()p Fk(X)t Fl())g
- Fo(j)g Fk(t)g Fo(2)g Fk(R)p Fo(g)p Ft(,)e(where)f Fk(t)p
- Fl(()p Fk(X)t Fl())h Ft(denotes)395 590 y(the)g(v)o(alue)g(of)g
- (attrib)o(ute)f Fk(X)17 b Ft(of)12 b(tuple)g Fk(t)p Ft(.)345
- 707 y Fo( 17)25 b Ft(PR)n(ODUCT)12 b(()p Fo( 02)p
- Ft():)i(b)o(uilds)f(the)f(Cartesian)g(product)g(of)f(two)h(relations.)
- j(Let)e Fk(R)g Ft(be)f(a)g(table)g(with)395 767 y(arity)i
- 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
- (with)f(arity)g Fk(k)1210 774 y Fg(2)1233 767 y Ft(.)23
- b Fk(R)13 b Fo( 02)g Fk(S)k Ft(is)e(the)g(set)g(of)g(all)g
- Fl(()p Fk(k)1780 774 y Fg(1)1815 767 y Fl(+)e Fk(k)1893
- 774 y Fg(2)1915 767 y Fl())p Ft(-tuples)395 827 y(whose)h( 02rst)f
- Fk(k)653 834 y Fg(1)690 827 y Ft(components)g(form)g(a)h(tuple)g(in)g
- Fk(R)g Ft(and)g(whose)g(last)g Fk(k)1646 834 y Fg(2)1682
- 827 y Ft(components)g(form)f(a)395 887 y(tuple)f(in)g
- Fk(S)s Ft(.)345 1004 y Fo( 17)25 b Ft(UNION)13 b(()p
- Fo([)p Ft():)18 b(b)o(uilds)c(the)g(set-theoretic)f(union)h(of)g(two)f
- (tables.)21 b(Gi)o(v)o(en)14 b(the)g(tables)g Fk(R)h
- Ft(and)f Fk(S)395 1063 y Ft((both)e(must)g(ha)o(v)o(e)h(the)g(same)g
- (arity),)g(the)f(union)h Fk(R)e Fo([)h Fk(S)j Ft(is)e(the)g(set)g(of)g
- (tuples)g(that)f(are)h(in)f Fk(R)i Ft(or)395 1123 y Fk(S)g
- Ft(or)e(both.)345 1240 y Fo( 17)25 b Ft(INTERSECT)12
- b(()p Fo(\)p Ft():)h(b)o(uilds)e(the)f(set-theoretic)g(intersection)
- g(of)g(two)g(tables.)16 b(Gi)o(v)o(en)10 b(the)h(tables)395
- 1300 y Fk(R)j Ft(and)f Fk(S)s Ft(,)i Fk(R)d Fo([)g Fk(S)17
- b Ft(is)d(the)g(set)g(of)f(tuples)h(that)g(are)g(in)f
- Fk(R)h Ft(and)g(in)g Fk(S)s Ft(.)20 b(W)l(e)14 b(again)f(require)g
- (that)h Fk(R)395 1360 y Ft(and)e Fk(S)j Ft(ha)o(v)o(e)e(the)f(same)h
- (arity)m(.)345 1477 y Fo( 17)25 b Ft(DIFFERENCE)14 b(()p
- Fo( 00)g Ft(or)f Fo(n)p Ft():)18 b(b)o(uilds)c(the)g(set)h(dif)o
- (ference)d(of)i(two)f(tables.)21 b(Let)15 b Fk(R)f Ft(and)g
- Fk(S)i Ft(again)395 1536 y(be)c(two)g(tables)g(with)g(the)h(same)g
- (arity)m(.)h Fk(R)e Fo( 00)f Fk(S)j Ft(is)f(the)f(set)h(of)f(tuples)h
- (in)f Fk(R)h Ft(b)o(ut)f(not)g(in)g Fk(S)s Ft(.)345 1653
- y Fo( 17)25 b Ft(JOIN)d(()p Fe(1)p Ft():)36 b(connects)23
- b(two)g(tables)g(by)g(their)f(common)g(attrib)o(utes.)47
- b(Let)24 b Fk(R)f Ft(be)g(a)g(table)395 1713 y(with)18
- b(the)g(attrib)o(utes)g Fk(A;)8 b(B)22 b Ft(and)c Fk(C)k
- Ft(and)c(let)h Fk(S)i Ft(a)e(table)f(with)g(the)h(attrib)o(utes)f
- Fk(C)q(;)8 b(D)19 b Ft(and)g Fk(E)s Ft(.)395 1773 y(There)k(is)g(one)g
- (attrib)o(ute)f(common)g(to)h(both)f(relations,)k(the)d(attrib)o(ute)f
- Fk(C)t Ft(.)47 b Fk(R)33 b Fe(1)g Fk(S)j Fl(=)395 1833
- y Fk( 31)423 1840 y Ff(R:A;R:B)r(;R:C;S:D)q(;S:E)826
- 1833 y Fl(()p Fk( 33)873 1840 y Ff(R:C)r Fg(=)p Ff(S:C)1047
- 1833 y Fl(()p Fk(R)15 b Fo( 02)e Fk(S)s Fl()))p Ft(.)27
- b(What)16 b(are)g(we)g(doing)f(here?)27 b(W)l(e)16 b( 02rst)f(cal-)395
- 1893 y(culate)g(the)h(Cartesian)f(product)g Fk(R)f Fo( 02)f
- Fk(S)s Ft(.)24 b(Then)16 b(we)g(select)g(those)g(tuples)f(whose)h(v)o
- (alues)g(for)395 1952 y(the)c(common)g(attrib)o(ute)g
- Fk(C)k Ft(are)d(equal)f(()p Fk( 33)1124 1959 y Ff(R:C)r
- Fg(=)p Ff(S:C)1297 1952 y Ft().)17 b(No)o(w)12 b(we)h(got)f(a)h(table)
- g(that)f(contains)h(the)395 2012 y(attrib)o(ute)e Fk(C)16
- b Ft(two)11 b(times)i(and)f(we)h(correct)e(this)i(by)f(projecting)f
- (out)i(the)f(duplicate)g(column.)395 2153 y Fn(Example)g(1.1)25
- 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
- (are)h(produced)e(by)i(e)o(v)o(aluating)e(the)h(steps)395
- 2213 y(necessary)j(for)e(a)i(join.)395 2273 y(Let)f(the)h(follo)o(wing)
- e(two)g(tables)i(be)f(gi)o(v)o(en:)664 2410 y Fr(R)89
- b(A)30 b(|)g(B)f(|)h(C)179 b(S)90 b(C)30 b(|)f(D)h(|)g(E)753
- 2470 y(---+---+---)238 b(---+---+---)783 2529 y(1)30
- 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
- (6)299 b(6)30 b(|)f(c)h(|)g(d)783 2649 y(7)g(|)g(8)f(|)h(9)395
- 2786 y Ft(First)11 b(we)i(calculate)f(the)h(Cartesian)f(product)g
- Fk(R)f Fo( 02)g Fk(S)k Ft(and)d(get:)604 2923 y Fr(R)30
- 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
- 2983 y(---+---+-----+-----+---+---)843 3042 y(1)g(|)f(2)h(|)60
- b(3)g(|)f(3)h(|)30 b(a)f(|)h(b)843 3102 y(1)g(|)f(2)h(|)60
- b(3)g(|)f(6)h(|)30 b(c)f(|)h(d)843 3162 y(4)g(|)f(5)h(|)60
- b(6)g(|)f(3)h(|)30 b(a)f(|)h(b)843 3222 y(4)g(|)f(5)h(|)60
- b(6)g(|)f(6)h(|)30 b(c)f(|)h(d)843 3281 y(7)g(|)f(8)h(|)60
- b(9)g(|)f(3)h(|)30 b(a)f(|)h(b)843 3341 y(7)g(|)f(8)h(|)60
- b(9)g(|)f(6)h(|)30 b(c)f(|)h(d)p eop
- %%Page: 13 13
- 13 12 bop 198 60 a Fm(1.2.)29 b(OPERA)-6 b(TIONS)12 b(IN)g(THE)i(RELA)
- -6 b(TION)n(AL)14 b(D)n(A)-6 b(T)h(A)14 b(MODEL)521 b
- Ft(13)323 234 y(After)11 b(the)h(selection)h Fk( 33)731
- 241 y Ff(R:C)r Fg(=)p Ff(S:C)905 234 y Fl(()p Fk(R)e
- Fo( 02)g Fk(S)s Fl())h Ft(we)h(get:)771 347 y Fr(A)30
- b(|)f(B)h(|)g(R.C)g(|)f(S.C)h(|)g(D)f(|)h(E)741 407 y
- (---+---+-----+-----+---+---)771 467 y(1)g(|)f(2)h(|)60
- b(3)g(|)f(3)h(|)30 b(a)f(|)h(b)771 526 y(4)g(|)f(5)h(|)60
- b(6)g(|)f(6)h(|)30 b(c)f(|)h(d)323 639 y Ft(T)l(o)16
- b(remo)o(v)o(e)g(the)f(duplicate)h(column)f Fk(S:C)k
- Ft(we)d(project)f(it)h(out)f(by)h(the)g(follo)o(wing)e(operation:)323
- 699 y Fk( 31)351 706 y Ff(R:A;R:B)r(;R:C;S:D)q(;S:E)754
- 699 y Fl(()p Fk( 33)801 706 y Ff(R:C)r Fg(=)p Ff(S:C)975
- 699 y Fl(()p Fk(R)e Fo( 02)f Fk(S)s Fl()))h Ft(and)h(get:)890
- 812 y Fr(A)30 b(|)g(B)g(|)g(C)f(|)h(D)g(|)g(E)861 872
- y(---+---+---+---+---)890 931 y(1)g(|)g(2)g(|)g(3)f(|)h(a)g(|)g(b)890
- 991 y(4)g(|)g(5)g(|)g(6)f(|)h(c)g(|)g(d)273 1104 y Fo( 17)25
- b Ft(DIVIDE)11 b(()p Fo( 04)p Ft():)k(Let)d Fk(R)g
- Ft(be)g(a)g(table)g(with)f(the)h(attrib)o(utes)f Fk(A;)d(B)r(;)g(C)16
- b Ft(and)c Fk(D)i Ft(and)d(let)h Fk(S)i Ft(be)e(a)g(table)323
- 1164 y(with)i(the)h(attrib)o(utes)f Fk(C)k Ft(and)d Fk(D)q
- Ft(.)24 b(Then)16 b(we)f(de 02ne)g(the)f(di)o(vision)h(as:)21
- b Fk(R)13 b Fo( 04)g Fk(S)21 b Fl(=)e Fo(f)p Fk(t)f
- Fo(j)g(8)p Fk(t)1926 1171 y Ff(s)1965 1164 y Fo(2)323
- 1224 y Fk(S)c Fo(9)p Fk(t)414 1231 y Ff(r)450 1224 y
- Fo(2)g Fk(R)e Ft(such)g(that)g Fk(t)755 1231 y Ff(r)777
- 1224 y Fl(()p Fk(A;)c(B)r Fl())15 b(=)f Fk(t)21 b Fo(^)h
- Fk(t)1094 1231 y Ff(r)1116 1224 y Fl(()p Fk(C)q(;)8
- b(D)q Fl())15 b(=)e Fk(t)1340 1231 y Ff(s)1362 1224
- y Fo(g)f Ft(where)f Fk(t)1550 1231 y Ff(r)1572 1224 y
- Fl(()p Fk(x;)d(y)r Fl())14 b Ft(denotes)e(a)g(tuple)323
- 1283 y(of)i(table)g Fk(R)h Ft(that)g(consists)g(only)f(of)g(the)h
- (components)f Fk(x)i Ft(and)e Fk(y)r Ft(.)23 b(Note)14
- b(that)h(the)f(tuple)h Fk(t)f Ft(only)323 1343 y(consists)f(of)f(the)g
- (components)g Fk(A)h Ft(and)f Fk(B)j Ft(of)d(relation)g
- Fk(R)p Ft(.)323 1459 y Fn(Example)g(1.2)25 b Ft(Gi)o(v)o(en)13
- b(the)f(follo)o(wing)f(tables)621 1571 y Fr(R)90 b(A)30
- b(|)g(B)f(|)h(C)g(|)g(D)239 b(S)89 b(C)30 b(|)g(D)711
- 1631 y(---+---+---+---)297 b(---+---)741 1691 y(a)30
- 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
- (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
- 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)
- 741 1990 y(a)g(|)g(b)f(|)h(d)g(|)g(e)323 2103 y Fk(R)11
- b Fo( 04)h Fk(S)i Ft(is)f(deri)o(v)o(ed)f(as)1070 2216
- y Fr(A)30 b(|)f(B)1040 2275 y(---+---)1070 2335 y(a)h(|)f(b)1070
- 2395 y(e)h(|)f(d)198 2508 y Ft(F)o(or)12 b(a)g(more)g(detailed)g
- (description)g(and)g(de 02nition)g(of)g(the)g(relational)g(algebra)g
- (refer)f(to)h([ULL88])h(or)198 2568 y([D)n(A)-6 b(TE94)q(].)198
- 2683 y Fn(Example)13 b(1.3)25 b Ft(Recall)12 b(that)g(we)h(formulated)e
- (all)h(those)g(relational)g(operators)f(to)h(be)h(able)f(to)g(retrie)o
- (v)o(e)198 2743 y(data)i(from)e(the)i(database.)20 b(Let')m(s)14
- b(return)f(to)g(our)g(e)o(xample)h(of)f(section)h(1.2)g(where)f
- (someone)h(wanted)198 2803 y(to)d(kno)o(w)f(the)h(names)g(of)g(all)g
- (suppliers)f(that)h(sell)g(the)g(part)g('Scre)o(w'.)i(This)f(question)f
- (can)g(be)g(answered)198 2862 y(using)h(relational)g(algebra)g(by)g
- (the)h(follo)o(wing)e(operation:)222 2965 y Fk( 31)250
- 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
- 2965 y Fl(()p Fk( 33)704 2972 y Ff(P)g(ART)s(:P)g(N)t(AM)t(E)r
- Fg(=)1033 2963 y Fd(0)1047 2972 y Ff(S)r(cr)q(ew)1159
- 2963 y Fd(0)1176 2965 y Fl(()p Fk(S)s(U)g(P)i(P)g(LI)t(E)s(R)13
- b Fe(1)h Fk(S)s(E)s(LLS)h Fe(1)f Fk(P)7 b(ART)g Fl()))198
- 3068 y Ft(W)l(e)14 b(call)g(such)g(an)g(operation)g(a)g(query)m(.)20
- b(If)13 b(we)h(e)o(v)o(aluate)f(the)h(abo)o(v)o(e)h(query)e(against)h
- (the)g(tables)g(form)198 3128 y( 02gure)e(1.1)g Fp(The)h(suppliers)f
- (and)g(parts)h(database)g Ft(we)f(will)g(obtain)g(the)g(follo)o(wing)f
- (result:)1065 3222 y Fr(SNAME)1035 3282 y(-------)1065
- 3342 y(Smith)1065 3402 y(Adams)p eop
- %%Page: 14 14
- 14 13 bop 270 60 a Ft(14)1351 b Fm(CHAPTER)14 b(1.)28
- b(SQL)270 234 y Fh(1.2.2)59 b(Relational)14 b(Calculus)270
- 332 y Ft(The)20 b(relational)f(calculus)g(is)h(based)g(on)f(the)g
- ( 02rst)g(order)g(logic.)37 b(There)19 b(are)h(two)e(v)o(ariants)h(of)
- g(the)270 391 y(relational)12 b(calculus:)345 498 y Fo( 17)25
- b Ft(The)13 b Fp(Domain)g(Relational)f(Calculus)i Ft((DRC),)f(where)g
- (v)o(ariables)f(stand)i(for)e(components)h((at-)395
- 557 y(trib)o(utes))e(of)h(the)g(tuples.)345 666 y Fo( 17)25
- b Ft(The)12 b Fp(T)m(uple)h(Relational)f(Calculus)g Ft((TRC),)h
- (where)f(v)o(ariables)g(stand)h(for)f(tuples.)270 772
- y(W)l(e)j(want)g(to)g(discuss)h(the)f(tuple)g(relational)f(calculus)h
- (only)g(because)h(it)f(is)g(the)g(one)g(underlying)f(the)270
- 832 y(most)c(relational)g(languages.)16 b(F)o(or)10 b(a)g(detailed)g
- (discussion)h(on)g(DRC)g((and)f(also)h(TRC))g(see)g([D)n(A)-6
- b(TE94])270 891 y(or)12 b([ULL88].)270 1036 y Fn(T)-5
- b(uple)12 b(Relational)g(Calculus)270 1133 y Ft(The)h(queries)f(used)h
- (in)f(TRC)i(are)e(of)g(the)g(follo)o(wing)f(form:)1019
- 1247 y Fo(f)p Fk(x)p Fl(()p Fk(A)p Fl())k Fo(j)f Fk(F)7
- b Fl(()p Fk(x)p Fl())p Fo(g)270 1361 y Ft(where)k Fk(x)h
- Ft(is)g(a)f(tuple)g(v)o(ariable)g Fk(A)h Ft(is)g(a)f(set)h(of)f(attrib)
- o(utes)g(and)g Fk(F)19 b Ft(is)11 b(a)h(formula.)i(The)e(resulting)f
- (relation)270 1421 y(consists)i(of)f(all)g(tuples)h Fk(t)p
- Fl(()p Fk(A)p Fl())g Ft(that)g(satisfy)f Fk(F)7 b Fl(()p
- Fk(t)p Fl())p Ft(.)270 1554 y Fn(Example)13 b(1.4)25
- b Ft(If)9 b(we)h(want)g(to)g(answer)g(the)g(question)g(from)f(e)o
- (xample)h(1.3)g(using)g(TRC)h(we)f(formulate)270 1613
- y(the)i(follo)o(wing)f(query:)370 1725 y Fo(f)p Fk(x)p
- Fl(()p Fk(S)s(N)5 b(AM)g(E)s Fl())51 b Fo(j)f Fk(x)14
- b Fo(2)g Fk(S)s(U)5 b(P)i(P)g(LI)t(E)s(R)12 b Fo(^)785
- 1785 y(9)p Fk(y)k Fo(2)e Fk(S)s(E)s(LLS)g Fo(9)p Fk(z)h
- Fo(2)f Fk(P)7 b(ART)58 b Fl(()p Fk(y)r Fl(()p Fk(S)s(N)5
- b(O)q Fl())15 b(=)f Fk(x)p Fl(()p Fk(S)s(N)5 b(O)q
- Fl())14 b Fo(^)1413 1845 y Fk(z)r Fl(()p Fk(P)7 b(N)e(O)q
- Fl())16 b(=)d Fk(y)r Fl(()p Fk(P)7 b(N)e(O)q Fl())15
- b Fo(^)1413 1904 y Fk(z)r Fl(()p Fk(P)7 b(N)e(AM)g(E)s
- Fl())16 b(=)1745 1886 y Fc(0)1773 1904 y Fk(S)s(cr)q(ew)1912
- 1886 y Fc(0)1926 1904 y Fl())p Fo(g)270 2016 y Ft(Ev)o(aluating)f(the)
- h(query)f(against)h(the)f(tables)h(from)e( 02gure)h(1.1)h
- Fp(The)g(suppliers)g(and)f(parts)h(database)270 2075
- y Ft(again)c(leads)h(to)f(the)g(same)h(result)f(as)h(in)g(e)o(xample)f
- (1.3.)270 2230 y Fh(1.2.3)59 b(Relational)14 b(Algebra)f(vs.)19
- b(Relational)13 b(Calculus)270 2327 y Ft(The)j(relational)g(algebra)f
- (and)h(the)g(relational)f(calculus)i(ha)o(v)o(e)f(the)g(same)g
- Fp(e)o(xpr)n(essive)i(power)e Ft(i.e.)h(all)270 2387
- y(queries)g(that)f(can)i(be)e(formulated)g(using)h(relational)f
- (algebra)h(can)g(also)g(be)g(formulated)e(using)i(the)270
- 2447 y(relational)9 b(calculus)h(and)g(vice)g(v)o(ersa.)16
- b(This)10 b(was)g( 02rst)g(pro)o(v)o(ed)g(by)g(E.)h(F)l(.)f(Codd)g(in)
- g(1972.)k(This)d(proof)e(is)270 2507 y(based)k(on)g(an)f(algorithm)g
- (-224Codd')m(s)g(reduction)g(algorithm224-)f(by)h(which)h(an)f
- (arbitrary)g(e)o(xpression)h(of)270 2567 y(the)g(relational)f(calculus)
- h(can)g(be)g(reduced)f(to)h(a)g(semantically)f(equi)o(v)o(alent)g(e)o
- (xpression)i(of)e(relational)270 2626 y(algebra.)j(F)o(or)d(a)h(more)f
- (detailed)g(discussion)h(on)f(that)g(refer)g(to)g([D)n(A)-6
- b(TE94)q(])12 b(and)g([ULL88].)345 2688 y(It)i(is)h(sometimes)g(said)g
- (that)f(languages)h(based)g(on)g(the)f(relational)g(calculus)h(are)g
- (224higher)f(le)o(v)o(el224)270 2748 y(or)e(224more)g(declarati)o(v)
- o(e224)h(than)f(languages)h(based)g(on)f(relational)g(algebra)g
- (because)h(the)g(algebra)f((par)o(-)270 2808 y(tially))i(speci 02es)
- h(the)g(order)f(of)g(operations)h(while)f(the)h(calculus)g(lea)o(v)o
- (es)h(it)e(to)h(a)g(compiler)f(or)g(inter)o(-)270 2868
- y(preter)e(to)g(determine)f(the)i(most)f(ef)o( 02cient)g(order)f(of)h
- (e)o(v)o(aluation.)270 3048 y Fi(1.3)71 b(The)18 b(SQL)f(Language)270
- 3163 y Ft(As)11 b(most)f(modern)g(relational)f(languages)i(SQL)f(is)h
- (based)g(on)f(the)g(tuple)g(relational)g(calculus.)15
- b(As)c(a)g(re-)270 3223 y(sult)i(e)o(v)o(ery)f(query)g(that)h(can)g(be)
- f(formulated)g(using)g(the)h(tuple)f(relational)g(calculus)h((or)f
- (equi)o(v)o(alently)m(,)270 3283 y(relational)g(algebra))h(can)g(also)
- h(be)f(formulated)f(using)i(SQL.)g(There)f(are,)h(ho)o(we)o(v)o(er)n(,)
- f(capabilities)g(be-)270 3342 y(yond)h(the)f(scope)i(of)e(relational)h
- (algebra)f(or)h(calculus.)20 b(Here)14 b(is)g(a)h(list)e(of)h(some)g
- (additional)f(features)270 3402 y(pro)o(vided)f(by)g(SQL)h(that)f(are)g
- (not)g(part)g(of)g(relational)g(algebra)g(or)g(calculus:)p
- eop
- %%Page: 15 15
- 15 14 bop 198 60 a Fm(1.3.)29 b(THE)13 b(SQL)f(LANGU)n(A)n(GE)1160
- b Ft(15)273 234 y Fo( 17)25 b Ft(Commands)12 b(for)f(insertion,)i
- (deletion)f(or)g(modi 02cation)f(of)h(data.)273 333
- y Fo( 17)25 b Ft(Arithmetic)12 b(capability:)17 b(In)c(SQL)h(it)g(is)f
- (possible)h(to)g(in)n(v)o(olv)o(e)f(arithmetic)g(operations)g(as)h
- (well)323 393 y(as)g(comparisons,)h(e.g.)22 b Fk(A)c(<)f(B)e
- Fl(+)d(3)p Ft(.)21 b(Note)15 b(that)f Fl(+)g Ft(or)g(other)f
- (arithmetic)h(operators)f(appear)323 453 y(neither)e(in)i(relational)e
- (algebra)h(nor)g(in)g(relational)g(calculus.)273 552
- y Fo( 17)25 b Ft(Assignment)14 b(and)g(Print)g(Commands:)19
- b(It)14 b(is)g(possible)h(to)f(print)g(a)g(relation)g(constructed)g(by)
- g(a)323 612 y(query)d(and)i(to)f(assign)h(a)g(computed)e(relation)h(to)
- g(a)h(relation)f(name.)273 711 y Fo( 17)25 b Ft(Aggre)o(gate)15
- b(Functions:)22 b(Operations)16 b(such)g(as)h Fp(aver)o(age)p
- Ft(,)g Fp(sum)p Ft(,)h Fp(max)p Ft(,)f(.)7 b(.)g(.)g(can)19
- b(be)d(applied)g(to)323 771 y(columns)c(of)g(a)g(relation)g(to)g
- (obtain)g(a)h(single)f(quantity)m(.)198 913 y Fh(1.3.1)59
- b(Select)198 1006 y Ft(The)17 b(most)f(often)g(used)h(command)f(in)g
- (SQL)h(is)f(the)h(SELECT)h(statement)e(that)g(is)h(used)g(to)f(retrie)o
- (v)o(e)198 1066 y(data.)g(The)d(syntax)f(is:)288 1165
- y Fr(SELECT)29 b([ALL|DISTINCT])497 1225 y({)h(*)f(|)h(<expr_1>)f([AS)h
- (<c_alias_1>])e([,)i(...)676 1285 y([,)g(<expr_k>)f([AS)g
- (<c_alias_k>]]]})288 1344 y(FROM)g(<table_name_1>)f([t_alias_1])437
- 1404 y([,)i(...)f([,)h(<table_name_n>)e([t_alias_n]]])288
- 1464 y([WHERE)h(condition])288 1524 y([GROUP)g(BY)h(<name_of_attr_i>)
- 587 1583 y([,...)f([,)h(<name_of_attr_j>]])d([HAVING)j(condition]])288
- 1643 y([{UNION)f(|)h(INTERSECT)e(|)i(EXCEPT})f(SELECT)h(...])288
- 1703 y([ORDER)f(BY)h(<name_of_attr_i>)e([ASC|DESC])587
- 1763 y([,)h(...)h([,)f(<name_of_attr_j>)g([ASC|DESC]]]];)198
- 1861 y Ft(No)o(w)15 b(we)g(will)g(illustrate)g(the)g(comple)o(x)g
- (syntax)g(of)g(the)g(SELECT)i(statement)f(with)f(v)o(arious)f(e)o(xam-)
- 198 1921 y(ples.)28 b(The)17 b(tables)g(used)f(for)g(the)g(e)o(xamples)
- h(are)f(de 02ned)g(in)g( 02gure)g(1.1)h Fp(The)f(suppliers)g(and)h
- (parts)198 1981 y(database)p Ft(.)198 2113 y Fn(Simple)12
- b(Selects)198 2207 y(Example)h(1.5)25 b Ft(Here)12 b(are)g(some)h
- (simple)f(e)o(xamples)h(using)f(a)h(SELECT)h(statement:)198
- 2326 y(T)l(o)23 b(retrie)o(v)o(e)f(all)h(tuples)g(from)f(table)g(P)-5
- b(AR)m(T)24 b(where)f(the)f(attrib)o(ute)g(PRICE)h(is)g(greater)g(than)
- f(10)198 2386 y(we)13 b(formulate)e(the)h(follo)o(wing)f(query)288
- 2485 y Fr(SELECT)29 b(*)288 2545 y(FROM)g(PART)288 2604
- y(WHERE)g(PRICE)g(>)h(10;)198 2703 y Ft(and)12 b(get)h(the)f(table:)766
- 2802 y Fr(PNO)29 b(|)60 b(PNAME)f(|)h(PRICE)736 2862
- y(-----+---------+--------)796 2921 y(3)f(|)h(Bolt)89
- b(|)h(15)796 2981 y(4)59 b(|)h(Cam)119 b(|)90 b(25)198
- 3080 y Ft(Using)12 b(224)p Fo( 03)p Ft(224)g(in)g(the)g(SELECT)i
- (statement)e(will)g(deli)o(v)o(er)f(all)h(attrib)o(utes)g(from)f(the)h
- (table.)j(If)d(we)g(want)f(to)198 3140 y(retrie)o(v)o(e)h(only)g(the)g
- (attrib)o(utes)g(PN)n(AME)h(and)f(PRICE)h(from)e(table)h(P)-5
- b(AR)m(T)14 b(we)e(use)h(the)f(statement:)288 3238 y
- Fr(SELECT)29 b(PNAME,)g(PRICE)288 3298 y(FROM)g(PART)288
- 3358 y(WHERE)g(PRICE)g(>)h(10;)p eop
- %%Page: 16 16
- 16 15 bop 270 60 a Ft(16)1351 b Fm(CHAPTER)14 b(1.)28
- b(SQL)270 234 y Ft(In)12 b(this)g(case)i(the)e(result)g(is:)928
- 339 y Fr(PNAME)59 b(|)g(PRICE)898 399 y(--------+--------)928
- 459 y(Bolt)89 b(|)g(15)928 519 y(Cam)119 b(|)89 b(25)270
- 622 y Ft(Note)12 b(that)f(the)h(SQL)g(SELECT)i(corresponds)e(to)f(the)h
- (224projection224)f(in)h(relational)f(algebra)h(not)f(to)h(the)270
- 682 y(224selection224)h((see)f(section)h(1.2.1)g Fp(Relational)f
- (Algebr)o(a)p Ft().)270 802 y(The)26 b(quali 02cations)g(in)g(the)f
- (WHERE)i(clause)g(can)f(also)g(be)g(logically)f(connected)h(using)g
- (the)270 862 y(ke)o(ywords)11 b(OR,)i(AND)g(and)f(NO)n(T)n(:)360
- 967 y Fr(SELECT)29 b(PNAME,)g(PRICE)360 1027 y(FROM)g(PART)360
- 1086 y(WHERE)g(PNAME)g(=)h('Bolt')f(AND)539 1146 y((PRICE)g(=)h(0)g
- (OR)f(PRICE)h(<)g(15);)270 1250 y Ft(will)12 b(lead)g(to)h(the)f
- (result:)928 1355 y Fr(PNAME)59 b(|)g(PRICE)898 1415
- y(--------+--------)928 1475 y(Bolt)89 b(|)g(15)270 1578
- y Ft(Arithmetic)10 b(operations)g(may)h(be)g(used)g(in)g(the)f
- Fp(selectlist)i Ft(and)e(in)h(the)g(WHERE)h(clause.)k(F)o(or)10
- 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
- (it)g(would)g(cost)h(if)f(we)h(take)f(two)g(pieces)h(of)f(a)h(part)f
- (we)h(could)g(use)270 1698 y(the)d(follo)o(wing)f(query:)360
- 1803 y Fr(SELECT)29 b(PNAME,)g(PRICE)g(*)h(2)g(AS)g(DOUBLE)360
- 1863 y(FROM)f(PART)360 1923 y(WHERE)g(PRICE)g(*)h(2)g(<)g(50;)270
- 2027 y Ft(and)12 b(we)h(get:)928 2132 y Fr(PNAME)59 b(|)g(DOUBLE)898
- 2191 y(--------+---------)928 2251 y(Screw)g(|)119 b(20)928
- 2311 y(Nut)g(|)g(16)928 2371 y(Bolt)89 b(|)119 b(30)270
- 2475 y Ft(Note)14 b(that)f(the)h(word)e(DOUBLE)j(after)e(the)g(ke)o
- (yword)g(AS)g(is)h(the)g(ne)o(w)f(title)g(of)g(the)h(second)g(column.)
- 270 2534 y(This)i(technique)f(can)h(be)g(used)g(for)e(e)o(v)o(ery)h
- (element)h(of)f(the)g Fp(selectlist)h Ft(to)g(assign)g(a)f(ne)o(w)h
- (title)f(to)g(the)270 2594 y(resulting)i(column.)32 b(This)19
- b(ne)o(w)f(title)f(is)i(often)e(referred)g(to)g(as)i(alias.)33
- b(The)18 b(alias)h(cannot)f(be)g(used)270 2654 y(throughout)11
- b(the)h(rest)h(of)f(the)g(query)m(.)270 2794 y Fn(J)o(oins)270
- 2890 y(Example)h(1.6)25 b Ft(The)13 b(follo)o(wing)e(e)o(xample)h(sho)o
- (ws)h(ho)o(w)f Fp(joins)g Ft(are)g(realized)h(in)f(SQL:)270
- 3010 y(T)l(o)23 b(join)g(the)g(three)g(tables)g(SUPPLIER,)g(P)-5
- b(AR)m(T)24 b(and)f(SELLS)h(o)o(v)o(er)f(their)f(common)h(attrib)o
- (utes)270 3070 y(we)13 b(formulate)e(the)h(follo)o(wing)f(statement:)
- 360 3175 y Fr(SELECT)29 b(S.SNAME,)g(P.PNAME)360 3235
- y(FROM)g(SUPPLIER)g(S,)h(PART)f(P,)h(SELLS)f(SE)360 3294
- y(WHERE)g(S.SNO)g(=)h(SE.SNO)f(AND)539 3354 y(P.PNO)g(=)h(SE.PNO;)p
- eop
- %%Page: 17 17
- 17 16 bop 198 60 a Fm(1.3.)29 b(THE)13 b(SQL)f(LANGU)n(A)n(GE)1160
- b Ft(17)198 234 y(and)12 b(get)h(the)f(follo)o(wing)f(table)h(as)h(a)g
- (result:)885 330 y Fr(SNAME)30 b(|)g(PNAME)856 390 y(-------+-------)
- 885 450 y(Smith)g(|)g(Screw)885 510 y(Smith)g(|)g(Nut)885
- 570 y(Jones)g(|)g(Cam)885 629 y(Adams)g(|)g(Screw)885
- 689 y(Adams)g(|)g(Bolt)885 749 y(Blake)g(|)g(Nut)885
- 809 y(Blake)g(|)g(Bolt)885 868 y(Blake)g(|)g(Cam)198
- 965 y Ft(In)11 b(the)h(FR)n(OM)g(clause)g(we)g(introduced)f(an)h(alias)
- g(name)g(for)f(e)o(v)o(ery)g(relation)g(because)i(there)e(are)h(com-)
- 198 1025 y(mon)j(named)g(attrib)o(utes)f((SNO)g(and)h(PNO))g(among)f
- (the)h(relations.)24 b(No)o(w)14 b(we)h(can)h(distinguish)e(be-)198
- 1084 y(tween)g(the)h(common)f(named)g(attrib)o(utes)g(by)g(simply)g
- (pre 02xing)g(the)g(attrib)o(ute)g(name)g(with)g(the)h(alias)198
- 1144 y(name)f(follo)o(wed)e(by)i(a)g(dot.)20 b(The)14
- b(join)g(is)g(calculated)g(in)f(the)h(same)g(way)g(as)g(sho)o(wn)g(in)f
- (e)o(xample)h(1.1.)198 1204 y(First)d(the)g(Cartesian)h(product)e
- Fk(S)s(U)5 b(P)i(P)g(LI)t(E)s(R)g Fo( 02)g Fk(P)g(ART)14
- 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
- (only)g(those)198 1264 y(tuples)i(satisfying)h(the)f(conditions)g(gi)o
- (v)o(en)g(in)g(the)h(WHERE)g(clause)g(are)f(selected)h((i.e.)g(the)g
- (common)198 1323 y(named)g(attrib)o(utes)f(ha)o(v)o(e)h(to)g(be)g
- (equal).)20 b(Finally)13 b(we)h(project)f(out)g(all)h(columns)g(b)o
- (ut)f(S.SN)n(AME)i(and)198 1383 y(P)-6 b(.PN)n(AME.)198
- 1515 y Fn(Aggr)o(egate)12 b(Operators)198 1608 y Ft(SQL)k(pro)o(vides)f
- (aggre)o(gate)g(operators)g((e.g.)25 b(A)-7 b(V)o(G,)16
- b(COUNT)l(,)h(SUM,)f(MIN,)g(MAX))f(that)g(take)g(the)198
- 1668 y(name)d(of)f(an)h(attrib)o(ute)f(as)i(an)f(ar)o(gument.)j(The)d
- (v)o(alue)g(of)f(the)h(aggre)o(gate)g(operator)f(is)h(calculated)g(o)o
- (v)o(er)198 1728 y(all)i(v)o(alues)g(of)g(the)g(speci 02ed)g(attrib)o
- (ute)f((column))g(of)g(the)h(whole)g(table.)21 b(If)13
- b(groups)h(are)g(speci 02ed)g(in)198 1788 y(the)e(query)g(the)h
- (calculation)f(is)g(done)h(only)f(o)o(v)o(er)g(the)g(v)o(alues)h(of)f
- (a)g(group)g((see)h(ne)o(xt)f(section).)198 1905 y
- 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
- (v)o(erage)h(cost)h(of)e(all)g(parts)h(in)g(table)f(P)-5
- b(AR)m(T)17 b(we)f(use)g(the)198 1965 y(follo)o(wing)11
- b(query:)288 2061 y Fr(SELECT)29 b(AVG(PRICE))g(AS)g(AVG_PRICE)288
- 2121 y(FROM)g(PART;)198 2217 y Ft(The)13 b(result)f(is:)945
- 2313 y Fr(AVG_PRICE)915 2373 y(-----------)1005 2433
- 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
- (parts)h(are)f(stored)g(in)g(table)h(P)-5 b(AR)m(T)13
- b(we)f(use)h(the)g(statement:)288 2626 y Fr(SELECT)29
- b(COUNT(PNO))288 2685 y(FROM)g(PART;)198 2782 y Ft(and)12
- b(get:)1005 2878 y Fr(COUNT)975 2938 y(-------)1065 2998
- y(4)198 3130 y Fn(Aggr)o(egation)f(by)h(Gr)o(oups)198
- 3223 y Ft(SQL)18 b(allo)o(ws)f(to)h(partition)f(the)g(tuples)h(of)f(a)h
- (table)g(into)f(groups.)31 b(Then)19 b(the)e(aggre)o(gate)h(operators)
- 198 3283 y(described)12 b(abo)o(v)o(e)i(can)e(be)h(applied)f(to)g(the)h
- (groups)f((i.e.)k(the)d(v)o(alue)f(of)g(the)h(aggre)o(gate)f(operator)
- f(is)i(no)198 3342 y(longer)f(calculated)g(o)o(v)o(er)h(all)f(the)h(v)o
- (alues)f(of)g(the)g(speci 02ed)h(column)f(b)o(ut)g(o)o(v)o(er)h(all)f
- (v)o(alues)h(of)f(a)g(group.)198 3402 y(Thus)h(the)f(aggre)o(gate)g
- (operator)g(is)h(e)o(v)o(aluated)e(indi)o(vidually)g(for)h(e)o(v)o(ery)
- g(group.))p eop
- %%Page: 18 18
- 18 17 bop 270 60 a Ft(18)1351 b Fm(CHAPTER)14 b(1.)28
- b(SQL)270 294 y Ft(The)21 b(partitioning)e(of)h(the)g(tuples)h(into)f
- (groups)g(is)h(done)f(by)g(using)h(the)f(ke)o(ywords)g(GR)n(OUP)12
- b(BY)270 354 y(follo)o(wed)g(by)h(a)g(list)g(of)g(attrib)o(utes)f(that)
- h(de 02ne)g(the)g(groups.)18 b(If)12 b(we)h(ha)o(v)o(e)h
- Fr(GROUP)29 b(BY)h Fk(A)1875 361 y Fg(1)1897 354 y Fk(;)8
- b(:)g(:)g(:)h(;)f(A)2045 361 y Ff(k)270 413 y Ft(we)k(partition)f(the)h
- (relation)f(into)h(groups,)g(such)g(that)g(two)f(tuples)i(are)e(in)h
- (the)g(same)h(group)e(if)g(and)h(only)270 473 y(if)g(the)o(y)g(agree)h
- (on)f(all)g(the)h(attrib)o(utes)e Fk(A)962 480 y Fg(1)985
- 473 y Fk(;)d(:)g(:)g(:)h(;)f(A)1133 480 y Ff(k)1158 473
- y Ft(.)270 600 y Fn(Example)13 b(1.8)25 b Ft(If)11 b(we)h(want)g(to)g
- (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
- (supplier)h(we)g(formulate)270 660 y(the)g(query:)360
- 764 y Fr(SELECT)29 b(S.SNO,)g(S.SNAME,)g(COUNT(SE.PNO))360
- 824 y(FROM)g(SUPPLIER)g(S,)h(SELLS)f(SE)360 883 y(WHERE)g(S.SNO)g(=)h
- (SE.SNO)360 943 y(GROUP)f(BY)h(S.SNO,)f(S.SNAME;)270
- 1046 y Ft(and)12 b(get:)898 1151 y Fr(SNO)29 b(|)h(SNAME)f(|)h(COUNT)
- 868 1210 y(-----+-------+-------)928 1270 y(1)59 b(|)30
- b(Smith)f(|)90 b(2)928 1330 y(2)59 b(|)30 b(Jones)f(|)90
- b(1)928 1390 y(3)59 b(|)30 b(Adams)f(|)90 b(2)928 1450
- y(4)59 b(|)30 b(Blake)f(|)90 b(3)270 1553 y Ft(No)o(w)12
- b(let')m(s)h(ha)o(v)o(e)f(a)h(look)f(of)g(what)g(is)h(happening)f
- (here:)270 1612 y(First)g(the)g(join)g(of)g(the)g(tables)h(SUPPLIER)f
- (and)h(SELLS)g(is)f(deri)o(v)o(ed:)808 1717 y Fr(S.SNO)29
- b(|)h(S.SNAME)f(|)h(SE.PNO)778 1777 y(-------+---------+--------)868
- 1836 y(1)89 b(|)60 b(Smith)f(|)90 b(1)868 1896 y(1)f(|)60
- b(Smith)f(|)90 b(2)868 1956 y(2)f(|)60 b(Jones)f(|)90
- b(4)868 2016 y(3)f(|)60 b(Adams)f(|)90 b(1)868 2075 y(3)f(|)60
- b(Adams)f(|)90 b(3)868 2135 y(4)f(|)60 b(Blake)f(|)90
- b(2)868 2195 y(4)f(|)60 b(Blake)f(|)90 b(3)868 2255 y(4)f(|)60
- b(Blake)f(|)90 b(4)270 2358 y Ft(Ne)o(xt)16 b(we)g(partition)f(the)h
- (tuples)g(into)f(groups)h(by)g(putting)f(all)h(tuples)g(together)f
- (that)h(agree)g(on)f(both)270 2418 y(attrib)o(utes)d(S.SNO)g(and)g
- (S.SN)n(AME:)808 2522 y Fr(S.SNO)29 b(|)h(S.SNAME)f(|)h(SE.PNO)778
- 2582 y(-------+---------+--------)868 2642 y(1)89 b(|)60
- b(Smith)f(|)90 b(1)1286 2701 y(|)g(2)778 2761 y
- (--------------------------)868 2821 y(2)f(|)60 b(Jones)f(|)90
- b(4)778 2881 y(--------------------------)868 2940 y(3)f(|)60
- b(Adams)f(|)90 b(1)1286 3000 y(|)g(3)778 3060 y
- (--------------------------)868 3120 y(4)f(|)60 b(Blake)f(|)90
- b(2)1286 3180 y(|)g(3)1286 3239 y(|)g(4)270 3342 y Ft(In)13
- b(our)f(e)o(xample)i(we)f(got)g(four)f(groups)h(and)g(no)o(w)g(we)g
- (can)g(apply)g(the)g(aggre)o(gate)g(operator)f(COUNT)270
- 3402 y(to)g(e)o(v)o(ery)g(group)g(leading)g(to)g(the)h(total)f(result)g
- (of)g(the)g(query)g(gi)o(v)o(en)g(abo)o(v)o(e.)p eop
- %%Page: 19 19
- 19 18 bop 198 60 a Fm(1.3.)29 b(THE)13 b(SQL)f(LANGU)n(A)n(GE)1160
- b Ft(19)198 234 y(Note)11 b(that)f(for)g(the)h(result)g(of)f(a)h(query)
- f(using)h(GR)n(OUP)g(BY)g(and)g(aggre)o(gate)f(operators)g(to)h(make)f
- (sense)198 294 y(the)16 b(attrib)o(utes)f(grouped)h(by)f(must)h(also)h
- (appear)e(in)h(the)g Fp(selectlist)p Ft(.)27 b(All)16
- b(further)e(attrib)o(utes)i(not)f(ap-)198 354 y(pearing)d(in)g(the)g
- (GR)n(OUP)g(BY)h(clause)g(can)f(only)g(be)h(selected)f(by)h(using)f(an)
- g(aggre)o(gate)g(function.)j(On)198 413 y(the)f(other)f(hand)g(you)g
- (can)h(not)f(use)h(aggre)o(gate)g(functions)f(on)g(attrib)o(utes)g
- (appearing)g(in)h(the)f(GR)n(OUP)198 473 y(BY)g(clause.)198
- 606 y Fn(Ha)o(ving)198 699 y Ft(The)18 b(HA)-7 b(VING)17
- b(clause)i(works)e(much)g(like)g(the)g(WHERE)i(clause)f(and)g(is)g
- (used)g(to)f(consider)g(only)198 759 y(those)h(groups)g(satisfying)f
- (the)h(quali 02cation)f(gi)o(v)o(en)h(in)g(the)f(HA)-7
- b(VING)18 b(clause.)33 b(The)18 b(e)o(xpressions)198
- 818 y(allo)o(wed)13 b(in)h(the)g(HA)-7 b(VING)13 b(clause)i(must)e(in)n
- (v)o(olv)o(e)h(aggre)o(gate)f(functions.)20 b(Ev)o(ery)14
- b(e)o(xpression)g(using)198 878 y(only)h(plain)h(attrib)o(utes)f
- (belongs)h(to)g(the)g(WHERE)h(clause.)27 b(On)15 b(the)h(other)f(hand)h
- (e)o(v)o(ery)g(e)o(xpression)198 938 y(in)n(v)o(olving)11
- b(an)i(aggre)o(gate)f(function)f(must)i(be)f(put)g(to)h(the)f(HA)-7
- b(VING)12 b(clause.)198 1056 y Fn(Example)h(1.9)25 b
- Ft(If)11 b(we)h(want)f(only)h(those)g(suppliers)g(selling)g(more)f
- (than)h(one)g(part)f(we)h(use)h(the)f(query:)288 1155
- y Fr(SELECT)29 b(S.SNO,)g(S.SNAME,)g(COUNT(SE.PNO))288
- 1214 y(FROM)g(SUPPLIER)g(S,)h(SELLS)f(SE)288 1274 y(WHERE)g(S.SNO)g(=)h
- (SE.SNO)288 1334 y(GROUP)f(BY)h(S.SNO,)f(S.SNAME)288
- 1394 y(HAVING)g(COUNT(SE.PNO))f(>)i(1;)198 1492 y Ft(and)12
- b(get:)826 1590 y Fr(SNO)29 b(|)h(SNAME)f(|)h(COUNT)796
- 1650 y(-----+-------+-------)856 1709 y(1)59 b(|)30 b(Smith)f(|)90
- b(2)856 1769 y(3)59 b(|)30 b(Adams)f(|)90 b(2)856 1829
- y(4)59 b(|)30 b(Blake)f(|)90 b(3)198 1961 y Fn(Subqueries)198
- 2055 y Ft(In)11 b(the)g(WHERE)i(and)e(HA)-7 b(VING)12
- b(clauses)g(the)f(use)h(of)f(subqueries)h((subselects))f(is)h(allo)o
- (wed)f(in)g(e)o(v)o(ery)198 2114 y(place)k(where)g(a)g(v)o(alue)g(is)g
- (e)o(xpected.)24 b(In)14 b(this)h(case)h(the)f(v)o(alue)g(must)g(be)g
- (deri)o(v)o(ed)f(by)h(e)o(v)o(aluating)f(the)198 2174
- y(subquery)e( 02rst.)j(The)e(usage)g(of)f(subqueries)h(e)o(xtends)g
- (the)f(e)o(xpressi)o(v)o(e)h(po)o(wer)f(of)g(SQL.)198
- 2293 y Fn(Example)h(1.10)25 b Ft(If)17 b(we)h(want)g(to)f(kno)o(w)h
- (all)g(parts)g(ha)o(ving)g(a)g(greater)f(price)h(than)g(the)g(part)f
- (named)198 2352 y('Scre)o(w')11 b(we)h(use)h(the)g(query:)288
- 2450 y Fr(SELECT)29 b(*)288 2510 y(FROM)g(PART)288 2570
- y(WHERE)g(PRICE)g(>)h((SELECT)f(PRICE)h(FROM)f(PART)736
- 2630 y(WHERE)g(PNAME='Screw');)198 2728 y Ft(The)13
- b(result)f(is:)766 2826 y Fr(PNO)29 b(|)60 b(PNAME)f(|)h(PRICE)736
- 2886 y(-----+---------+--------)796 2945 y(3)f(|)h(Bolt)89
- b(|)h(15)796 3005 y(4)59 b(|)h(Cam)119 b(|)90 b(25)198
- 3103 y Ft(When)15 b(we)g(look)g(at)g(the)g(abo)o(v)o(e)h(query)e(we)h
- (can)h(see)f(the)g(ke)o(yword)f(SELECT)j(two)d(times.)24
- b(The)15 b( 02rst)198 3163 y(one)h(at)g(the)f(be)o(ginning)h(of)f(the)
- h(query)f(-)h(we)g(will)f(refer)g(to)h(it)f(as)i(outer)e(SELECT)i(-)f
- (and)g(the)f(one)h(in)198 3223 y(the)h(WHERE)h(clause)g(which)f(be)o
- (gins)h(a)f(nested)h(query)e(-)h(we)g(will)g(refer)f(to)h(it)g(as)h
- (inner)f(SELECT)l(.)198 3283 y(F)o(or)d(e)o(v)o(ery)g(tuple)g(of)g(the)
- g(outer)g(SELECT)i(the)e(inner)g(SELECT)i(has)f(to)f(be)h(e)o(v)o
- (aluated.)21 b(After)13 b(e)o(v)o(ery)198 3342 y(e)o(v)o(aluation)f(we)
- i(kno)o(w)f(the)g(price)g(of)g(the)g(tuple)g(named)h('Scre)o(w')d(and)j
- (we)f(can)h(check)f(if)g(the)h(price)f(of)198 3402 y(the)f(actual)h
- (tuple)f(is)g(greater)m(.)p eop
- %%Page: 20 20
- 20 19 bop 270 60 a Ft(20)1351 b Fm(CHAPTER)14 b(1.)28
- b(SQL)270 294 y Ft(If)19 b(we)i(want)f(to)g(kno)o(w)f(all)i(suppliers)f
- (that)g(do)g(not)g(sell)g(an)o(y)h(part)f((e.g.)39 b(to)20
- b(be)h(able)f(to)g(remo)o(v)o(e)270 354 y(these)13 b(suppliers)f(from)f
- (the)i(database))f(we)h(use:)360 471 y Fr(SELECT)29
- b(*)360 531 y(FROM)g(SUPPLIER)g(S)360 590 y(WHERE)g(NOT)h(EXISTS)659
- 650 y((SELECT)f(*)g(FROM)h(SELLS)f(SE)688 710 y(WHERE)h(SE.SNO)f(=)h
- (S.SNO);)270 823 y Ft(In)19 b(our)h(e)o(xample)g(the)g(result)f(will)h
- (be)g(empty)f(because)i(e)o(v)o(ery)e(supplier)h(sells)g(at)g(least)g
- (one)g(part.)270 883 y(Note)15 b(that)g(we)g(use)h(S.SNO)e(from)g(the)h
- (outer)g(SELECT)i(within)d(the)h(WHERE)h(clause)g(of)f(the)g(inner)270
- 942 y(SELECT)l(.)d(As)f(described)f(abo)o(v)o(e)g(the)g(subquery)g(is)g
- (e)o(v)o(aluated)f(for)g(e)o(v)o(ery)h(tuple)g(from)e(the)i(outer)g
- (query)270 1002 y(i.e.)16 b(the)d(v)o(alue)f(for)f(S.SNO)i(is)f(always)
- g(taken)g(from)f(the)h(actual)h(tuple)f(of)g(the)g(outer)g(SELECT)l(.)
- 270 1159 y Fn(Union,)g(Intersect,)h(Except)270 1261 y
- Ft(These)19 b(operations)e(calculate)h(the)g(union,)i(intersect)d(and)h
- (set)h(theoretic)e(dif)o(ference)g(of)g(the)h(tuples)270
- 1320 y(deri)o(v)o(ed)12 b(by)g(two)g(subqueries:)270
- 1466 y Fn(Example)h(1.11)25 b Ft(The)13 b(follo)o(wing)e(query)g(is)i
- (an)g(e)o(xample)f(for)g(UNION:)360 1583 y Fr(SELECT)29
- b(S.SNO,)g(S.SNAME,)g(S.CITY)360 1643 y(FROM)g(SUPPLIER)g(S)360
- 1703 y(WHERE)g(S.SNAME)g(=)h('Jones')360 1763 y(UNION)360
- 1822 y(SELECT)f(S.SNO,)g(S.SNAME,)g(S.CITY)360 1882 y(FROM)g(SUPPLIER)g
- (S)360 1942 y(WHERE)g(S.SNAME)g(=)h('Adams';)270 2055
- y Ft(gi)o(v)o(es)13 b(the)f(result:)898 2172 y Fr(SNO)29
- b(|)h(SNAME)f(|)60 b(CITY)868 2232 y(-----+-------+--------)928
- 2292 y(2)f(|)30 b(Jones)f(|)h(Paris)928 2351 y(3)59 b(|)30
- b(Adams)f(|)h(Vienna)270 2464 y Ft(Here)12 b(an)h(e)o(xample)f(for)g
- (INTERSECT)n(:)360 2581 y Fr(SELECT)29 b(S.SNO,)g(S.SNAME,)g(S.CITY)360
- 2641 y(FROM)g(SUPPLIER)g(S)360 2701 y(WHERE)g(S.SNO)g(>)h(1)360
- 2761 y(INTERSECT)360 2820 y(SELECT)f(S.SNO,)g(S.SNAME,)g(S.CITY)360
- 2880 y(FROM)g(SUPPLIER)g(S)360 2940 y(WHERE)g(S.SNO)g(>)h(2;)270
- 3053 y Ft(gi)o(v)o(es)13 b(the)f(result:)898 3170 y Fr(SNO)29
- b(|)h(SNAME)f(|)60 b(CITY)868 3230 y(-----+-------+--------)928
- 3289 y(2)f(|)30 b(Jones)f(|)h(Paris)270 3402 y Ft(The)13
- b(only)f(tuple)g(returned)f(by)i(both)f(parts)g(of)g(the)g(query)g(is)h
- (the)f(one)h(ha)o(ving)f Fk(S)s(N)5 b(O)15 b Fl(=)e(2)p
- Ft(.)p eop
- %%Page: 21 21
- 21 20 bop 198 60 a Fm(1.3.)29 b(THE)13 b(SQL)f(LANGU)n(A)n(GE)1160
- b Ft(21)198 234 y(Finally)12 b(an)g(e)o(xample)h(for)e(EXCEPT)n(:)288
- 342 y Fr(SELECT)29 b(S.SNO,)g(S.SNAME,)g(S.CITY)288 402
- y(FROM)g(SUPPLIER)g(S)288 461 y(WHERE)g(S.SNO)g(>)h(1)288
- 521 y(EXCEPT)288 581 y(SELECT)f(S.SNO,)g(S.SNAME,)g(S.CITY)288
- 641 y(FROM)g(SUPPLIER)g(S)288 700 y(WHERE)g(S.SNO)g(>)h(3;)198
- 806 y Ft(gi)o(v)o(es)13 b(the)f(result:)826 914 y Fr(SNO)29
- b(|)h(SNAME)f(|)60 b(CITY)796 974 y(-----+-------+--------)856
- 1033 y(2)f(|)30 b(Jones)f(|)h(Paris)856 1093 y(3)59 b(|)30
- b(Adams)f(|)h(Vienna)198 1247 y Fh(1.3.2)59 b(Data)15
- b(De 02nition)198 1344 y Ft(There)e(is)f(a)h(set)g(of)f(commands)g
- (used)h(for)e(data)i(de 02nition)e(included)h(in)g(the)h(SQL)f
- (language.)198 1488 y Fn(Cr)o(eate)g(T)-5 b(able)198
- 1585 y Ft(The)12 b(most)g(fundamental)e(command)h(for)g(data)h
- (de 02nition)e(is)i(the)g(one)f(that)g(creates)h(a)g(ne)o(w)f
- (relation)g((a)198 1645 y(ne)o(w)h(table).)k(The)c(syntax)h(of)f(the)
- g(CREA)-6 b(TE)15 b(T)-5 b(ABLE)14 b(command)e(is:)288
- 1752 y Fr(CREATE)29 b(TABLE)g(<table_name>)676 1812 y
- ((<name_of_attr_1>)f(<type_of_attr_1>)706 1872 y([,)i
- (<name_of_attr_2>)e(<type_of_attr_2>)706 1932 y([,)i(...]]);)198
- 2063 y Fn(Example)13 b(1.12)25 b Ft(T)l(o)13 b(create)g(the)g(tables)h
- (de 02ned)e(in)h( 02gure)g(1.1)g(the)g(follo)o(wing)f(SQL)h
- (statements)g(are)198 2123 y(used:)288 2231 y Fr(CREATE)29
- b(TABLE)g(SUPPLIER)676 2290 y((SNO)89 b(INTEGER,)706
- 2350 y(SNAME)29 b(VARCHAR(20),)706 2410 y(CITY)59 b(VARCHAR(20));)
- 288 2530 y(CREATE)29 b(TABLE)g(PART)676 2589 y((PNO)89
- b(INTEGER,)706 2649 y(PNAME)29 b(VARCHAR(20),)706 2709
- y(PRICE)g(DECIMAL(4)g(,)h(2));)288 2828 y(CREATE)f(TABLE)g(SELLS)676
- 2888 y((SNO)h(INTEGER,)706 2948 y(PNO)g(INTEGER);)198
- 3092 y Fn(Data)12 b(T)l(ypes)h(in)f(SQL)198 3189 y Ft(The)h(follo)o
- (wing)e(is)i(a)f(list)g(of)g(some)h(data)f(types)h(that)f(are)h
- (supported)e(by)i(SQL:)273 3295 y Fo( 17)25 b Ft(INTEGER:)13
- b(signed)f(fullword)e(binary)i(inte)o(ger)g((31)g(bits)g(precision).)
- 273 3402 y Fo( 17)25 b Ft(SMALLINT)n(:)12 b(signed)h(halfword)d
- (binary)i(inte)o(ger)g((15)g(bits)g(precision).)p eop
- %%Page: 22 22
- 22 21 bop 270 60 a Ft(22)1354 b Fm(CHAPTER)14 b(1.)25
- b(SQL)345 234 y Fo( 17)g Ft(DECIMAL)19 b(()p Fk(p)p
- Fl([)p Fk(;)8 b(q)r Fl(])p Ft():)27 b(signed)19 b(packed)f(decimal)h
- (number)f(of)g Fk(p)h Ft(digits)f(precision)h(with)f(as-)395
- 294 y(sumed)13 b Fk(q)j Ft(of)e(them)f(right)g(to)h(the)g(decimal)f
- (point.)20 b Fl((15)d Fo( 25)f Fk(p)g Fo( 25)h Fk(q)h
- Fo( 25)e Fl(0))p Ft(.)21 b(If)13 b Fk(q)j Ft(is)e(omitted)f(it)h(is)
- 395 354 y(assumed)f(to)f(be)g(0.)345 448 y Fo( 17)25
- b Ft(FLO)n(A)-6 b(T)n(:)13 b(signed)f(double)o(word)f( 03oating)g
- (point)h(number)m(.)345 543 y Fo( 17)25 b Ft(CHAR()p
- Fk(n)p Ft():)14 b( 02x)o(ed)f(length)f(character)g(string)f(of)h
- (length)g Fk(n)p Ft(.)345 638 y Fo( 17)25 b Ft(V)-7
- b(ARCHAR()p Fk(n)p Ft():)15 b(v)o(arying)c(length)h(character)g
- (string)g(of)g(maximum)f(length)h Fk(n)p Ft(.)270 768
- y Fn(Cr)o(eate)g(Index)270 862 y Ft(Indices)i(are)g(used)h(to)f(speed)h
- (up)f(access)i(to)e(a)g(relation.)21 b(If)14 b(a)g(relation)g
- Fk(R)g Ft(has)h(an)f(inde)o(x)h(on)f(attrib)o(ute)270
- 921 y Fk(A)j Ft(then)f(we)h(can)f(retrie)o(v)o(e)g(all)g(tuples)h
- Fk(t)g Ft(ha)o(ving)f Fk(t)p Fl(()p Fk(A)p Fl())22
- b(=)f Fk(a)c Ft(in)f(time)h(roughly)e(proportional)g(to)h(the)270
- 981 y(number)c(of)g(such)g(tuples)h Fk(t)f Ft(rather)g(than)g(in)g
- (time)g(proportional)f(to)h(the)h(size)f(of)g Fk(R)p
- Ft(.)345 1041 y(T)l(o)h(create)f(an)g(inde)o(x)h(in)f(SQL)h(the)f(CREA)
- -6 b(TE)14 b(INDEX)f(command)f(is)g(used.)17 b(The)c(syntax)f(is:)360
- 1131 y Fr(CREATE)29 b(INDEX)g(<index_name>)360 1190 y(ON)g
- (<table_name>)g(()h(<name_of_attribute>)d();)270 1303
- y Fn(Example)13 b(1.13)25 b Ft(T)l(o)12 b(create)g(an)f(inde)o(x)h
- (named)g(I)f(on)h(attrib)o(ute)f(SN)n(AME)h(of)f(relation)g(SUPPLIER)h
- (we)270 1362 y(use)h(the)f(follo)o(wing)f(statement:)360
- 1452 y Fr(CREATE)29 b(INDEX)g(I)360 1512 y(ON)g(SUPPLIER)g((SNAME);)
- 270 1602 y Ft(The)11 b(created)f(inde)o(x)h(is)g(maintained)f
- (automatically)m(,)g(i.e.)i(whene)o(v)o(er)e(a)g(ne)o(w)h(tuple)f(is)h
- (inserted)f(into)g(the)270 1661 y(relation)k(SUPPLIER)g(the)h(inde)o(x)
- f(I)h(is)g(adapted.)22 b(Note)15 b(that)f(the)h(only)f(changes)h(a)g
- (user)g(can)f(percept)270 1721 y(when)e(an)h(inde)o(x)f(is)h(present)f
- (are)g(an)h(increased)g(speed.)270 1852 y Fn(Cr)o(eate)f(V)n(iew)270
- 1945 y Ft(A)i(vie)o(w)f(may)h(be)g(re)o(garded)f(as)h(a)g
- Fp(virtual)g(table)p Ft(,)g(i.e.)h(a)f(table)f(that)h(does)g(not)g
- Fp(physically)f Ft(e)o(xist)i(in)e(the)270 2005 y(database)i(b)o(ut)f
- (looks)g(to)g(the)g(user)g(as)h(if)e(it)h(did.)21 b(By)14
- b(contrast,)h(when)f(we)g(talk)g(of)g(a)g Fp(base)h(table)e
- Ft(there)270 2064 y(is)f(really)g(a)g(physically)f(stored)h
- (counterpart)e(of)i(each)g(ro)o(w)f(of)h(the)f(table)h(some)o(where)g
- (in)f(the)h(physical)270 2124 y(storage.)345 2184 y(V)m(ie)o(ws)h(do)g
- (not)g(ha)o(v)o(e)h(their)f(o)o(wn,)h(physically)e(separate,)j
- (distinguishable)e(stored)g(data.)19 b(Instead,)270 2244
- y(the)d(system)g(stores)g(the)f Fp(de 02nition)g Ft(of)h(the)f(vie)o
- (w)h((i.e.)g(the)g(rules)f(about)h(ho)o(w)f(to)g(access)i(physically)
- 270 2304 y(stored)c Fp(base)g(tables)h Ft(in)e(order)h(to)g
- (materialize)f(the)h(vie)o(w))g(some)o(where)f(in)h(the)g
- Fp(system)h(catalogs)f Ft((see)270 2363 y(section)19
- b(1.3.4)h Fp(System)g(Catalogs)p Ft().)36 b(F)o(or)18
- b(a)i(discussion)g(on)f(dif)o(ferent)e(techniques)j(to)f(implement)270
- 2423 y(vie)o(ws)12 b(refer)g(to)g(section)h(3.4.1)g Fp(T)-5
- b(ec)o(hniques)13 b(T)-5 b(o)12 b(Implement)g(V)l(ie)o(ws)p
- Ft(.)345 2483 y(In)g(SQL)g(the)h(CREA)-6 b(TE)14 b(VIEW)f(command)f(is)
- g(used)h(to)f(de 02ne)g(a)h(vie)o(w)m(.)i(The)e(syntax)g(is:)360
- 2573 y Fr(CREATE)29 b(VIEW)g(<view_name>)360 2632 y(AS)g(<select_stmt>)
- 270 2722 y Ft(where)10 b Fk(<)p Fr(select)p 624 2722
- 15 2 v 17 w(stmt)p Fk(>)40 b Ft(is)11 b(a)g(v)o(alid)g(select)g
- (statement)f(as)i(de 02ned)e(in)h(section)g(1.3.1.)16
- b(Note)10 b(that)270 2782 y(the)15 b Fk(<)p Fr(select)p
- 568 2782 V 17 w(stmt)p Fk(>)44 b Ft(is)15 b(not)g(e)o(x)o(ecuted)g
- (when)g(the)g(vie)o(w)f(is)h(created.)23 b(It)15 b(is)g(just)g(stored)f
- (in)h(the)270 2842 y Fp(system)e(catalogs)f Ft(and)g(is)h(e)o(x)o
- (ecuted)g(whene)o(v)o(er)f(a)h(query)f(against)g(the)g(vie)o(w)g(is)h
- (made.)270 2954 y Fn(Example)g(1.14)25 b Ft(Let)16 b(the)g(follo)o
- (wing)f(vie)o(w)h(de 02nition)f(be)h(gi)o(v)o(en)g((we)g(use)g(the)g
- (tables)h(from)e( 02gure)270 3014 y(1.1)e Fp(The)f(suppliers)h(and)f
- (parts)h(database)f Ft(again):)360 3103 y Fr(CREATE)29
- b(VIEW)g(London_Suppliers)449 3163 y(AS)h(SELECT)f(S.SNAME,)g(P.PNAME)
- 539 3223 y(FROM)g(SUPPLIER)g(S,)h(PART)g(P,)f(SELLS)h(SE)539
- 3283 y(WHERE)f(S.SNO)h(=)f(SE.SNO)h(AND)718 3342 y(P.PNO)g(=)f(SE.PNO)h
- (AND)718 3402 y(S.CITY)g(=)f('London';)p eop
- %%Page: 23 23
- 23 22 bop 198 60 a Fm(1.3.)26 b(THE)13 b(SQL)f(LANGU)n(A)n(GE)1163
- b Ft(23)198 234 y(No)o(w)10 b(we)g(can)g(use)g(this)g
- Fp(virtual)g(r)n(elation)f Fr(London)p 1100 234 15 2
- v 18 w(Suppliers)g Ft(as)h(if)f(it)h(were)g(another)f(base)h(table:)288
- 338 y Fr(SELECT)29 b(*)288 397 y(FROM)g(London_Suppliers)288
- 457 y(WHERE)g(P.PNAME)g(=)h('Screw';)198 560 y Ft(will)12
- b(return)f(the)i(follo)o(wing)e(table:)885 663 y Fr(SNAME)30
- b(|)g(PNAME)856 723 y(-------+-------)885 783 y(Smith)g(|)g(Screw)198
- 885 y Ft(T)l(o)17 b(calculate)h(this)f(result)g(the)g(database)g
- (system)h(has)f(to)g(do)g(a)g Fp(hidden)g Ft(access)h(to)f(the)g(base)h
- (tables)198 945 y(SUPPLIER,)e(SELLS)g(and)g(P)-5 b(AR)m(T)16
- b( 02rst.)25 b(It)15 b(does)h(so)g(by)f(e)o(x)o(ecuting)h(the)f(query)
- g(gi)o(v)o(en)h(in)f(the)g(vie)o(w)198 1005 y(de 02nition)h(against)g
- (those)h(base)h(tables.)28 b(After)16 b(that)h(the)f(additional)g
- (quali 02cations)h((gi)o(v)o(en)f(in)g(the)198 1065
- y(query)c(against)g(the)h(vie)o(w))e(can)i(be)f(applied)g(to)h(obtain)
- f(the)g(resulting)g(table.)198 1202 y Fn(Dr)o(op)g(T)-5
- b(able,)13 b(Dr)o(op)g(Index,)f(Dr)o(op)h(V)n(iew)198
- 1298 y Ft(T)l(o)g(destroy)e(a)h(table)h((including)e(all)h(tuples)g
- (stored)g(in)g(that)g(table))g(the)g(DR)n(OP)g(T)-5
- b(ABLE)14 b(command)e(is)198 1357 y(used:)288 1461 y
- Fr(DROP)29 b(TABLE)g(<table_name>;)198 1586 y Fn(Example)13
- b(1.15)25 b Ft(T)l(o)13 b(destroy)e(the)h(SUPPLIER)h(table)f(use)h(the)
- f(follo)o(wing)f(statement:)288 1690 y Fr(DROP)29 b(TABLE)g(SUPPLIER;)
- 198 1792 y Ft(The)13 b(DR)n(OP)f(INDEX)h(command)f(is)g(used)h(to)f
- (destroy)g(an)g(inde)o(x:)288 1896 y Fr(DROP)29 b(INDEX)g
- (<index_name>;)198 1998 y Ft(Finally)12 b(to)g(destroy)f(a)i(gi)o(v)o
- (en)f(vie)o(w)g(use)h(the)f(command)g(DR)n(OP)h(VIEW)n(:)288
- 2102 y Fr(DROP)29 b(VIEW)h(<view_name>;)198 2250 y Fh(1.3.3)59
- b(Data)15 b(Manipulation)198 2345 y Fn(Insert)e(Into)198
- 2440 y Ft(Once)h(a)h(table)f(is)h(created)f((see)g(section)h(1.3.2),)
- g(it)f(can)h(be)f( 02lled)g(with)g(tuples)g(using)g(the)h(command)198
- 2500 y(INSER)m(T)e(INT)o(O.)g(The)g(syntax)f(is:)288
- 2603 y Fr(INSERT)29 b(INTO)g(<table_name>)g((<name_of_attr_1>)1065
- 2663 y([,)g(<name_of_attr_2>)g([,...]]))288 2723 y(VALUES)g
- ((<val_attr_1>)527 2783 y([,)g(<val_attr_2>)g([,)h(...]]);)198
- 2908 y Fn(Example)13 b(1.16)25 b Ft(T)l(o)14 b(insert)g(the)h( 02rst)f
- (tuple)f(into)h(the)h(relation)e(SUPPLIER)h(of)g( 02gure)g(1.1)g
- Fp(The)g(sup-)198 2968 y(pliers)e(and)h(parts)f(database)h
- Ft(we)f(use)h(the)g(follo)o(wing)d(statement:)288 3071
- y Fr(INSERT)29 b(INTO)g(SUPPLIER)g((SNO,)h(SNAME,)f(CITY))288
- 3131 y(VALUES)g((1,)g('Smith',)g('London');)198 3234
- y Ft(T)l(o)13 b(insert)f(the)g( 02rst)g(tuple)g(into)g(the)h(relation)
- e(SELLS)i(we)g(use:)288 3337 y Fr(INSERT)29 b(INTO)g(SELLS)h((SNO,)f
- (PNO))288 3397 y(VALUES)g((1,)g(1);)p eop
- %%Page: 24 24
- 24 23 bop 270 60 a Ft(24)1351 b Fm(CHAPTER)14 b(1.)28
- b(SQL)270 234 y Fn(Update)270 330 y Ft(T)l(o)17 b(change)f(one)h(or)f
- (more)g(attrib)o(ute)f(v)o(alues)i(of)f(tuples)g(in)h(a)f(relation)g
- (the)g(UPD)n(A)-6 b(TE)18 b(command)e(is)270 389 y(used.)g(The)d
- (syntax)g(is:)360 493 y Fr(UPDATE)29 b(<table_name>)360
- 553 y(SET)g(<name_of_attr_1>)f(=)i(<value_1>)479 613
- y([,)g(...)f([,)h(<name_of_attr_k>)e(=)i(<value_k>]])360
- 672 y(WHERE)f(<condition>;)270 798 y Fn(Example)13 b(1.17)25
- b Ft(T)l(o)15 b(change)g(the)f(v)o(alue)h(of)f(attrib)o(ute)g(PRICE)h
- (of)f(the)g(part)h('Scre)o(w')e(in)h(the)h(relation)270
- 858 y(P)-5 b(AR)m(T)13 b(we)g(use:)360 962 y Fr(UPDATE)29
- b(PART)360 1022 y(SET)g(PRICE)h(=)f(15)360 1081 y(WHERE)g(PNAME)g(=)h
- ('Screw';)270 1184 y Ft(The)13 b(ne)o(w)f(v)o(alue)g(of)g(attrib)o(ute)
- g(PRICE)g(of)g(the)h(tuple)f(whose)g(name)h(is)f('Scre)o(w')f(is)i(no)o
- (w)f(15.)270 1323 y Fn(Delete)270 1418 y Ft(T)l(o)h(delete)f(a)g(tuple)
- g(from)f(a)h(particular)f(table)h(use)h(the)f(command)g(DELETE)i(FR)n
- (OM.)f(The)g(syntax)f(is:)360 1522 y Fr(DELETE)29 b(FROM)g
- (<table_name>)360 1582 y(WHERE)g(<condition>;)270 1708
- y Fn(Example)13 b(1.18)25 b Ft(T)l(o)13 b(delete)g(the)g(supplier)f
- (called)h('Smith')e(of)i(the)f(table)h(SUPPLIER)g(the)g(follo)o(wing)
- 270 1767 y(statement)f(is)h(used:)360 1871 y Fr(DELETE)29
- b(FROM)g(SUPPLIER)360 1931 y(WHERE)g(SNAME)g(=)h('Smith';)270
- 2079 y Fh(1.3.4)59 b(System)15 b(Catalogs)270 2175 y
- Ft(In)10 b(e)o(v)o(ery)g(SQL)g(database)h(system)f Fp(system)h
- (catalogs)f Ft(are)g(used)g(to)g(keep)g(track)g(of)g(which)g(tables,)h
- (vie)o(ws)270 2235 y(inde)o(x)o(es)16 b(etc.)24 b(are)15
- b(de 02ned)g(in)g(the)g(database.)24 b(These)17 b(system)e(catalogs)h
- (can)f(be)g(queried)g(as)g(if)g(the)o(y)270 2294 y(were)g(normal)g
- (relations.)23 b(F)o(or)15 b(e)o(xample)h(there)e(is)i(one)f(catalog)g
- (used)h(for)e(the)i(de 02nition)e(of)h(vie)o(ws.)270
- 2354 y(This)h(catalog)f(stores)h(the)f(query)g(from)f(the)h(vie)o(w)g
- (de 02nition.)23 b(Whene)o(v)o(er)16 b(a)f(query)g(against)g(a)g(vie)o
- (w)270 2414 y(is)f(made,)h(the)e(system)i( 02rst)e(gets)h(the)g
- Fp(vie)o(w-de 02nition-query)f Ft(out)h(of)f(the)h(catalog)g(and)f
- (materializes)270 2474 y(the)e(vie)o(w)g(before)g(proceeding)g(with)g
- (the)g(user)g(query)g((see)h(section)f(3.4.1)h Fp(T)-5
- b(ec)o(hniques)12 b(T)-5 b(o)12 b(Implement)270 2533
- y(V)l(ie)o(ws)k Ft(for)e(a)h(more)f(detailed)g(description).)21
- b(F)o(or)14 b(more)g(information)f(about)i Fp(system)g(catalogs)f
- Ft(refer)270 2593 y(to)e([D)n(A)-6 b(TE96)q(].)270 2742
- y Fh(1.3.5)59 b(Embedded)15 b(SQL)270 2837 y Ft(In)h(this)h(section)g
- (we)g(will)g(sketch)f(ho)o(w)h(SQL)g(can)g(be)g(embedded)f(into)h(a)g
- (host)g(language)f((e.g.)i(C).)270 2897 y(There)13
- b(are)f(two)g(main)g(reasons)g(why)g(we)h(want)f(to)g(use)h(SQL)f(from)
- g(a)g(host)h(language:)345 3000 y Fo( 17)25 b Ft(There)13
- b(are)g(queries)f(that)h(cannot)g(be)g(formulated)e(using)i(pure)g(SQL)
- g((i.e.)18 b(recursi)o(v)o(e)12 b(queries).)395 3059
- y(T)l(o)f(be)g(able)g(to)g(perform)e(such)j(queries)f(we)g(need)g(a)g
- (host)g(language)g(with)g(a)g(greater)f(e)o(xpressi)o(v)o(e)395
- 3119 y(po)o(wer)h(than)h(SQL.)345 3223 y Fo( 17)25 b
- Ft(W)l(e)11 b(simply)f(want)g(to)h(access)h(a)f(database)h(from)d(some)
- i(application)g(that)f(is)h(written)g(in)f(the)h(host)395
- 3283 y(language)g((e.g.)h(a)g(ticket)e(reserv)o(ation)h(system)h(with)
- f(a)h(graphical)f(user)g(interface)g(is)h(written)e(in)395
- 3342 y(C)h(and)g(the)g(information)f(about)g(which)h(tickets)g(are)g
- (still)g(left)g(is)g(stored)g(in)g(a)g(database)h(that)f(can)395
- 3402 y(be)h(accessed)i(using)e(embedded)g(SQL).)p eop
- %%Page: 25 25
- 25 24 bop 198 60 a Fm(1.3.)29 b(THE)13 b(SQL)f(LANGU)n(A)n(GE)1160
- b Ft(25)198 234 y(A)19 b(program)f(using)h(embedded)g(SQL)h(in)f(a)g
- (host)h(language)f(consists)h(of)e(statements)i(of)f(the)g(host)198
- 294 y(language)c(and)g(of)g(embedded)g(SQL)g((ESQL))g(statements.)25
- b(Ev)o(ery)15 b(ESQL)h(statement)f(be)o(gins)g(with)198
- 354 y(the)d(ke)o(ywords)g(EXEC)h(SQL.)g(The)g(ESQL)g(statements)g(are)f
- (transformed)g(to)g(statements)h(of)f(the)g(host)198
- 413 y(language)j(by)g(a)g Fp(pr)n(ecompiler)h Ft((mostly)e(calls)h(to)
- g(library)f(routines)g(that)h(perform)f(the)g(v)o(arious)h(SQL)198
- 473 y(commands).)273 533 y(When)i(we)g(look)f(at)h(the)g(e)o(xamples)g
- (throughout)f(section)h(1.3.1)h(we)f(realize)f(that)h(the)g(result)g
- (of)198 593 y(the)e(queries)g(is)g(v)o(ery)g(often)g(a)g(set)g(of)g
- (tuples.)24 b(Most)15 b(host)g(languages)h(are)f(not)f(designed)i(to)e
- (operate)198 653 y(on)h(sets)g(so)g(we)g(need)g(a)g(mechanism)g(to)g
- (access)h(e)o(v)o(ery)e(single)h(tuple)g(of)f(the)h(set)g(of)f(tuples)h
- (returned)198 712 y(by)h(a)g(SELECT)i(statement.)27 b(This)16
- b(mechanism)g(can)g(be)h(pro)o(vided)e(by)h(declaring)f(a)i
- Fp(cursor)p Ft(.)27 b(After)198 772 y(that)11 b(we)g(can)g(use)g(the)g
- (FETCH)g(command)g(to)g(retrie)o(v)o(e)f(a)h(tuple)f(and)h(set)g(the)g
- (cursor)g(to)f(the)h(ne)o(xt)g(tuple.)198 892 y(F)o(or)h(a)g(detailed)h
- (discussion)g(on)f(embedded)g(SQL)h(refer)e(to)h([D)n(A)-6
- b(TE96)q(],)12 b([D)n(A)-6 b(TE94)q(])12 b(or)g([ULL88].)p
- eop
- %%Page: 26 26
- 26 25 bop 270 609 a Fj(Chapter)26 b(2)270 858 y Fq(P)n(ostgr)n(eSQL)k
- (fr)n(om)g(the)g(User')-5 b(s)32 b(P)n(oint)270 1008
- y(of)f(V)-5 b(iew)270 1268 y Ft(This)13 b(chapter)f(contains)g
- (information)f(that)h(will)f(be)i(useful)f(for)f(people)h(that)g(only)g
- (want)g(to)g(use)h(Post-)270 1327 y(greSQL.)g(It)f(gi)o(v)o(es)h(a)g
- (listing)f(and)h(description)f(of)g(the)g(a)o(v)o(ailable)h(features)f
- (including)g(a)h(lot)f(of)g(e)o(xam-)270 1387 y(ples.)k(The)11
- b(users)h(interested)f(in)g(the)g(internals)g(of)g(PostgreSQL)f(should)
- h(read)g(chapter)g(3)g Fp(P)l(ostgr)n(eSQL)270 1447 y(fr)n(om)h(the)h
- (Pr)n(ogr)o(ammer')n(s)g(P)l(oint)f(of)h(V)l(ie)o(w)p
- Ft(.)270 1620 y Fi(2.1)71 b(A)18 b(Short)f(History)g(of)h(P)o(ostgr)o
- (eSQL)270 1732 y Ft(PostgreSQL)c(is)h(an)g(enhancement)f(of)g(the)h
- (POSTGRES)f(database)i(management)e(system,)i(a)e(ne)o(xt-)270
- 1792 y(generation)f(relational)g(DBMS)h(research)g(prototype)f(running)
- g(on)g(almost)h(an)o(y)g(UNIX)g(based)g(oper)o(-)270
- 1852 y(ating)f(system.)20 b(The)14 b(original)e(POSTGRES)i(code,)g
- (from)f(which)g(PostgreSQL)g(is)h(deri)o(v)o(ed,)g(was)f(the)270
- 1912 y(ef)o(fort)f(of)i(man)o(y)g(graduate)g(students,)h(under)o
- (graduate)e(students,)i(and)f(staf)o(f)g(programmers)e(working)270
- 1971 y(under)d(the)h(direction)f(of)h(Professor)f(Michael)h
- (Stonebraker)e(at)i(the)f(Uni)o(v)o(ersity)h(of)f(California,)h(Berke-)
- 270 2031 y(le)o(y)m(.)16 b(Originally)11 b(POSTGRES)i(implemented)e
- (its)i(o)o(wn)f(query)g(language)g(called)g(POSTQUEL.)345
- 2092 y(In)18 b(1995)g(Andre)o(w)g(Y)-6 b(u)19 b(and)f(Jolly)h(Chen)g
- (adapted)f(the)h(last)f(of)o( 02cial)g(release)h(of)f(POSTGRES)270
- 2152 y((v)o(ersion)d(4.2))h(to)f(meet)h(their)f(o)o(wn)g
- (requirements)g(and)g(made)h(some)g(major)e(changes)j(to)e(the)g(code.)
- 270 2211 y(The)i(most)g(important)e(change)i(is)f(the)h(replacement)f
- (of)g(POSTQUEL)h(by)f(an)h(e)o(xtended)f(subset)i(of)270
- 2271 y(SQL92.)f(The)c(name)g(was)g(changed)f(to)h(Postgres95)f(and)h
- (since)g(that)g(time)f(man)o(y)h(other)f(people)h(ha)o(v)o(e)270
- 2331 y(contrib)o(uted)h(to)h(the)g(porting,)g(testing,)h(deb)o(ugging)f
- (and)g(enhancement)g(of)g(the)g(code.)24 b(In)14 b(late)h(1996)270
- 2391 y(the)d(name)h(was)f(changed)h(again)f(to)g(the)g(ne)o(w)g(of)o
- ( 02cial)g(name)g(PostgreSQL.)270 2563 y Fi(2.2)71 b(An)18
- b(Ov)o(er)o(view)f(on)h(the)g(F)n(eatur)o(es)e(of)i(P)o(ostgr)o(eSQL)
- 270 2676 y Ft(As)d(mentioned)f(earlier)g(PostgreSQL)h(is)g(a)g
- (relational)f(database)h(management)f(system)h((RDBMS))270
- 2736 y(b)o(ut)h(in)f(contrast)h(to)f(the)h(most)g(traditional)f(RDBMSs)
- h(it)g(is)g(designed)g(to)f(pro)o(vide)h(more)f( 03e)o(xibility)270
- 2796 y(to)j(the)f(user)m(.)33 b(One)18 b(e)o(xample)g(for)f(the)h
- (impro)o(v)o(ed)f( 03e)o(xibility)g(is)h(the)g(support)f(for)g
- Fp(user)i(de 02ned)f Ft(or)270 2855 y Fp(abstr)o(act)11
- b(data)f(types)h Ft((ADTs).)k(Another)10 b(e)o(xample)h(is)f(the)h
- (support)f(of)g(user)g(de 02ned)h(SQL)f(functions.)270
- 2915 y((W)l(e)j(will)g(discuss)h(these)f(features)g(later)g(in)g
- (section)g(2.5)h Fp(Some)f(of)g(P)l(ostgr)n(eSQL)n(')n(s)h(Special)e(F)
- l(eatur)n(es)270 2975 y(in)g(Detail)p Ft())270 3095
- y(Here)g(is)h(a)f(list)h(of)f(the)g(features)g(PostgreSQL)g(pro)o
- (vides:)345 3197 y Fo( 17)25 b Ft(An)12 b(e)o(xtended)g(subset)h(of)f
- (SQL92)h(as)g(query)f(language.)345 3299 y Fo( 17)25
- b Ft(A)12 b(commandline)g(interface)f(called)h Fr(psql)g
- Ft(using)h(GNU)f(readline.)345 3402 y Fo( 17)25 b Ft(A)12
- b(client/serv)o(er)g(architecture)f(allo)o(wing)h(concurrent)f(access)j
- (to)e(the)h(databases.)1145 3552 y(26)p eop
- %%Page: 27 27
- 27 26 bop 198 60 a Fm(2.3.)29 b(WHERE)13 b(T)o(O)g(GET)g(POSTGRESQL)956
- b Ft(27)273 234 y Fo( 17)25 b Ft(Support)11 b(for)g(btree,)i(hash)g
- (or)e(rtree)h(inde)o(x)o(es.)273 331 y Fo( 17)25 b Ft(A)13
- b(transaction)f(mechanism)h(based)h(on)f(the)g(two)f(phase)i(commit)e
- (protocol)g(is)i(used)f(to)g(ensure)323 391 y(data)f(inte)o(grity)f
- (throughout)h(concurrent)f(data)h(access.)273 488 y Fo( 17)25
- b Ft(Host)17 b(based,)i(password,)f(crypt,)g(ident)e((RFC)h(1413))f
- (or)h(K)o(erberos)f(V4/V5)h(authentication)323 547 y(can)12
- b(be)h(used)f(to)h(ensure)f(authorized)g(data)g(access.)273
- 644 y Fo( 17)25 b Ft(A)12 b(huge)g(amount)g(of)g(prede 02ned)g(data)g
- (types.)273 741 y Fo( 17)25 b Ft(Support)11 b(for)g(user)i(de 02ned)f
- (data)g(types.)273 838 y Fo( 17)25 b Ft(Support)11 b(for)g(user)i
- (de 02ned)f(SQL)g(functions.)273 935 y Fo( 17)25 b
- Ft(Support)11 b(for)g(reco)o(v)o(ery)h(after)g(a)h(crash.)273
- 1032 y Fo( 17)25 b Ft(A)12 b(precompiler)f(for)h(embedded)g(SQL)g(in)h
- (C.)273 1129 y Fo( 17)25 b Ft(An)12 b(ODBC)h(interface.)273
- 1225 y Fo( 17)25 b Ft(A)12 b(JDBC)h(interface.)273 1322
- y Fo( 17)25 b Ft(A)12 b(Tcl/Tk)h(interface.)273 1419
- y Fo( 17)25 b Ft(A)12 b(Perl)g(interface.)198 1586 y
- Fi(2.3)71 b(Wher)o(e)17 b(to)h(Get)f(P)o(ostgr)o(eSQL)198
- 1697 y Ft(PostgreSQL)26 b(is)h(a)o(v)o(ailable)f(as)i(source)e(distrib)
- o(ution)g((v6.3.2)g(at)h(the)g(time)f(of)g(writing))f(from)198
- 1757 y Fr(ftp://ftp.postgresql.org/pub/)p Ft(.)63 b(There)30
- b(is)f(also)h(an)f(of)o( 02cial)f(homepage)h(for)198
- 1817 y(PostgreSQL)15 b(at)g Fr(http://www.postgresgl.org/)p
- Ft(.)21 b(There)15 b(are)g(a)g(lot)g(of)g(hosts)g(mirroring)198
- 1877 y(the)d(contents)h(of)f(the)g(abo)o(v)o(e)h(mentioned)f(ones)h
- (all)f(o)o(v)o(er)g(the)h(world.)198 2008 y Fn(Copyright)e(of)h(P)o
- (ostgr)o(eSQL)198 2101 y Ft(PostgreSQL)17 b(is)h(not)f(public)g(domain)
- g(software.)30 b(It)17 b(is)h(copyrighted)e(by)h(the)h(Uni)o(v)o
- (ersity)e(of)h(Cali-)198 2161 y(fornia)e(b)o(ut)h(may)g(be)g(used)h
- (according)f(to)g(the)g(licensing)g(terms)g(of)g(the)g(the)g(copyright)
- e(included)i(in)198 2221 y(e)o(v)o(ery)h(distrib)o(ution)g((refer)f
- (to)h(the)h( 02le)f Fr(COPYRIGHT)g Ft(included)g(in)g(e)o(v)o(ery)h
- (distrib)o(ution)e(for)h(more)198 2281 y(information).)198
- 2412 y Fn(Support)11 b(f)o(or)h(P)o(ostgr)o(eSQL)198
- 2506 y Ft(There)g(is)g(no)g(of)o( 02cial)e(support)i(for)f
- (PostgreSQL.)g(That)h(means)h(there)e(is)h(no)g(obligation)e(for)h(an)o
- (ybody)198 2565 y(to)h(pro)o(vide)g(maintenance,)h(support,)f(updates,)
- h(enhancements)g(or)f(modi 02cations)g(to)g(the)g(code.)17
- b(The)198 2625 y(whole)c(PostgreSQL)g(project)g(is)h(maintained)e
- (through)h(v)o(olunteer)f(ef)o(fort)g(only)m(.)18 b(Ho)o(we)o(v)o(er)13
- b(there)g(are)198 2685 y(man)o(y)f(mailing)g(lists)h(which)f(can)h(be)f
- (subscribed)h(to)f(in)g(case)h(of)f(problems:)198 2804
- y(Support)f(Mailing)h(Lists:)273 2864 y Fr(announce@postgreSQL.org)e
- Ft(for)h(announcements.)273 2924 y Fr(ports@postgreSQL.org)f
- Ft(for)h(OS-speci 02c)h(b)o(ugs.)273 2984 y Fr(bugs@postgreSQL.org)e
- Ft(for)i(other)f(unsolv)o(ed)i(b)o(ugs.)273 3044 y Fr
- (questions@postgreSQL.org)c Ft(for)j(general)g(discussion.)198
- 3163 y(Mailing)g(Lists)i(for)d(De)o(v)o(elopers:)273
- 3223 y Fr(hackers@postgreSQL.org)f Ft(for)h(serv)o(er)i(internals)f
- (discussion.)273 3283 y Fr(docs@postgreSQL.org)e Ft(for)i(the)g
- (documentation)f(project.)273 3342 y Fr(patches@postgreSQL.org)f
- Ft(for)h(patches)i(and)f(discussion.)273 3402 y Fr
- (mirrors@postgreSQL.org)e Ft(for)h(mirror)g(site)i(announcements.)p
- eop
- %%Page: 28 28
- 28 27 bop 270 60 a Ft(28)307 b Fm(CHAPTER)14 b(2.)28
- b(POSTGRESQL)13 b(FR)n(OM)f(THE)i(USER'S)e(POINT)g(OF)g(VIEW)270
- 234 y Ft(T)l(o)i(subscribe)h(to)f(the)g(mailing)f(list)h
- Fr(questions@postgreSQL.org)d Ft(for)i(e)o(xample)i(just)f(send)270
- 294 y(an)e(email)h(to)f Fr(questions-request@postgreSQL.o)o(rg)e
- Ft(with)i(the)g(lines)360 401 y Fr(subscribe)360 461
- y(end)270 567 y Ft(in)g(the)h(body)f((not)f(the)i(subject)f(line).)
- 270 746 y Fi(2.4)71 b(Ho)o(w)18 b(to)g(use)f(P)o(ostgr)o(eSQL)270
- 861 y Ft(Before)11 b(we)h(can)g(use)g(PostgreSQL)g(we)g(ha)o(v)o(e)g
- (to)f(get)h(and)g(install)f(it.)16 b(W)l(e)c(won')o(t)e(talk)i(about)g
- (installing)270 921 y(PostgreSQL)g(here)h(because)g(the)g(installation)
- f(procedure)g(is)h(straight)g(forward)e(and)i(described)f(v)o(ery)270
- 980 y(detailed)h(in)h(the)f( 02le)g Fr(INSTALL)g Ft(contained)g(in)g
- (the)h(distrib)o(ution.)k(W)l(e)13 b(want)g(to)h(concentrate)f(on)g
- (the)270 1040 y(basic)g(usage)g(of)f(PostgreSQL)g(after)f(a)i
- (successful)g(setup)g(has)g(taken)e(place.)270 1194 y
- Fh(2.4.1)59 b(Starting)14 b(The)h(P)o(ostmaster)270 1291
- y Ft(As)j(mentioned)g(earlier)f(PostgreSQL)g(uses)i(a)f(traditional)f
- (client/serv)o(er)h(architecture)f(to)h(pro)o(vide)270
- 1351 y(multi)c(user)g(access.)24 b(The)15 b(serv)o(er)g(is)g
- (represented)f(by)g(a)h(program)e(called)i Fr(postmaster)e
- Ft(which)i(is)270 1410 y(started)c(only)h(once)f(at)h(each)g(host.)j
- (This)e(master)e(serv)o(er)h(process)g(listens)g(at)f(a)h(speci 02ed)g
- (TCP/IP)f(port)270 1470 y(for)j(incoming)h(connections)g(by)g(a)h
- (client.)24 b(F)o(or)15 b(e)o(v)o(ery)g(incoming)f(connection)h(the)g
- Fr(postmaster)270 1530 y Ft(spa)o(wns)e(a)e(ne)o(w)h(serv)o(er)g
- (process)g(()p Fr(postgres)p Ft())e(and)h(continues)h(listening)f
- (for)g(further)g(connections.)270 1590 y(Ev)o(ery)18
- b(serv)o(er)f(process)g(spa)o(wned)h(in)f(this)h(way)f(handles)g(e)o
- (xactly)g(one)h(connection)f(to)g(one)g(client.)270 1649
- y(The)f Fr(postgres)e Ft(serv)o(er)i(processes)g(communicate)f(with)f
- (each)i(other)f(using)g(UNIX)g(semaphores)270 1709 y(and)k(shared)h
- (memory)e(to)i(ensure)f(data)h(inte)o(grity)e(throughout)g(concurrent)h
- (data)g(access.)38 b((F)o(or)19 b(a)270 1769 y(more)d(detailed)g
- (description)f(on)h(these)h(architectural)e(concepts)h(see)h(chapter)f
- (3)g Fp(P)l(ostgr)n(eSQL)h(fr)n(om)270 1829 y(the)12
- b(Pr)n(ogr)o(ammer')n(s)i(P)l(oint)e(of)g(V)l(ie)o(w)p
- Ft(.))270 1948 y(T)l(o)h(start)f(the)g(master)h(serv)o(er)f(process)h
- (use)g(the)f(follo)o(wing)f(command:)330 2056 y Fr($)30
- b(nohup)f(postmaster)g(>)g(server.log)g(2>&1)h(&)270
- 2161 y Ft(which)11 b(will)g(start)g Fr(postmaster)g Ft(in)g(the)g
- (background)g(and)g(e)o(v)o(en)h(if)f(you)g(log)g(out)g(of)g(the)g
- (system)h(the)270 2221 y(process)h(remains)f(acti)o(v)o(e.)k(All)c
- (errors)g(and)g(messages)i(will)e(be)g(logged)g(to)g(the)h( 02le)f
- Fr(server.log)p Ft(.)270 2341 y Fn(Note:)35 b Ft(The)23
- b Fr(postmaster)e Ft(process)i(is)g(usually)g(started)f(by)g(a)h
- (special)g Fp(database)g(superuser)270 2401 y Ft(called)c
- Fr(postgres)f Ft(which)h(is)g(a)g(normal)g(UNIX)f(user)h(b)o(ut)g(has)g
- (more)g(rights)f(concerning)h(Post-)270 2460 y(greSQL.)f(F)o(or)g
- (security)g(reasons)h(it)f(is)g(strongly)g(recommended)f(not)h(to)g
- (run)g(the)g Fr(postmaster)270 2520 y Ft(process)13 b(as)g(the)f
- Fp(system)h(super)h(user)f Fr(root)p Ft(.)270 2674 y
- Fh(2.4.2)59 b(Cr)o(eating)14 b(a)h(New)g(Database)270
- 2771 y Ft(Once)c(the)g Fr(postmaster)f Ft(daemon)g(is)i(running)e(we)h
- (can)g(create)g(a)g(ne)o(w)f(database)i(using)f(the)g(follo)o(w-)270
- 2830 y(ing)h(command:)330 2938 y Fr($)30 b(createdb)f(testdb)270
- 3044 y Ft(which)22 b(will)g(create)g(a)g(database)h(called)f
- Fr(testdb)p Ft(.)45 b(The)23 b(user)f(e)o(x)o(ecuting)h(the)f(command)f
- (will)270 3103 y(become)12 b(the)f(database)h(administrator)f(and)g
- (will)g(therefore)g(be)h(the)f(only)g(user)h((e)o(xcept)g(the)f
- Fp(database)270 3163 y(superuser)j Fr(postgres)p Ft())d(who)h(can)h
- (destroy)e(the)i(database)g(again.)270 3283 y Fn(Note:)35
- b Ft(T)l(o)22 b(create)h(the)f(database)h(you)f(don')o(t)g(need)g(to)g
- (kno)o(w)g(an)o(ything)g(about)g(the)g(tables)h((re-)270
- 3342 y(lations))16 b(that)h(will)f(be)h(used)h(within)e(the)h
- (database.)29 b(The)18 b(tables)f(will)f(be)h(de 02ned)g(later)f
- (using)h(the)270 3402 y(SQL)c(statements)f(sho)o(wn)h(in)f(section)g
- (2.4.4)h Fp(De 02ning)f(and)h(P)l(opulating)f(T)-5 b(ables)p
- Ft(.)p eop
- %%Page: 29 29
- 29 28 bop 198 60 a Fm(2.4.)29 b(HO)n(W)12 b(T)o(O)h(USE)g(POSTGRESQL)
- 1018 b Ft(29)198 234 y Fh(2.4.3)59 b(Connecting)15 b(T)-5
- b(o)14 b(a)h(Database)198 335 y Ft(After)g(ha)o(ving)g(created)h(at)g
- (least)g(one)g(database)g(we)g(can)g(make)g(our)f( 02rst)g(client)h
- (connection)f(to)h(the)198 395 y(database)g(system)g(to)f(be)g(able)g
- (to)g(de 02ne)g(tables,)i(populate)e(them,)h(retrie)o(v)o(e)f(data,)h
- (update)f(data)g(etc.)198 455 y(Note)20 b(that)g(most)f(database)i
- (manipulation)e(is)h(done)g(this)g(way)f((just)h(creating)f(and)h
- (destroying)f(a)198 514 y(database)11 b(is)f(done)g(by)g(separate)h
- (commands)f(which)g(are)g(in)g(fact)f(just)i(shell)f(scripts)g(also)h
- (using)f Fr(psql)p Ft())198 634 y(The)j(connection)f(to)g(the)g(DBMS)h
- (is)g(established)g(by)f(the)g(follo)o(wing)f(command:)258
- 749 y Fr($)30 b(psql)f(testdb)198 861 y Ft(which)18 b(will)f(make)g(a)h
- (connection)g(to)f(a)h(database)g(called)g Fr(testdb)p
- Ft(.)32 b Fr(psql)17 b Ft(is)h(a)g(command)f(line)198
- 920 y(interface)d(using)h(GNU)g(readline.)23 b(It)15
- b(can)g(handle)g(a)g(connection)g(to)f(only)h(one)g(database)h(at)f(a)g
- (time.)198 980 y(When)d(the)h(connection)f(is)g(established)h
- Fr(psql)f Ft(presents)h(itself)f(as)h(follo)o(ws:)258
- 1095 y Fr(Welcome)29 b(to)h(the)f(POSTGRESQL)g(interactive)g(sql)g
- (monitor:)318 1155 y(Please)g(read)g(the)h(file)f(COPYRIGHT)g(for)h
- (copyright)f(terms)g(of)318 1215 y(POSTGRESQL)347 1334
- y(type)h(\?)g(for)f(help)h(on)f(slash)h(commands)347
- 1394 y(type)g(\q)g(to)f(quit)347 1454 y(type)h(\g)g(or)f(terminate)g
- (with)h(semicolon)e(to)i(execute)f(query)288 1514 y(You)g(are)h
- (currently)f(connected)g(to)g(the)h(database:)f(testdb)258
- 1633 y(testdb=>)198 1745 y Ft(No)o(w)16 b(you)g(can)g(either)g(enter)g
- (an)o(y)g(v)o(alid)g(SQL)g(statement)h(terminated)e(by)h(a)g(';')i(or)d
- (use)i(one)f(of)g(the)198 1805 y Fp(slash)d(commands)p
- Ft(.)j(A)c(list)h(of)f(all)g(a)o(v)o(ailable)g Fp(slash)h(commands)f
- Ft(can)h(be)f(obtained)g(by)h(typing)e Fr(')p Fo(n)p
- Fr(?')p Ft(.)198 1924 y(Here)h(is)h(a)f(list)h(of)f(the)g(most)g
- (important)g Fp(slash)h(commands)p Ft(:)273 2035 y Fo( 17)25
- b(n)p Fr(?)f Ft(lists)13 b(all)f(a)o(v)o(ailable)g Fp(slash)h(commands)
- g Ft(and)f(gi)o(v)o(es)h(a)f(short)g(description.)273
- 2151 y Fo( 17)25 b(n)p Fr(q)f Ft(quits)13 b Fr(psql)p
- Ft(.)273 2266 y Fo( 17)25 b(n)p Fr(d)f Ft(lists)13 b(all)f(tables,)h
- (vie)o(ws)g(and)f(inde)o(x)o(es)h(e)o(xisting)g(in)f(the)g(current)g
- (database.)273 2381 y Fo( 17)25 b(n)p Fr(dt)f Ft(lists)13
- b(only)f(tables.)273 2497 y Fo( 17)25 b(n)p Fr(dT)f
- Ft(lists)13 b(all)f(a)o(v)o(ailable)g(data)h(types.)273
- 2612 y Fo( 17)25 b(n)p Fr(i)k Fk(<)p Fr(filename)p Fk(>)24
- b Ft(reads)12 b(and)h(e)o(x)o(ecutes)g(the)f(queries)h(contained)f(in)g
- Fr(filename)p Ft(.)273 2727 y Fo( 17)25 b(n)p Fr(l)f
- Ft(lists)13 b(all)f(a)o(v)o(ailable)g(databases)i(kno)o(wn)d(to)i(the)f
- (system.)273 2843 y Fo( 17)25 b(n)p Fr(connect)k Fk(<)p
- Fr(database)p Fk(>)37 b Ft(terminates)19 b(the)g(current)g(connection)g
- (and)g(opens)h(a)f(ne)o(w)323 2902 y(connection)12 b(to)g
- Fr(database)p Ft(.)273 3018 y Fo( 17)25 b(n)p Fr(o)k
- Fl([)p Fk(<)p Fr(filename)p Fk(>)p Fl(])23 b Ft(sends)14
- b(all)e(query)g(output)f(to)i Fr(file)p Ft(.)198 3182
- y Fh(2.4.4)59 b(De 02ning)15 b(and)g(P)o(opulating)f(T)-5
- b(ables)198 3283 y Ft(De 02ning)13 b(tables)i(and)f(inserting)f
- (tuples)h(is)g(done)g(by)g(the)g(SQL)g(statements)g Fr(CREATE)30
- b(TABLE)13 b Ft(and)198 3342 y Fr(INSERT)29 b(INTO)p
- Ft(.)14 b(F)o(or)f(a)g(detailed)h(description)e(on)i(the)f(syntax)h(of)
- f(these)h(commands)f(refer)g(to)g(sec-)198 3402 y(tion)f(1.3.2)h
- Fp(Data)f(De 02nition)p Ft(.)p eop
- %%Page: 30 30
- 30 29 bop 270 60 a Ft(30)310 b Fm(CHAPTER)14 b(2.)25
- b(POSTGRESQL)13 b(FR)n(OM)f(THE)i(USER'S)e(POINT)g(OF)g(VIEW)270
- 234 y Fn(Example)h(2.1)25 b Ft(T)l(o)12 b(create)g(and)g(populate)g
- (the)g(table)g(SUPPLIER)g(used)g(in)g( 02gure)g(1.1)g
- Fp(The)g(suppliers)270 294 y(and)g(parts)h(database)f
- Ft(we)h(could)f(use)h(the)f(follo)o(wing)f(session:)330
- 403 y Fr($)30 b(psql)f(testdb)330 522 y(Welcome)g(to)h(the)f
- (POSTGRESQL)g(interactive)g(sql)g(monitor:)390 582 y(Please)g(read)g
- (the)h(file)f(COPYRIGHT)g(for)h(copyright)f(terms)g(of)390
- 642 y(POSTGRESQL)419 761 y(type)h(\?)g(for)f(help)h(on)f(slash)h
- (commands)419 821 y(type)g(\q)g(to)f(quit)419 881 y(type)h(\g)g(or)f
- (terminate)g(with)h(semicolon)e(to)i(execute)f(query)360
- 941 y(You)g(are)h(currently)f(connected)g(to)g(the)h(database:)f
- (testdb)330 1060 y(testdb=>)g(create)g(table)g(supplier)g((sno)h
- (int4,)330 1120 y(testdb->)f(sname)g(varchar(20),)330
- 1180 y(testdb->)g(city)g(varchar(20));)330 1239 y(CREATE)330
- 1299 y(testdb=>)g(insert)g(into)g(supplier)g((sno,)h(sname,)f(city))
- 330 1359 y(testdb->)g(values)g((1,'Smith','London');)330
- 1419 y(INSERT)g(26187)g(1)330 1479 y(testdb=>)g(insert)g(into)g
- (supplier)g((sno,)h(sname,)f(city))330 1538 y(testdb->)g(values)g
- ((2,'Jones','Paris');)330 1598 y(INSERT)g(26188)g(1)330
- 1658 y(testdb=>)g(insert)g(into)g(supplier)g((sno,)h(sname,)f(city))
- 330 1718 y(testdb->)g(values)g((3,'Adams','Vienna');)330
- 1777 y(INSERT)g(26189)g(1)330 1837 y(testdb=>)g(insert)g(into)g
- (supplier)g((sno,)h(sname,)f(city))330 1897 y(testdb->)g(values)g
- ((4,'Blake','Rome');)330 1957 y(INSERT)g(26190)g(1)330
- 2017 y(testdb=>)270 2123 y Ft(If)12 b(you)g( 02rst)g(put)g(all)g(the)h
- (abo)o(v)o(e)f(commands)h(into)f(a)g( 02le)g(you)h(can)f(easily)h(e)o
- (x)o(ecute)g(the)f(statements)h(by)270 2183 y(the)f Fp(slash)h(command)
- 25 b Fo(n)p Fr(i)k Fk(<)p Fr(file)p Fk(>)p Ft(.)270 2302
- y(Note:)34 b(The)22 b(data)g(type)f Fr(int4)h Ft(is)g(not)f(part)g(of)h
- (the)f(SQL92)h(standard.)44 b(It)21 b(is)h(a)g(b)o(uilt)f(in)h(Post-)
- 270 2362 y(greSQL)13 b(type)g(denoting)g(a)g(four)f(byte)h(signed)g
- (inte)o(ger)m(.)18 b(F)o(or)13 b(information)f(on)h(which)g(data)g
- (types)g(are)270 2422 y(a)o(v)o(ailable)g(you)h(can)g(use)g(the)f
- Fo(n)p Fr(dT)h Ft(command)f(which)h(will)f(gi)o(v)o(e)g(a)h(list)g(and)
- f(short)h(description)f(of)g(all)270 2482 y(datatypes)g(currently)e
- (kno)o(wn)h(to)g(PostgreSQL.)270 2637 y Fh(2.4.5)59 b(Retrie)o(ving)13
- b(Data)i(Fr)o(om)f(The)g(Database)270 2734 y Ft(After)19
- b(ha)o(ving)g(de 02ned)h(and)f(populated)h(the)f(tables)h(in)g(the)g
- (database)g Fr(testdb)f Ft(we)h(are)f(able)h(to)270 2794
- y(retrie)o(v)o(e)10 b(data)h(by)g(formulating)e(queries)i(using)g
- Fr(psql)p Ft(.)k(Ev)o(ery)d(query)e(has)h(to)g(be)g(terminated)f(by)h
- (a)h(';'.)270 2927 y Fn(Example)h(2.2)25 b Ft(W)l(e)f(assume)h(that)f
- (all)g(the)g(tables)g(form)f( 02gure)g(1.1)i Fp(The)e(suppliers)i(and)
- f(parts)270 2987 y(database)19 b Ft(e)o(xist)h(in)f(the)g(database)g
- Fr(testdb)p Ft(.)36 b(If)18 b(we)i(want)e(to)h(kno)o(w)g(all)g(parts)g
- (that)g(are)g(sold)g(in)270 3047 y(London)12 b(we)h(use)g(the)f(follo)o
- (wing)f(session:)330 3155 y Fr(testdb=>)29 b(select)g(p.pname)330
- 3215 y(testdb->)g(from)g(supplier)g(s,)h(sells)f(se,)h(part)f(p)330
- 3275 y(testdb->)g(where)g(s.sno=se.sno)g(and)330 3335
- y(testdb->)208 b(p.pno=se.pno)29 b(and)330 3395 y(testdb->)208
- b(s.city='London';)p eop
- %%Page: 31 31
- 31 30 bop 198 60 a Fm(2.5.)29 b(SOME)12 b(OF)h(POSTGRESQL)-5
- b('S)12 b(SPECIAL)h(FEA)-6 b(TURES)14 b(IN)e(DET)-5 b(AIL)340
- b Ft(31)258 234 y Fr(pname)258 294 y(-----)258 354 y(Screw)258
- 413 y(Nut)258 473 y((2)29 b(rows))258 593 y(testdb=>)198
- 729 y Fn(Example)13 b(2.3)25 b Ft(W)l(e)18 b(use)h(again)f(the)g
- (tables)g(gi)o(v)o(en)g(in)g( 02gure)f(1.1.)33 b(No)o(w)18
- b(we)g(want)g(to)g(retrie)o(v)o(e)f(all)198 789 y(suppliers)12
- b(selling)h(no)f(parts)g(at)h(all)f((to)g(remo)o(v)o(e)g(them)g(from)f
- (the)i(suppliers)f(table)g(for)g(e)o(xample):)258 900
- y Fr(testdb=>)29 b(select)g(*)h(from)f(supplier)g(s)258
- 960 y(testdb->)g(where)g(not)h(exists)258 1020 y(testdb->)507
- b((select)29 b(sno)h(from)f(sells)g(se)258 1080 y(testdb->)537
- b(where)29 b(se.sno)g(=)h(s.sno);)258 1139 y(sno|sname|city)258
- 1199 y(---+-----+----)258 1259 y((0)f(rows))258 1378
- y(testdb=>)198 1487 y Ft(The)15 b(result)f(relation)g(is)h(empty)f(in)h
- (our)f(e)o(xample)h(telling)f(us)h(that)f(e)o(v)o(ery)g(supplier)g
- (contained)h(in)f(the)198 1546 y(database)e(sells)f(at)g(least)h(one)f
- (part.)k(Note)c(that)g(we)g(used)g(a)h(nested)f(subselect)h(to)f
- (formulate)e(the)i(query)m(.)198 1730 y Fi(2.5)71 b(Some)18
- b(of)f(P)o(ostgr)o(eSQL)-8 b(')m(s)16 b(Special)i(F)n(eatur)o(es)e(in)i
- (Detail)198 1847 y Ft(T)n(raditional)23 b(relational)g(database)h
- (management)g(systems)g((RDMSs))g(pro)o(vide)f(only)g(v)o(ery)h(fe)o
- (w)198 1907 y(datatypes)16 b(including)e( 03oating)h(point)g(numbers,)
- h(inte)o(gers,)g(character)f(strings,)i(mone)o(y)m(,)f(and)f(dates.)198
- 1967 y(This)j(makes)f(the)g(implementation)f(of)h(man)o(y)g
- (applications)g(v)o(ery)g(dif)o( 02cult)e(and)j(that')m(s)f(why)g
- (Post-)198 2026 y(greSQL)12 b(of)o(fers)e(substantial)i(additional)f
- (po)o(wer)h(by)f(incorporating)f(the)i(follo)o(wing)f(additional)g
- (basic)198 2086 y(concepts)i(in)f(such)h(a)f(way)g(that)g(users)h(can)g
- (easily)f(e)o(xtend)h(the)f(system:)273 2194 y Fo( 17)25
- b Ft(inheritance)273 2305 y Fo( 17)g Ft(user)12 b(de 02ned)g
- (functions)273 2416 y Fo( 17)25 b Ft(user)12 b(de 02ned)g(types)273
- 2527 y Fo( 17)25 b Ft(rules)198 2636 y(Some)11 b(other)g(features,)h
- (implemented)e(in)h(most)h(modern)e(RDBMSs)j(pro)o(vide)e(additional)f
- (po)o(wer)h(and)198 2695 y( 03e)o(xibility:)273 2804
- y Fo( 17)25 b Ft(constraints)12 b((gi)o(v)o(en)g(in)g(the)g
- Fr(create)29 b(table)12 b Ft(command))273 2915 y Fo( 17)25
- b Ft(triggers)273 3026 y Fo( 17)g Ft(transaction)12
- b(inte)o(grity)198 3184 y Fh(2.5.1)59 b(Inheritance)198
- 3283 y Ft(Inheritance)14 b(is)h(a)g(feature)f(well)g(kno)o(wn)g(from)g
- (object)h(oriented)f(programming)e(languages)j(such)h(as)198
- 3342 y(Smalltalk)c(or)g(C++.)18 b(PostgreSQL)13 b(refers)f(to)h(tables)
- g(as)g Fp(classes)h Ft(and)f(the)g(de 02nition)f(of)h(a)g
- Fp(class)g Ft(may)198 3402 y(inherit)f(the)g(contents)g(of)g(another)g
- Fp(class)p Ft(:)p eop
- %%Page: 32 32
- 32 31 bop 270 60 a Ft(32)307 b Fm(CHAPTER)14 b(2.)28
- b(POSTGRESQL)13 b(FR)n(OM)f(THE)i(USER'S)e(POINT)g(OF)g(VIEW)270
- 234 y Fn(Example)h(2.4)25 b Ft(First)12 b(we)g(de 02ne)g(a)h(table)f
- ((class))h Fr(city)p Ft(:)330 320 y Fr(testdb=>)29
- b(create)g(table)g(city)h(()330 380 y(testdb->)f(name)g
- (varchar(20),)330 440 y(testdb->)g(population)g(int4,)330
- 500 y(testdb->)g(altitude)g(int4);)330 560 y(CREATE)330
- 619 y(testdb=>)270 706 y Ft(No)o(w)17 b(we)g(de 02ne)f(a)i(ne)o(w)e
- (table)h((class))g Fr(capital)f Ft(that)h(inherits)f(all)h(attrib)o
- (utes)g(from)f Fr(city)g Ft(and)270 765 y(adds)d(a)f(ne)o(w)h(attrib)o
- (ute)e Fr(country)h Ft(storing)g(the)g(country)f(which)i(it)f(is)g(the)
- h(capital)f(of.)330 852 y Fr(testdb=>)29 b(create)g(table)g(capital)g
- (()330 912 y(testdb->)g(country)g(varchar(20))330
- 971 y(testdb->)g())h(inherits)f((city);)330 1031 y(CREATE)330
- 1091 y(testdb=>)270 1177 y Fn(Note)p Ft(:)23 b(The)17
- b(class)g Fr(capital)f Ft(inherits)g(only)g(the)g(attrib)o(utes)g(of)g
- Fr(city)g Ft((not)g(the)g(tuples)h(stored)f(in)270 1237
- y Fr(city)p Ft().)f(The)e(ne)o(w)f(table)g(can)h(be)g(used)f(as)h(if)f
- (it)g(were)g(de 02ned)h(without)e(using)i(inheritance:)330
- 1323 y Fr(testdb=>)29 b(insert)g(into)g(capital)h((name,)f
- (population,)330 1383 y(testdb->)656 b(altitude,)29 b(state))330
- 1443 y(testdb->)g(values)g(('Vienna',)g(1500000,)g(200,)g
- ('Austria');)330 1503 y(INSERT)g(26191)g(1)330 1562
- y(testdb=>)270 1649 y Ft(Let')m(s)18 b(assume)g(that)f(the)g(tables)h
- Fr(city)f Ft(and)g Fr(capital)g Ft(ha)o(v)o(e)h(been)f(populated)g(in)g
- (the)h(follo)o(wing)270 1709 y(way:)330 1795 y Fr(city)179
- b(name)149 b(|)29 b(population)g(|)h(altitude)629 1855
- y(---------+------------+------)o(---)629 1914 y(Linz)149
- b(|)g(200000)29 b(|)179 b(270)629 1974 y(Graz)149 b(|)g(250000)29
- b(|)179 b(350)629 2034 y(Villach)59 b(|)179 b(50000)29
- b(|)179 b(500)629 2094 y(Salzburg)29 b(|)149 b(150000)29
- b(|)179 b(420)330 2273 y(capital)89 b(name)149 b(|)29
- b(population)g(|)h(altitude)f(|)60 b(country)629 2333
- y(---------+------------+------)o(----+----)o(-----)629
- 2393 y(Vienna)89 b(|)119 b(1500000)29 b(|)179 b(200)30
- b(|)60 b(Austria)270 2479 y Ft(Standard)12 b(SQL92)g(queries)g(against)
- 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
- (xpected:)330 2565 y Fr(testdb=>)29 b(select)g(*)h(from)f(city)330
- 2625 y(testdb->)g(where)g(altitude)g(>)h(400;)330 2685
- y(name)149 b(|)30 b(population)e(|)i(altitude)330 2745
- y(---------+------------+-------)o(--)330 2804 y(Villach)59
- b(|)179 b(50000)29 b(|)180 b(500)330 2864 y(Salzburg)29
- b(|)149 b(150000)29 b(|)180 b(420)330 2924 y((2)29 b(rows))330
- 3044 y(testdb=>)g(select)g(*)h(from)f(capital;)330 3103
- y(name)149 b(|)30 b(population)e(|)i(altitude)f(|)60
- b(country)330 3163 y(---------+------------+-------)o(---+-----)o(----)
- 330 3223 y(Vienna)89 b(|)119 b(1500000)29 b(|)180 b(200)29
- b(|)60 b(Austria)330 3283 y((1)29 b(row))330 3402 y(testdb=>)p
- eop
- %%Page: 33 33
- 33 32 bop 198 60 a Fm(2.5.)29 b(SOME)12 b(OF)h(POSTGRESQL)-5
- b('S)12 b(SPECIAL)h(FEA)-6 b(TURES)14 b(IN)e(DET)-5 b(AIL)340
- 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
- (all)g(cities)h((including)e(capitals))h(that)g(are)g(located)h(at)f
- (an)h(altitude)198 294 y(o)o(v)o(er)g(100)h(meters)f(the)g(query)g(is:)
- 258 376 y Fr(testdb=>)29 b(select)g(*)h(from)f(city*)258
- 436 y(testdb->)g(where)g(altitude)g(>)h(100;)258 495
- y(name)149 b(|)30 b(population)e(|)i(altitude)258 555
- y(---------+------------+-------)o(--)258 615 y(Linz)149
- b(|)g(200000)29 b(|)180 b(270)258 675 y(Graz)149 b(|)g(250000)29
- b(|)180 b(350)258 734 y(Villach)59 b(|)179 b(50000)29
- b(|)180 b(500)258 794 y(Salzburg)29 b(|)149 b(150000)29
- b(|)180 b(420)258 854 y(Vienna)89 b(|)119 b(1500000)29
- b(|)180 b(200)258 914 y((5)29 b(rows))258 1033 y(testdb=>)198
- 1115 y Ft(Here)14 b(the)h('*')f(after)g Fr(city)g Ft(indicates)h(that)f
- (the)g(query)h(should)f(be)h(run)f(o)o(v)o(er)g Fr(city)h
- Ft(and)f(all)h(classes)198 1175 y(belo)o(w)i Fr(city)g
- Ft(in)g(the)g(inheritance)f(hierarchy)m(.)29 b(Man)o(y)18
- b(of)e(the)i(commands)f(that)g(we)g(ha)o(v)o(e)g(already)198
- 1235 y(discussed)c((SELECT)l(,)i(UPD)n(A)-6 b(TE,)14
- b(DELETE,)h(etc))d(support)g(this)g('*')g(notation.)198
- 1373 y Fh(2.5.2)59 b(User)15 b(De 02ned)g(Functions)198
- 1467 y Ft(PostgreSQL)i(allo)o(ws)g(the)g(de 02nition)f(and)h(usage)h
- (of)e Fp(user)i(de 02ned)f(functions)p Ft(.)30 b(The)17
- b(ne)o(w)g(de 02ned)198 1527 y(functions)12 b(can)g(be)h(used)g
- (within)e(e)o(v)o(ery)i(query)m(.)i(PostgreSQL)d(pro)o(vides)g(two)g
- (types)g(of)g(functions:)273 1608 y Fo( 17)25 b Ft(Query)11
- b(Language)i((SQL))f(Functions:)j(functions)d(written)f(in)h(SQL.)273
- 1699 y Fo( 17)25 b Ft(Programming)14 b(Language)j(Functions:)22
- b(functions)16 b(written)f(in)h(a)h Fp(compiled)f Ft(language)g(such)
- 323 1759 y(as)c(C.)198 1888 y Fn(Query)g(Language)g((SQL))f
- (Functions)198 1981 y Ft(These)k(functions)d(are)i(de 02ned)f(using)h
- (SQL.)g(Note)f(that)g Fp(query)h(language)e(functions)h
- Ft(do)h(not)f(e)o(xtend)198 2041 y(the)k Fp(e)o(xpr)n(essive)h(power)g
- Ft(of)e(the)h(SQL92)g(standard.)29 b(Ev)o(ery)17 b Fp(query)g(language)
- f(function)g Ft(can)h(be)g(re-)198 2100 y(placed)10 b(by)g(an)g
- (appropriate)f(nested)h(query)f(()p Fp(subselect)p Ft())h(without)f
- (changing)h(the)f(semantical)h(meaning)198 2160 y(of)j(the)g(whole)g
- (query)m(.)k(Ho)o(we)o(v)o(er)n(,)d(since)f(PostgreSQL)g(does)h(not)f
- (allo)o(w)f Fp(subselects)j Ft(in)e(the)g Fp(selectlist)198
- 2220 y Ft(at)g(the)f(moment)g(b)o(ut)h(does)g(allo)o(w)f(the)g(usage)h
- (of)g Fp(query)g(language)e(functions)p Ft(,)i(the)f
- Fp(e)o(xpr)n(essive)i(power)198 2280 y Ft(of)e(PostgreSQL)-5
- b(')m(s)13 b(current)e(SQL)i(implementation)e(is)i(e)o(xtended.)273
- 2340 y(The)44 b(de 02nition)f(of)h Fp(query)g(language)e(functions)i
- Ft(is)g(done)g(using)g(the)g(command)198 2399 y Fr(create)29
- b(function)g Fk(<)p Fr(function)p 958 2399 15 2 v 17
- w(name)p Fk(>)o Ft(.)d(Ev)o(ery)16 b(function)f(can)h(take)f(zero)g(or)
- h(more)f(ar)o(-)198 2459 y(guments.)23 b(The)16 b(type)f(of)f(e)o(v)o
- (ery)h(ar)o(gument)f(is)h(speci 02ed)h(in)e(the)h(list)g(of)g(ar)o
- (guments)f(in)h(the)g(function)198 2519 y(de 02nition.)28
- b(The)17 b(type)f(of)h(the)f(function')m(s)g(result)h(is)f(gi)o(v)o(en)
- h(after)f(the)g(ke)o(yword)g Fr(returns)g Ft(in)g(the)198
- 2579 y(function)d(de 02nition.)20 b(The)15 b(types)f(used)g(for)g(the)
- g(ar)o(guments)f(and)h(the)g(return)g(v)o(alue)f(of)h(the)g(function)
- 198 2638 y(can)i(either)f(be)g Fp(base)h(types)g Ft((e.g.)25
- b(int4,)17 b(v)o(archar)n(,)f(.)7 b(.)g(.)g())27 b(or)15
- b Fp(composite)g(types)p Ft(.)26 b((F)o(or)15 b(each)g(class)i((ta-)
- 198 2698 y(ble))c(that)g(is)h(created,)g(a)g(corresponding)f
- Fp(composite)g(type)h Ft(is)g(de 02ned.)19 b Fr(supplier)12
- b Ft(and)i Fr(part)f Ft(are)198 2758 y(e)o(xamples)g(for)e
- Fp(composite)i(types)g Ft(after)e(the)i(tables)f Fr(supplier)g
- Ft(and)g Fr(part)g Ft(ha)o(v)o(e)h(been)g(created.))198
- 2864 y Fn(Example)g(2.5)25 b Ft(This)13 b(is)g(an)f(e)o(xample)g(using)
- h(only)f Fp(base)h(types)p Ft(.)198 2984 y(Before)29
- b(PostgreSQL)g(was)g(e)o(xtended)g(to)h(support)e(nested)i(subqueries)f
- (user)h(de 02ned)f(query)198 3044 y(language)11 b((SQL))f(functions)
- h(could)g(be)g(used)g(to)g(simulate)g(them.)k(Consider)c(e)o(xample)h
- (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
- (names)i(of)e(all)h(suppliers)f(that)h(do)g(not)f(sell)i(an)o(y)f(part)
- f(at)h(all.)23 b(Normally)198 3163 y(we)13 b(would)f(formulate)g(the)h
- (query)f(as)i(we)f(did)g(in)f(e)o(xample)i(2.3.)j(Here)c(we)g(want)g
- (to)g(sho)o(w)g(a)g(possible)198 3223 y(way)h(of)g(formulating)f(the)h
- (query)g(without)g(using)g(a)h(subquery)m(.)21 b(This)15
- b(is)g(done)f(in)h(two)e(steps.)23 b(In)14 b(the)198
- 3283 y( 02rst)j(step)h(we)f(de 02ne)h(the)f(function)f
- Fr(my)p 930 3283 V 18 w(exists)p Ft(.)30 b(In)17 b(the)h(second)g(step)
- f(we)h(formulate)e(a)i(query)198 3342 y(using)12 b(the)h(ne)o(w)f
- (function.)p eop
- %%Page: 34 34
- 34 33 bop 270 60 a Ft(34)307 b Fm(CHAPTER)14 b(2.)28
- b(POSTGRESQL)13 b(FR)n(OM)f(THE)i(USER'S)e(POINT)g(OF)g(VIEW)270
- 234 y Ft(In)f(the)h( 02rst)f(step)h(we)g(de 02ne)g(the)f(ne)o(w)h
- (function)f Fr(my)p 1188 234 15 2 v 18 w(exists(int4))f
- Ft(which)i(takes)f(an)h(inte)o(ger)g(as)270 294 y(ar)o(gument:)330
- 374 y Fr(testdb=>)29 b(create)g(function)g(my_exists(int4))f(returns)
- h(int4)330 434 y(testdb->)g(as)g('select)h(count(pno))e(from)i(sells)
- 330 494 y(testdb->)148 b(where)30 b(sno)f(=)h($1;')f(language)g('sql';)
- 330 554 y(CREATE)330 613 y(testdb=>)270 694 y Ft(Here)12
- b(is)h(the)f(second)h(step)g(which)f(performs)f(the)i(intended)f
- (retrie)o(v)o(e:)330 774 y Fr(testdb=>)29 b(select)g(s.sname)g(from)h
- (supplier)f(s)330 834 y(testdb->)g(where)g(my_exists(s.sno))f(=)i(0;)
- 330 894 y(sname)330 953 y(-----)330 1013 y((0)f(rows))330
- 1133 y(testdb=>)270 1213 y Ft(No)o(w)12 b(let')m(s)h(ha)o(v)o(e)f(a)h
- (look)f(at)g(what)h(is)f(happening)g(here.)k(The)d(function)e
- Fr(my)p 1582 1213 V 18 w(exists(int4))g Ft(takes)270
- 1273 y(one)j(ar)o(gument)f(which)h(must)g(be)g(of)f(type)h(inte)o(ger)m
- (.)20 b(W)n(ithin)13 b(the)h(function)f(de 02nition)g(this)h(ar)o
- (gument)270 1332 y(can)20 b(be)f(refered)g(to)g(using)h(the)f($1)h
- (notation)f((if)f(there)h(were)h(furhter)e(ar)o(guments)h(the)o(y)h
- (could)f(be)270 1392 y(referred)13 b(to)i(by)f($2,)h($3,)h(.)7
- b(.)g(.)g().)25 b Fr(my)p 889 1392 V 17 w(exists(int4))14
- b Ft(returns)g(the)g(number)g(of)g(tuples)h(from)e(table)270
- 1452 y Fr(sells)19 b Ft(where)f(the)h(attrib)o(ute)f
- Fr(sno)h Ft(is)h(equal)f(to)f(the)h(gi)o(v)o(en)g(ar)o(gument)g($1)f
- (()p Fr(sno)30 b(=)f($1)p Ft().)36 b(The)270 1512 y(ke)o(yword)12
- b Fr(language)29 b('sql')13 b Ft(tells)h(PostgreSQL)f(that)h(the)f(ne)o
- (w)h(function)e(is)i(a)g(query)f(language)270 1572 y(function.)345
- 1631 y(The)e(query)f(in)g(the)h(second)g(step)g(e)o(xamines)g(e)o(v)o
- (ery)f(tuple)h(from)e(table)i Fr(supplier)f Ft(and)g(checks)i(if)270
- 1691 y(it)f(sati 02es)g(the)g(gi)o(v)o(en)g(quali 02cation.)j(It)d
- (does)g(so)g(by)g(taking)g(the)f(supplier)h(id)g Fr(sno)f
- 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
- (ar)o(gument)e(to)i(the)f(function)f Fr(my)p 1127 1751
- V 18 w(exists(int4))p Ft(.)j(In)e(other)g(words)g(the)g(function)270
- 1811 y Fr(my)p 333 1811 V 18 w(exists(int4))17 b Ft(is)h(called)h
- (once)f(for)g(e)o(v)o(ery)g(tuple)g(of)g(table)g Fr(supplier)p
- Ft(.)33 b(The)19 b(function)270 1870 y(returns)10 b(the)h(number)f(of)h
- (tuples)g(ha)o(ving)f(the)h(gi)o(v)o(en)f(supplier)h(id)g
- Fr(sno)f Ft(contained)h(in)f(table)h Fr(sells)p Ft(.)k(A)270
- 1930 y(result)c(of)f(zero)h(means)h(that)f(no)g(such)g(tuple)g(is)g(a)o
- (v)o(ailable)g(meaning)g(that)f(the)h(corresponding)g(supplier)270
- 1990 y(does)i(not)g(sell)g(a)g(single)g(part.)k(W)l(e)c(can)h(see)f
- (that)g(this)g(query)f(is)i(semantically)e(equi)o(v)o(alent)g(to)h(the)
- g(one)270 2050 y(gi)o(v)o(en)f(in)g(e)o(xample)h(2.3.)270
- 2155 y Fn(Example)g(2.6)25 b Ft(This)13 b(e)o(xample)f(sho)o(ws)h(ho)o
- (w)f(to)g(use)h(a)g Fp(composite)f(type)h Ft(in)f(a)g(function)g
- (de 02nition.)270 2274 y(Imagine)21 b(that)g(the)h(price)f(of)g(e)o(v)
- o(ery)g(part)g(was)h(doubled)f(o)o(v)o(er)h(night.)42
- b(If)21 b(you)h(want)e(to)i(look)f(at)270 2334 y(the)d(part)f(table)h
- (with)f(the)h(ne)o(w)g(v)o(alues)f(you)h(could)g(use)g(the)g(follo)o
- (wing)e(function)h(which)g(uses)i(the)270 2394 y Fp(composite)12
- b(type)h Fr(part)f Ft(for)f(its)i(ar)o(gument:)330 2474
- y Fr(testdb=>)29 b(create)g(function)g(new_price(part))f(returns)h
- (float)330 2534 y(testdb->)g(as)g('select)h($1.price)f(*)g(2;')h
- (language)f('sql';)330 2594 y(CREATE)330 2654 y(testdb=>)g(select)g
- (pno,)g(pname,)h(new_price(price))e(as)h(new_price)330
- 2713 y(testdb->)g(from)g(part;)330 2773 y(pno)g(|)60
- b(pname)f(|)h(new_price)330 2833 y(----+---------+-----------)360
- 2893 y(1)f(|)h(Screw)f(|)269 b(20)360 2952 y(2)59 b(|)h(Nut)119
- b(|)269 b(16)360 3012 y(3)59 b(|)h(Bolt)89 b(|)269 b(30)360
- 3072 y(4)59 b(|)h(Cam)119 b(|)269 b(50)330 3132 y((4)29
- b(rows))330 3251 y(testdb=>)270 3332 y Ft(Note)12 b(that)h(this)g
- (could)f(ha)o(v)o(e)h(been)g(done)f(by)g(a)h(normal)f(query)g
- ((without)g(using)g(a)h(user)g(de 02ned)f(func-)270
- 3391 y(tion))g(as)g(well)h(b)o(ut)f(it')m(s)g(an)h(easy)g(to)f
- (understand)g(e)o(xample)g(for)g(the)g(usage)h(of)f(functions.)p
- eop
- %%Page: 35 35
- 35 34 bop 198 60 a Fm(2.5.)29 b(SOME)12 b(OF)h(POSTGRESQL)-5
- b('S)12 b(SPECIAL)h(FEA)-6 b(TURES)14 b(IN)e(DET)-5 b(AIL)340
- b Ft(35)198 234 y Fn(Pr)o(ogramming)13 b(Language)f(Functions)198
- 328 y Ft(PostgreSQL)h(also)g(supports)g Fp(user)g(de 02ned)g
- (functions)g Ft(written)f(in)h(C.)g(This)h(is)f(a)g(v)o(ery)g(po)o
- (werful)f(fea-)198 387 y(ture)18 b(because)h(you)g(can)f(add)h(an)o(y)g
- (function)e(that)i(can)f(be)h(formulated)e(in)i(C.)g(F)o(or)f(e)o
- (xample)h(Post-)198 447 y(greSQL)c(lacks)h(the)f(function)f
- Fr(sqrt())g Ft(b)o(ut)h(it)g(can)h(be)f(easily)g(added)h(using)f(a)g
- (programming)f(lan-)198 507 y(guage)e(function.)198 626
- 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
- (the)g(user)g(de 02ned)g(function)f Fr(pg)p 1594 626
- 15 2 v 18 w(my)p 1672 626 V 18 w(sqrt(int4))p Ft(.)198
- 686 y(The)c(implementation)e(can)i(be)f(di)o(vided)g(into)g(three)g
- (steps:)273 785 y Fo( 17)25 b Ft(formulating)10 b(the)j(ne)o(w)f
- (function)f(in)h(C)273 885 y Fo( 17)25 b Ft(compiling)11
- b(and)h(linking)g(it)g(to)g(a)h(shared)f(library)273
- 984 y Fo( 17)25 b Ft(making)11 b(the)i(ne)o(w)f(function)f(kno)o(wn)h
- (to)g(PostgreSQL)198 1093 y Fn(F)o(ormulating)g(the)g(New)g(Function)f
- (in)h(C:)25 b Ft(W)l(e)16 b(create)g(a)h(ne)o(w)e( 02le)h(called)g
- Fr(sqrt.c)g Ft(and)g(add)g(the)323 1153 y(follo)o(wing)10
- b(lines:)382 1272 y Fr(#include)29 b(<postgres.h>)382
- 1332 y(#include)g(<utils/palloc.h>)382 1392 y(#include)g(<math.h>)382
- 1511 y(int4)h(pg_my_sqrt(int4)e(arg1))382 1571 y({)442
- 1631 y(return)h((ceil(sqrt(arg1)));)382 1691 y(})323
- 1810 y Ft(The)17 b(function)g Fr(pg)p 664 1810 V 18 w(my)p
- 742 1810 V 17 w(sqrt())g Ft(takes)h(one)f(ar)o(gument)g(of)g(type)g
- Fr(int4)g Ft(which)g(is)h(a)g(Post-)323 1870 y(greSQL)i(type)g
- (de 02ned)h(in)f Fr(postgres.h)f Ft(and)i(returns)f(the)h(inte)o(ger)f
- (v)o(alue)g(ne)o(xt)h(to)f(the)323 1929 y(square)c(root)g(of)g(the)g
- (ar)o(gument.)27 b(As)17 b(with)f Fp(query)h(language)d(functions)i
- Ft((see)h(pre)o(vious)f(sec-)323 1989 y(tion))c(the)h(ar)o(guments)g
- (can)g(be)h(of)e Fp(base)i Ft(or)f(of)f Fp(composite)i(type)p
- Ft(.)k(Special)13 b(care)g(must)g(be)h(taken)323 2049
- y(when)d(using)g Fp(base)h(types)g Ft(that)f(are)h(lar)o(ger)e(than)i
- (four)e(bytes)i(in)f(length.)k(PostgreSQL)c(supports)323
- 2109 y(three)h(types)g(of)g(passing)h(a)g(v)o(alue)f(to)g(the)g(user)h
- (de 02ned)f(function:)382 2208 y Fo( 17)25 b Ft(pass)13
- b(by)g(v)o(alue,)f( 02x)o(ed)h(length)382 2288 y Fo( 17)25
- b Ft(pass)13 b(by)g(reference,)f( 02x)o(ed)g(length)382
- 2367 y Fo( 17)25 b Ft(pass)13 b(by)g(reference,)f(v)o(ariable)f
- (length)323 2467 y(Only)k(data)h(types)g(that)g(are)g(1,)h(2)f(or)f(4)h
- (bytes)g(in)g(length)g(can)g(be)g Fp(passed)g(by)g(value)p
- Ft(.)27 b(W)l(e)16 b(just)323 2527 y(gi)o(v)o(e)d(an)g(e)o(xample)g
- (for)g(the)g(usage)h(of)f Fp(base)g(types)h Ft(that)f(can)h(be)f(used)h
- (for)e Fp(pass)i(by)g(value)f Ft(here.)323 2586 y(F)o(or)j(information)
- g(on)h(ho)o(w)g(to)g(use)h(types)f(that)g(require)g Fp(pass)h(by)f(r)n
- (efer)n(ence)i Ft(or)e(ho)o(w)g(to)g(use)323 2646 y Fp(composite)12
- b(types)h Ft(refer)e(to)h([LOCK98].)198 2746 y Fn(Compiling)g(and)f
- (Linking)h(It)g(to)g(a)h(Shar)o(ed)e(Library:)25 b Ft(PostgreSQL)14
- b(binds)i(the)f(ne)o(w)g(function)f(to)323 2805 y(the)f(runtime)g
- (system)i(by)f(using)g(a)g(shared)g(library)f(containing)g(the)h
- (function.)20 b(Therefore)13 b(we)323 2865 y(ha)o(v)o(e)i(to)g(create)g
- (a)g(shared)g(library)f(out)g(of)h(the)g(object 02le(s))f
- (containing)g(the)h(function(s).)23 b(It)323 2925 y(depends)18
- b(on)f(the)h(system)g(and)g(the)f(compiler)g(ho)o(w)h(this)f(can)h(be)g
- (done.)32 b(On)18 b(a)g(Linux)f(ELF)323 2985 y(system)12
- b(using)h Fr(gcc)f Ft(it)g(can)h(be)f(done)g(by)h(using)f(the)g(follo)o
- (wing)f(commands:)382 3104 y Fr($)30 b(gcc)g(-I$PGROOT/include)e(-fpic)
- h(-c)59 b(sqrt.c)30 b(-o)f(sqrt.o)382 3164 y($)h(gcc)g(-shared)f
- (sqrt.o)g(-o)h(sqrt.so)323 3283 y Ft(where)17 b Fr($PGROOT)g
- Ft(is)g(the)h(path)f(PostgreSQL)g(was)h(installed)f(to.)31
- b(The)18 b(important)e(options)323 3342 y(gi)o(v)o(en)11
- b(to)g Fr(gcc)g Ft(here)g(are)g Fr(-fpic)g Ft(in)g(the)g( 02rst)g
- (line)g(which)g(tells)g Fr(gcc)g Ft(to)g(produce)g Fp(position)g(in-)
- 323 3402 y(dependent)e(code)h Ft(that)g(can)g(be)g(loaded)g(to)f(an)o
- (y)h(address)h(of)e(the)h(process)g(image)g(and)g Fr(-shared)p
- eop
- %%Page: 36 36
- 36 35 bop 270 60 a Ft(36)307 b Fm(CHAPTER)14 b(2.)28
- b(POSTGRESQL)13 b(FR)n(OM)f(THE)i(USER'S)e(POINT)g(OF)g(VIEW)395
- 234 y Ft(in)g(the)g(second)h(line)g(telling)f Fr(gcc)g
- Ft(to)g(produce)h(a)f(shared)h(library)m(.)i(If)d(you)g(got)h(another)f
- (system)395 294 y(where)k(the)g(abo)o(v)o(e)h(described)f(steps)h(do)f
- (not)g(work)g(you)g(will)g(ha)o(v)o(e)g(to)h(refer)e(to)h(the)g(manual)
- 395 354 y(pages)i(of)g(your)g(c-compiler)f((often)g
- Fr(man)30 b(cc)p Ft())18 b(and)g(your)f(linker)h(()p
- Fr(man)29 b(ld)p Ft())17 b(to)i(see)f(ho)o(w)395 413
- y(shared)12 b(libraries)g(can)g(be)h(b)o(uilt.)270 599
- y Fn(Making)f(the)f(New)i(Function)e(Known)g(to)h(P)o(ostgr)o(eSQL:)25
- b Ft(No)o(w)f(we)g(ha)o(v)o(e)g(to)g(tell)f(PostgreSQL)395
- 659 y(about)18 b(the)g(ne)o(w)h(function.)34 b(W)l(e)18
- b(do)h(so)g(by)f(using)h(the)g Fr(create)29 b(function)18
- b Ft(command)395 719 y(within)11 b Fr(psql)h Ft(as)h(we)g(did)f(for)f
- Fp(query)i(language)e(functions)p Ft(:)454 924 y Fr(testdb=>)29
- b(create)h(function)f(pg_my_sqrt(int4))f(returns)h(int4)454
- 984 y(testdb->)g(as)h('/<where_ever_you_put_it>/sqrt.)o(so')454
- 1044 y(testdb->)f(language)g('c';)454 1103 y(CREATE)454
- 1163 y(testdb=>)395 1369 y Ft(From)13 b(no)o(w)h(on)g(the)g(function)f
- Fr(pg)p 998 1369 15 2 v 18 w(my)p 1076 1369 V 17 w(sqrt(int4))h
- Ft(can)g(be)g(used)h(in)f(e)o(v)o(ery)g(query)m(.)20
- b(Here)395 1429 y(is)12 b(a)h(query)f(against)g(table)g
- Fr(part)g Ft(using)h(the)f(ne)o(w)g(function:)454 1634
- y Fr(testdb=>)29 b(select)h(pname,)f(price,)g(pg_my_sqrt(price))454
- 1694 y(testdb->)g(from)h(part)454 1754 y(testdb->)f(where)h
- (pg_my_sqrt(price))e(<)h(10;)454 1813 y(pname)149 b
- (|price|pg_my_sqrt)454 1873 y(----------+-----+----------)454
- 1933 y(Screw)g(|)60 b(10)30 b(|)239 b(4)454 1993 y(Nut)209
- b(|)90 b(8)30 b(|)239 b(3)454 2053 y(Bolt)179 b(|)60
- b(15)30 b(|)239 b(4)454 2112 y(Cam)209 b(|)60 b(25)30
- b(|)239 b(5)454 2172 y((4)30 b(rows))454 2292 y(testdb=>)270
- 2552 y Fh(2.5.3)59 b(User)15 b(De 02ned)g(T)l(ypes)270
- 2687 y Ft(Adding)10 b(a)g(ne)o(w)g(data)h(type)f(to)g(PostgreSQL)g
- (also)h(requires)e(the)i(de 02nition)e(of)h(an)g Fp(input)g
- Ft(and)g(an)h Fp(output)270 2746 y(function)p Ft(.)19
- b(These)c(functions)e(are)g(implemented)g(using)h(the)f(techniques)h
- (presented)g(in)f(the)h(pre)o(vious)270 2806 y(section)f
- Fp(Pr)n(ogr)o(amming)f(Language)f(Functions)p Ft(.)16
- b(The)d(functions)f(determine)f(ho)o(w)h(the)h(type)f(appears)270
- 2866 y(in)19 b(strings)g((for)f(input)h(by)g(the)g(user)g(and)g
- (output)g(to)g(the)g(user))g(and)g(ho)o(w)g(the)g(type)g(is)h(or)o
- (ganized)270 2926 y(in)g(memory)m(.)36 b(The)20 b(input)g(function)f
- (takes)g(a)h(null-delimited)e(character)h(string)h(as)g(its)g(input)f
- (and)270 2986 y(returns)14 b(the)g(internal)g((in)f(memory))g
- (representation)h(of)g(the)g(type.)22 b(The)15 b(output)e(function)h
- (takes)g(the)270 3045 y(internal)d(representation)g(of)g(the)g(type)h
- (and)f(returns)g(a)h(null)f(delimited)g(character)g(string.)k(Besides)e
- (the)270 3105 y(de 02nition)c(of)g Fp(input)h Ft(and)f
- Fp(output)h(functions)f Ft(it)h(is)g(often)f(necessary)i(to)e(enhance)i
- (operators)e((e.g.)16 b Fr('+')p Ft())270 3165 y(and)10
- b(aggre)o(gate)g(functions)f(for)h(the)g(ne)o(w)g(data)g(type.)15
- b(Ho)o(w)9 b(this)h(is)h(done)f(is)g(described)g(in)g(section)g(2.5.4)
- 270 3225 y Fp(Extending)i(Oper)o(ators)h Ft(and)g(section)f(2.5.5)h
- Fp(Extending)g(Aggr)n(e)n(gates)p Ft(.)p eop
- %%Page: 37 37
- 37 36 bop 198 60 a Fm(2.5.)29 b(SOME)12 b(OF)h(POSTGRESQL)-5
- b('S)12 b(SPECIAL)h(FEA)-6 b(TURES)14 b(IN)e(DET)-5 b(AIL)340
- b Ft(37)198 234 y Fn(Example)13 b(2.8)25 b Ft(Suppose)13
- b(we)h(want)f(to)g(de 02ne)h(a)g(comple)o(x)f(type)g(which)h
- (represents)f(comple)o(x)h(num-)198 294 y(bers.)i(Therefore)c(we)g
- (create)h(a)f(ne)o(w)g( 02le)g(called)h Fr(complex.c)e
- Ft(with)h(the)h(follo)o(wing)e(contents:)258 381 y Fr(#include)29
- b(<postgres.h>)258 441 y(#include)g(<utils/palloc.h>)258
- 500 y(#include)g(<math.h>)258 620 y(/*)g(Type)h(definition)f(of)g
- (Complex)g(*/)258 680 y(typedef)g(struct)g(Complex)g({)377
- 739 y(double)179 b(x;)377 799 y(double)g(y;)258 859 y(})30
- b(Complex;)258 979 y(/*)f(Input)h(function:)f(takes)g(a)h(char)f
- (string)g(of)h(the)g(from)288 1038 y(*)f('x,y')h(as)f(argument)g(where)
- h(x)g(and)f(y)h(must)f(be)h(string)288 1098 y(*)f(representations)g(of)
- g(double)h(numbers.)f(It)g(returns)g(a)288 1158 y(*)g(pointer)h(to)f
- (an)h(instance)f(of)h(structure)e(Complex)i(that)288
- 1218 y(*)f(is)h(setup)f(with)h(the)f(given)h(x)g(and)f(y)h(values.)f
- (*/)258 1277 y(Complex)g(*)258 1337 y(complex_in(char)f(*str))258
- 1397 y({)318 1457 y(double)h(x,)g(y;)318 1517 y(Complex)g(*result;)318
- 1636 y(/*)g(scan)h(the)f(input)h(string)f(and)g(set)h(x)g(and)f(y)h(to)
- g(the)347 1696 y(*)g(corresponding)f(double)g(numbers)g(*/)318
- 1756 y(if)g((sscanf(str,)g(")h(()f( 45lf)h(,)g( 45lf)f()",)h(&x,)
- f(&y))h(!=)g(2))f({)377 1815 y(elog(ERROR,)g("complex_in:)g(error)g
- (in)h(parsing");)377 1875 y(return)g(NULL;)318 1935
- y(})318 1995 y(/*)f(reserve)g(memory)h(for)f(the)h(Complex)f(data)g
- (structure)347 2055 y(*)h(Note:)g(we)f(use)h(palloc)f(here)g(because)h
- (the)f(memory)347 2114 y(*)h(allocated)f(using)g(palloc)h(is)f(freed)h
- (automatically)347 2174 y(*)g(by)g(PostgreSQL)f(when)g(it)h(is)f(not)h
- (used)f(any)h(more)f(*/)318 2234 y(result)g(=)h((Complex)f
- (*)palloc(sizeof(Complex));)318 2294 y(result->x)f(=)i(x;)318
- 2353 y(result->y)e(=)i(y;)318 2413 y(return)f((result);)258
- 2473 y(})258 2593 y(/*)g(Output)h(Function)f(*/)258 2652
- y(/*)g(Takes)h(a)g(pointer)f(to)g(an)h(instance)f(of)h(structure)f
- (Complex)288 2712 y(*)g(as)h(argument)f(and)h(returns)f(a)h(character)e
- (pointer)i(to)f(a)288 2772 y(*)g(string)h(representation)e(of)i(the)f
- (given)h(argument)f(*/)258 2832 y(char)g(*)258 2891 y
- (complex_out(Complex)f(*complex))258 2951 y({)318 3011