Вы находитесь на странице: 1из 1316

An Introduction to

Database Systems
C.J.Date

Boston San Francisco New York


London Toronto Sydney Tokyo Singapore Madrid
Mexico City Munich Paris Cape Town Hong Kong Montreal


. .

-
2005

.
32.973.26-018.2.75
27
681.3.07

""
. ..
..
"" :
info@williamspublishing.com, http://www.williamspublishing.com
115419, , / 783; 03150, , / 152

, . .
27

, 8- .: . . .:
"", 2005. 1328 .: . . . .
ISBN 5-8459-0788-8 (.)


.

, ,
, , .
, , , ,
-,

.
, .
, , ,
.
32.973.26-018.2.75
.

, , ,
Addison-Wesley Publishing Company, Inc.
Authorized translation from the English language edition published by Addison-Wesley, Copyright 2004
All rights reserved. No part of this book may be reproduced or transmitted in any form or by any means,
electronic or mechanical, including photocopying, recording or by any information storage retrieval system,
without permission from the Publisher.
Russian language edition published by Williams Publishing House according to the Agreement with R&I
Enterprises International, Copyright 2005
ISBN 5-8459-0788-8 (.)
ISBN 0-321-19784-4 (.)

"", 2005
by Pearson Education, Inc., 2004

29

31

I.

41

1.

43

2.

75

3.

103

4. SQL

133

II.

163

5.

165

6.

201

7.

241

8.

289

9.

337

10.

391

III.

433

11.

437

12. : 1, 2,

457

13. :

495

14.

531

IV.

571

15.

573

16.

599

V.

645

17.

647

18.

681

19.

735

20.

769

21.

821

22.

871

23.

915

24.

971

VI. , XML

1015

25.

1017

26. -

1073

27. World Wide Web XML

1117

VII.

1173

. TransRelational

1175

. SQL

1199

1209

1215

1259

1315

29
31
31
31
32
33
34
35
37
37
39

I.

41

1.
1.1
1.2

1.3.

43
43
46
47
49
49
50
51
51
52
55
56

1.4.

,
1.5
1.6
1.7

58
59
59
62
68
71
72

74

2.

75

2.1
2.2
2.3
2.4
2.5
2.6
2.7
2.8
2.9
2.10 "/"
2.11
2.12
2.13

75
76
79
82
83
84
85
87
91
92
94
95
99
100
101

3.
3.1
3.2

3.3
3.4
3.5
3.6
3.7
3.8
3.9
3.10

103
103
103
108
109
111
114
116
117
122
123
125
127
128

4. SQL
4.1.
4.2. SQL
4.3.
4.4.
4.5.
4.6. SQL
,
,
SQL SQL/CLI
4.7. SQL
4.8.

133
133
135
138
139
140
140
144
145
148
152
152
153
155


II.
5.
5.1
5.2

5.3

, _
5.4
5.5


5.6
5.7 SQL

DISTINCT


5.8.


6.
6.1
6.2

TUPLE


6.3.
RELATION
6.4.




6.5.



6.6. SQL




6.7.

163
165
165
167
168
169
170
170
175
178
181
183
184
186
186
188
191
194
196
198
200
201
201
201
203
203
204
206
207
209
209
212
214
216
217
219
219
221
224
225
225
226
227
229
232
234
236

10

7.
7.1.
7.2.
7.3.
7.4. -

7.5.
7.5.1. , 2
7.5.2. , .

7.5.3. ,
7.5.4. , , ,
, S2
7.5.5. ,
7.5.6. , 2
7.6
7.7



7.8.


7.9.
7.10.



8.
8.1.
8.2.

241
241
244
246
249
249
250
251
251
252
254
255
258
260
260
261
261
261
261
262
263
265
265
266
266
267
268
268
268
272
275
276
279
281
282
285
289
289
291
291
293
294
295



297

298
8.3.
300
8.3.1 , 20 300
8.3.2 ,
( 7.5.5)
300
8.3.3 2
( 7.5.1)
301
8.3.4
( 7.5.2)
301
8.3.5. ,
S2
302
8.3.6.
( 7.5.3)
302
8.3.7. ,
2 ( 7.5.6)
302
8.3.8. , , ,
S2 ( 7.5.4)
302
8.3.9. , 16 ,
S2 303
8.4
303
8.5
308
8.5.1. ,
10000
309
8.5.2.
"Supplier"
309
8.5.3. ,

309
8.5.4.

309
8.5.5.
309
8.5.6.

309
8.5.7. , ,

309
8.6.
SQL
309
8.6.1. ,
10 ,
310
8.6.2. (
8.5.1)
312
8.6.3. ,

313
8.6.4. , ,
, , 313
8.6.5. ,
(. 8.3.2)
314
8.6.6.
314

11

12

8.6.7.
2
315
8.6.8.
( 8.5.4)
315
8.6.9. ,

316
8.6.10. 2
(. 7.5.1)
316
8.6.11.
(. 8.3.4)
317
8.6.12. , ,
S
317
8.6.13. 2
317
8.6.14. ,
2 ( 8.3.7)
318
8.6.15. ,
(. 8.3.6)
318
8.6.16. , 16 ,
S2, ,
(. 8.3.9)
319
8.6.17.
> 10 000 (. 8.5.1)
320
8.7.
321
8.7.1. 20
( 8.3.1)
322
8.7.2. ,
(. 8.3.2)
322
8.7.3.
(. 8.3.4)
322
8.7.4 ,
, S2 (. 8.3.5) 323
8.7.5. ,
(. 8.3.6)
323
8.7.6. ,
2 (. 8.3.7)
323
8.7.7. , ,
, ,
S2 (. 8.3.8)
323
8.7.8. , 16 ,
S2,
, (. 8.3.9)
323
8.8.
323
8.8.1. , ,
> 20 ( 8.7.1)
324
8.8.2. ,

325


13
8.8.3. ,
,
,
325
8.8.4. ,
, > 20,
( 8.8.1)
326
8.8.5. , 16
19
326
8.8.6.
( 8.6.2)
326
8.8.7. , 2
( 7.5.1)
326
8.8.8. ,
, ( 8.6.3)
327
8.8.9. ,
( 8.6.5)
8.8.10 2
327
8.8.11
( 8.6.8)
328
8.8.12. ,

328
8.8.13. , 16 ,
S2, ,
( 8.7.8).
328
8.8.14. 7 ( ,
24, )
328
8.8.15. ,
300
328
8.8.16. 2 ,

329
8.8.17. , ,

329
8.9.
329

330

333

333
9.
9.1.
9.2.
Tutorial D
9.3
9.4
9.5.
9.6
9.7
9.8

337
337
339
342
343
344
346
347
350
351

14

9.9.



9.10.




9.11 ( )
9.12 SQL

9.13.

353
353
354
355
356
356
359
360
364
366
369
370
372
373
374
375
377
381

10.
10.1.


10.2.


10.3
10.4










10.5 ( )
10.6 SQL


10.7.

391
391
393
394
395
396
398
399
400
401
402
406
409
410
410
411
413
415
420
421
423
424
425
427
428
430

15

III.

433

11.
11.1
11.2
11.3
11.4
11.5
11.6
11.7

437
437
438
442
442
444
446
449
451
453

12. : 1, 2,
12.1.


12.2.

12.3 ,
12.4
12.5 -
12.6 ,

12.7.

457
457
459
461
462
465
466
475
479
486
488
489
492

13. :

13.1
13.2
13.3
13.4
13.5


13.6. ( )

13.7.
13.8.

495
495
496
501
508
510
511
512
513
516
517
519
520
521

16

14.
14.1.
14.2.
14.3. ""


14.4. ER-


14.5. ER-

" "
" "


14.6. ER-
ER-
ER-


14.7.

531
531
533
536
537
538
538
539
540
541
541
542
542
543
543
543
545
545
546
546
548
548
549
550
551
551
553
554

IV.

571

15.
15.1.
15.2.
15.3.
ACID
15.4.
ARIES
15.5.
15.6.
15.7. ( )
15.8. SQL
15.9.

573
573
574
579
582
582
585
586
586
588
588
590
591
592

17

16.
16.1.
16.2.




16.3.
16.4.



16.5.

16.6.
16.7.
16.8.

16.9.
16.10. , ACID


16.11. SQL
16.12.

599
599
600
601
601
603
603
605
607
607
608
609
609
611
612
616
618
620
621
624
624
627
627
628
629
630
630
631
633
635

V.

645

17.
17.1.
17.2.


17.3.

17.4.
17.5.

647
647
650
654
656
656
658
660
666
667
668

17.6 SQL

GRANT REVOKE

671
671
673

18

17.7.

675
676
678

18.
18.1.
18.2.
18.3.
1.
2.
3.
4.

18.4.








18.5.
18.6. " "
18.7.


-

18.8.

681
681
683
685
686
687
688

19.
19.1.
19.2.


UN k
UNK



19.3. :

735
735
737
737
739
740
741
741
741
743
743
743
743
745

689
689
690
691
692
692
693
693
694
696
696
697
701
702
704
705
705
706
707
708
712




19.4.


19.5. ( )
19.6.
19.7. SQL




SQL
19.8.


20.
20.1.


20.2.



20.3.

20.4.


TREAT DOWN
20.5.
_

20.6.


20.7. ,

, ,


20.8.

19
746
747
747
748
749
750
754
754
755
756
756
756
758
759
760
761
762
765
769
769
771
772
774
776
778
778
779
779
781
782
783
785
786
786
788
789
790
791
791
793
795
796
797
798
800

20




20.9.


20.10. SQL

20.11.

21.
21.1.
21.2.



21.3.
1.
2.
3.
4.
5.
6.
7.
8. ;
9.
10.
11.
12.
21.4.





21.5. "/"
"/"
"/"
21.6.



21.7. SQL
21.8.

801
802
803
804
805
806
807
812
813
815
817
821
821
822
823
824
825
826
826
827
827
828
828
831
833
833
834
834
835
835
835
836
838
841
843
846
848
850
850
852
852
855
857
858
859
860
861

21

22.
22.1.
22.2.
22.3.



22.4.






22.5.



22.6.


22.7.
22.8. SQL
22.9.

871
871
873
876
877
879
882
883
884
886
886
886
887
888
888
889
889
890
890
892
896
902
903
905
907
908
909
910

23.
23.1.


23.2.
23.3.


23.4.
EXPAND COLLAPSE
PACK UNPACK


23.5.


23.6.

915
915
917
919
921
928
932
934
935
935
938
944
945
946
949
950
951
953
954

22


" "
958
23.7.





_

23.8.

955
959
960
960
961
962
962
963
965
966
967
969

24.
24.1.
24.2.

24.3.

24.4.





24.5. -
24.6.
Datalog
24.7.




24.8.

971
971
972
974
975
976
976
977
978
980
980
981
983
985
986
988
993
996
999
1000
1001
1003
1005
1006
1008
1010

VI. , XML

1015

25.
25.1.

25.2. , ,

1017
1017
1020
1022





25.3.

,

25.4.




25.5.







25.6.


26. -
26.1.
26.2.

26.3.


26.4.


26.5.
26.6. SQL
REF


SQL
26.7.

23
1023
1026
1027
1027
1032
1033
1036
1037
1038
1041
1045
1047
1048
1048
1030
1051
1053
1053
1055
1058
1061
1062
1073
1073
1077
1085
1086
1088
1090
1091
1092
1092
1094
1094
1096
1097
1100
1102
1104
1105
1106
1107

24

27. World Wide Web XML


27.1.
27.2. Web Internet
27.3. XML

L
XML
, XML, XML
27.4. XML

ID IDREF
DTD
L Schema
, XML
27.5. XML
th
Quer
27.6! XML

" "
L
27.7. SQL
" XML"
" XML"

27.8.

1117
1117
1118
1120
1121
1123
1127
1131
1133
1133
1136
1136
1137
1138
1139
1143
1143
1144
1147
1153
1153
1155
1156
1157
1157
1159
1160
1162
1164
1167

VII.

1173

. TransRelational
.
.2.
..




.4.


.5.
.6.

1175
1175
1177
1179
1180
1180
1184
1185
1185
1187
1188
1189
1192
1192

,

.7.

25
1194
1194
1195
1196
1196
1197
1197

. SQL
.1.
.2.
SELECT
FROM
WHERE
GROUP BY
HAVING

..
LIKE
MATCH
ALL ANY

1199
1199
1199
1201
1202
1202
1203
1203
1204
1205
1206
1207
1208

.
.
.
.2.

..
.4.



B-
.5.

.6.
.7.


.8.

1209
1215
1215
1216
1217
1218
1219
1220
1226
1227
1229
1229
1231
1233
1236
1238
1241
1243
1244
1245
1246
1248

26

1
3
4
5
6
7
8
9
10
11
12
0.
1.
2.
3.
13
14
15
16
17
18
19
20
22
23
24
25
26
27

1259
1259
1259
1260
1262
1266
1267
1270
1272
1276
1284
1287
1289
1290
1291
1292
1293
1295
1297
1298
1299
1300
1302
1303
1304
1306
1307
1308
1309
1309
1310

1315

.. (C.J.Date) , , , . . ,
.
1967 , - Leo Computers Ltd. (, ). IBM (UK) Development Laboratories
PL/I. 1974 IBM Systems Development Center, ,
Unified Database Language (UDL).
SQL/DS DB2 IBM.
1983 IBM.
, , 30 .
.. (E.F.Codd)
. (
, )
, , , .
, :
Temporal Data and the Relational Model, 2003 ( Morgan Kaufmann); Foundation
for Future Database Systems: The Third Manifesto ( ), 2000 (
Addison-Wesley), ;
Database: Primer, 1983, ; Relational Database Writings (1986, 1990, 1992, 1995 1998 ), ;
, : A Guide to DB2 ( ), 1993; A Guide to SYBASE and SQL Server, 1992; A Guide to SQL/DS, 1988; A Guide to
INGRES, 1987; A Guide to the SQL Standard ( ), 1997. , , , , ,
, , , , , ,
. , .
300 .
Database Programming & Design. , Web- http://dbdebunk.com.
, , , .
( 1962
, 1966 ),
(1994).


. ,
, , , .
, ( , - ).
, .

, ,

.
, , ,
:
( ..)

;

(
Java, Pascal, PL/I ..).
,
,
" ".

,
. ,
, , ,
,
1000 ( , ,
,
1000 ).
.

I. .
II. .
III. .
IV. .

32


V. .
VI. , XML
.

I ( )
.
SQL.
II ( )
,
, .
III ( )
. ,
"-".
IV ( ) (..
).
V ( ) .
,
, , , ,
..
, VI ( ) ,
. 25
, 26
- , 27 , ML.
, .
, , TransRelational,
SQL - (),
,
. , ,
, , .
,


. , , Addison-Wesley
aw.cse@aw.com.

33

Instructor's Manual ,
,
. ,
, , .
( Instructor's Manual).
PowerPoint .

tp: //www.aw.com/cssupport ( ).
, .
( ).

, , .
.

1 2.
3 4 (, 4.6 4.7).
5.
6, 7, 9 10, 8 (,
8.6, SQL).
11.
12 141, 13.
15 16 (, 15.6
).
( ),
.

().
, .
. ,

. , ,
. ,
,
, .
. .
, [3.1] 3,
.. , 1982 , 25, 2.
( , , , "",
.)
1

14 , 4.

34


.
I. 1-4 , 1-4
,
. , 4,
SQL,
SQL: 1999, , , SQL. (

.)
. , ,
, ,
SQL:2003.
II. 5-10, , ,
5-9 . ,
( ) ( 5),
, ( 9),
. ,
,
, ,
.
. .

SQL ,
,
. , , "" SQL
,
, SQL
. , SQL
,
( ),
!
, SQL, ,
.
, ,
. :
-, SQL I , -,

SQL, .
SQL
( ),
, .

35

III. 10-13
9-12 , .
.
. .
,
.
, ,

, ,
; ,


. , , III .
( , ,
.
14 ,
, , 4.)
IV. , 15 16,
, 14 15 .
, 16
ACID (
).
V. 20 23

. , ,
,
, ,
.
VI. 25 26
24 25 . 27 .
, , , ,
( ).
. ,
, .

, .
, "", SQL, "" ,

36

.. , ,
.
. ,

, - . ,
; , , II ( ), , .
, . , .

, ("")
( ),
.
.

.
.
.
.
.
.
TransRelational.

, ,
.
;
, ,
. ,
; ,
, , . , (
, !). , ,
" ", ,
.
: , ""
, Foundation for Future Database Systems: The Third Manifesto ( [.])2. ,
2
, Web- http://www.thethirc3manifesto.com.
http: / /www. dbdebunk. com.

37

, , ;
,
.
, .
, ; ,
, .
. [3.3] Tutorial D,
. Tutorial D ,

( " ").
, ,
.

,

(Bertrand Russell) The Bertrand Russell Dictionary of Mind, Matter and
Morals (ed. Lester E. Denonn) Citadel Press, 1993 (
).
... ,
1900 , ,
, ?...
, ,
,
, ,
. ,
, , .
,
... ,
, .
, ,
,
. .
, ,
, (, ,
). , .
, ,
, .

,
.

38


, (David
McGoveran) (Nick Tindall)
; 22
, 27 XML.
(Hugh Darwen),
( )
, SQL. (Nagraj Alur)
(Fabian Pascal)
. (Steve Tarin)
, , ,
.
,
, . ,

, .
(Hugh Darwen), IBM; (Guy de ), ; (Carl Eckberg), -;
(Cheng Hsu), ; -
(Abdul-Rahman Itani), -; (Vijay Kanabar), ; . (Bruce . Larsen),
; (David Livingstone),
; (David
McGoveran), Alternative Technologies; (Steve Miller),
IBM; (Fabian Pascal),
; . (Martin . Solomon),
; (Steve Tarin), Required Technologies;
(Nick Tindall), IBM. , ,
, -
,
.
(Lindy) ,
,
, .
, ,
Addison-Wesley, - (Maite Suarez-Rivas)
(Katherine Harutunian)
, (Elisabeth Beller)
.
. . ,
,
2003

39

!
, , .
, ,
. , .
.
, Web- . , ,
, ,
.
, ,
. . :
E-mail: WWW: info@williamspublishing.com
http://www.williamspublishing.com

:
:
:

115419, , / 783
03150, , / 152


I .
1 . ,

. ,

.
2

ANSI/SPARC.

.
3 ,



II .

.
4 SQL
(,
SQL: 1999).

1

1.1
1.2
1.3
1.4
1.5
1.6
1.7

1.1.
, , ,
.
, ..
, .
(
)
, :

;
;
;
;
;
.

. 1.1 ,
CELLAR ( ).
. . 1.1

44 I.
, . ( , .. ,
. .) . 1.2 ,
. . .
1.1. CELLAR

. 1.1.
, . 1.1 . 1.1 1.2, .
1. , , ,
. 1.1 1.2, SELECT, INSERT, DELETE
UPDATE , SQL. SQL IBM, , ,

1.

45

. 4
SQL,
" SQL" ,
.
SQL , Structured Query
Language ( ),
"". , , SQL ,
, "--".
.

. 1.2. ,
2. , SQL
UPDATE, (. . 1.2).
, "
" (update) (INSERT),
(DELETE) (UPDATE) , .
,
,
UPDATE.
,
. , ,
( ); , .
3. SQL , CELLAR . 11,
( ). (row)
, (column) .
,
( , ). ,
,
3
, : ,
, , .

46

I.
4. CELLAR ,
WINE PRODUCER ,
. , ,
. , CELLAR
(
).
LABEL. .
REVIEW. ,
.
MAP. , .
NOTES. , .
,
, ,
. , (data type) ,
5, 6, 26 27.
5. BIN# (primary key) CELLAR (
,
BIN#).
( . 1.1).

, : . ,
- . , ,
. ( 3 4) , , , . , ,
,
,
.
1.2.
,
, .. ,
, . , , , ,
.
, . ,
, ,
, . , , , , ,
, .

1.

47

. 1.3 .
: , ,
.
. (
,
).

. 1-3.

,
. , . ,
(" "), ,
, (" ").
(single-user system) ,
,
(multi-user system) ,
. . 1.3, , , , ,
, .

48

I.


( IV , 16).
,
. , .
, ,
.
, 2.
( , ) . 1.4, ,
,
"" , ,
"" . , ( "" ),
. ,
.

,
. ,
EMPLOYEE, , ,
, .., ENROLLMENT,
(. 1.4). ,
. , ENROLLMENT,
EMPLOYEE.

. 1.4. EMPLOYEE ENROLLMENT


,
. , , , ( ). , ,
, . , . 1.4, EMPLOYEE . ( ,
.)

1.

49

(
) ,
, . ,
-. ,
,
, . , 1.5
( , 10).
1.3 , .

:
() ( ),
,
( ..), , ..;
( ) () ,
( ).
. -,
, . -, , , . -, .

(.. , )
, -: (database
manager), (database server) , , , (DataBase Management System DBMS).
. ( ),
. , . (
, , .) ,
, , (, ,
SQL, , 1.1).
.

50

I.
.
,
. ,
, ,
(transaction manager), (transaction
processing monitor monitor).
2, 3, 15 16.

, , DB2 Universal Database
IBM. ,
,
. , .
, ,
( ).
: " X ". ; , .
(, , , , ?) , !

.
,
, .
, COBOL, PL/I, C++, Java -
(. 2).
(
SQL).
,
(. ).

, .
.
,
, .
,
, , ,
. ,
,
-, .
,
,
(
), , SELECT INSERT. SQL

1.

51

. (
,
,
, , .)
,
,
, ,
SELECT INSERT.
. ,
, ,
( ; ; ). , .. , ,
(, ,
,
, COBOL). , , , ,
.
( . 1.3 ) , .
(
) , 1.4 2
( 2.7).

.
1.3.


( !).
(persistent) , ,
, , , , , , (transient) . , ,
,
,
, - . .
( ) , - .

52

I.


, , . ( ),
( )
. .
1.
2.
3.
4.
5.

.
.
.
.
.

,
. ,
.
, .
1.
2.
3.
4.
5.

.
.
.
.
.

. . , ,
, .. , ,
(,
).

(On-Line Transaction Processing OLTP). , ,
(decision support), .
;
(data warehouse). (, ), , , (, )
. ,
, 22.

(,
KnowWare, Inc.). (Projects),

1.

53

(Parts), (Suppliers) , (Warehouses),


, (Employees), .. ,
, .. (entity),
KnowWare, Inc. . , (. 1.5).

. 1.5. "-" (ER-)


KnowWare, Inc.
( , ..),
(relationship) , . . 1.5 . ,
SP ( Shipments/Parts):
, , . (, , .) , ,
( PJ Parts/proJects); ,
( WP Warehouses/Parts) .. ,
( ), .. . , SP ,
:
, ;
, , .

54

I.

, ( , . 1.5) , .
1.
, . 1.5 ,
( ) ""
( ER-). 14.
. 1.5 , .
(..
), ,
. (SPJ), (Suppliers, Parts Projects). ()
. : .
, ("
") :
" ", " " "
".
2.
) " ".
,
, .,
) " ".
) " ".
) " ".
, , . , , , ,
, -
(, Jz), - (, Sx)

- (, PY) .
, Sx , PY
, Jz .
1
(. 1.6) ,
(relation) , ,
, . 1.1. ,
(relationship), , ,
, .
2
statement :
, (
; . " " ),
command ().

1.

55

, ,
(connection trap).
2. (),
(Parts) . ,
( ,
""). , ,
, ,
- , . ,
; (
Parts).
3. ,
. . 1.5
Projects Employees: (EJ)
, , (MJ)
.
, .
", ",
. , " 4
W8" , , , .
, ,
( ).
.

, , . , ( , )
(properties), , .
, , , ,
.. . , s,
"", CITY (), " ".
, , , . , " " :
. ,
"" " " , , . 1.1,
,
.
( , 5, 6, 26 27), ( ,

56

I.

) , : , , , ..

, , .
(data) "" ( " "). , , . ( , ,
.) " ", , , . , " S1
" . , . , " "
( , ). ,
[ 1.2].
, , SQL
. , , , ,
, ( ). , .
1. 3,
. ,
( BIN#), 72 (. . 1.1),
:
" 72 Zinfandel,
Rafanelli 1999 ,
2007 ".
2. ,

. ,
( 1.6) ,
, :
" Zinfandel
2 007 ".
(, " Zinfandel ,
, 2007
".)

, , 3.

1.

57

. ( 1.6),
, ,
, .
: ? ,
[1.1] ( ), .
, , , , , . ,
.
,
.
(implementation) , .
, , , -
, .
,
( ). ,
, ( , , )
, . , -, , .

(, ) (, ). , , , ,
( , ),
.
, . . : ( )
(, KnowWare, Inc.,
). , , .
( ), ,
- .

58

I.
,
. ,
, ( ) .
.

, ,
, .
1.4.
?
? ,
(
,
). .
(. . 1.1), .
, . ,
, , , , , ,
, , .
"" .
, .
. , , .
.
. ,
, (, "
Zinfandel Pinot Noir?"),
.
. . .
. ,
.
. .

, , , . , :
( ). :

1.

59

,
, , . .

. , , , , .
, , 1.2.
, ( )
,
. .
,
,
.
, . ,
(
).
, ,
( , , ). , ,
, . , ,
.
, , .

.
(..
, ). ,
.
2.
,
, .

1.2,
.
, .

60

I.
, .

, , .
, , . , , , ,
, . 1.2, () , ,
, , .. .
. ,
. .
, .. . , ( ).
( )
.
. , D8, . ,
(.. ). ,
, , . .
, , .
, -
(.. ), .
, ,
( ).
,
. ,
, . (propagating
updates).

(transaction) (,
),
( , ).
. ,
:

1.

61

. ,
, ,
, ,
(, -
).
. (atomicity)
.
, . (
,
, .)

15 16.

( ).
, "",
(. ). ,

. ,
. , ,
400 40,
, .
(
). (
) (integrity constraints),
- .
,
, " ",
, .
,
. ,
,
.
, , 9,
,
.

(,
)
.
(security constraints), ,
.

62

I.
(, , ..)
. ,

, () . ,
.

(
), (
) ,
. , , (,
).

( ) , .
, , , , .

. ( , 2, 21 27.) , , .

.
,
( ).
. ( , ,
.) ,
, .
1.5.
: [1.3], [1.4]. .
. ( ,
. , .)
, . ,
(, ),
. ,

1.

63

. ,
. , ,
EMPLOYEE (. . 1.4). ,
" " (. ).
,
.
. ,
, .
, ,
, (.. ) (..
), (, ). , , . , ,
. , , , ;
, .
,
, , .
1. .
, ,
, .
, " ".
, ,
. ,
,
(
, )
, . ,
,

.
,
. .
2. (
)
,
. ,
,
, ( ,

64

I.
),
.. ,
, , , . . ,
(
2000- !), , ,

, .
, ,
. 2 , .
,
, , .
: , (. 1.6).
.
(occurence, instance)
. , ,
,
" " (,
, ..)
.
. ,
, .
, ,
. ( , .)
.
.
. ,

: " ", " ", " " "
". ,
"" ( ,
).
,
. (
,

1.

65

. .)
, , ( ) .
, ,
(.. , , ), . , SALARY EMPLOYEE , ,
COBOL, .
-
, .

. 1.6. ,
, (
) .

66

I.

, , , , , , .
, ,
.
,
( ).

(,
) .
, , (,
), (
), ,
( ,
).
, .


( ASCII, EBCDIC, Unicode).

, ,
.

. , " ", ("", "", ""), , 1 = "", 2 = "" ..

(, ,
, ..).
(materialization), ..

, .
,
,
. , " " "". .

1.

67


. ,

,
. , , ..
"" .
, .
.

, , .
,
, ..
.


(. ). ,
(, )
(, ).

, - , ,
. ( ).
- ( , , ).
, . ,
, . ,
. ,

68

I.

, ,
(, "" " "). .
( , ), . (, "" "").
.
, , ,
1.3. , ,
.

, SQL ( ).
. ( SQL ) ,
. , , 4. , .
. ,
SQL, , ,
, , .
1.6.
, SQL, SQL,
,
,
. , SQL 5. ,
30
( ) . , 1969 1970 , ,
. , , ,
,
, .
? , . ( !)
, .

4
,
.
5
, SQL, ,
.

1.

69

, , , .
( ).
(, ),
.
, ,
, , . , , .
, , , "relation" {), , .
, ,
. ( 3 6.) ,
, , , , "
" (relationship)
"-" (. 1.3). , .
, ,
. . 1.7 , . ,
. 1.7, , CELLAR (
CELLAR (. . 1.1), ,
). . 1.7, :
( ), ( ).
SQL.

. , . , , , ,
. . , (, IMS IBM)
(),
() ,
. , ,
, ( ,
, , ,
,
).
,
,
. , ()

70

I.

6: (inverted list), (hierarchic) (network). {.


,
.) , , , , .
[1.5].

. 1.7. ()
, CODASYL
DBTG (Data Base Task Group) CODASYL (Conference on Data Systems Language). ,
IDMS Computer Associates International, Inc.
( ), .
1970- 1980- . ( , SQL)
. ( ) : DB2
6
,
, (
). , , "" , , .. , "" " " (
) .
[1.1].

1.

71

( ) IBM; Ingres II Computer Associates


International, Inc.; Informix Dynamic Server Informix Software, Inc.7; Microsoft
SQL Server Microsoft; Oracle 8i Oracle Sybase Adaptive Server
Sybase, Inc.
. ,
( ) :
DB2, Ingres ( ""), Informix, SQL Server, Oracle Sybase.
- - : 1980-
1990- , - 1990- . -
, DB2 Informix. , GemStone
GemStone Systems, Inc. Versant ODBMS Versant Object
Technology. VI . ( , , ,
, VI. ,
, , .)
,
,
(multi-dimensional) (logic-based) , . 22,
24. , World Wide Web XML, , (
) . 27.
1.7.
, . . ( ), ,
( , ,
), ( ). , ,
,
, .
,
.

. .
( ),
, , ,
. "".
7

Informix Software, Inc. IBM 2001 .

72

I.

,
.
.
. ( , , , .)
, . , ( " "), , .
, . ,
,
( ), , .
, , ( ,
-, ). SQL ( , SELECT, INSERT, DELETE
UPDATE ). SQL ( ,
).

7.1.




""





()
()

1.
1.2.

73

?
?
1.3.
?
.
1.4.
?
. ?
1.5.
SQL
, . 11.
) SELECT WINE, PRODUCER
FROM CELLAR
WHERE BIN# = 72 ;
) SELECT WINE, PRODUCER
FROM CELLAR
WHERE YEAR > 2 000 ;
B) SELECT BIN#, WINE, YEAR
FROM CELLAR WHERE READY <
2003 ;
) SELECT WINE, BIN#, YEAR FROM
CELLAR WHERE PRODUCER = 'Robt.
Mondavi' AND BOTTLES > ;
1.6. . 1.5, .
1.7. SQL , . 11.
) INSERT
INTO CELLAR (BIN#, WINE, PRODUCER, YEAR, BOTTLES, READY )f?
VALUES (80, 'Syrah', 'Meridian', 1998, 12, 2003 );
) DELETE
FROM CELLAR
WHERE READY > 2004 ;
B) UPDATE CELLAR
SET BOTTLES = 5 WHERE
BIN# = 50 ;"
) UPDATE CELLAR
SET BOTTLES = BOTTLES + 2
WHERE BIN# = 50 ;
1.8. SQL
.
) ,
Geyser Peak.
) ,
.
) .
) 3 0.

74

1.9.

I.
) Chardonnay. %
) (12 ): Gary
Farrell, lot, 55, 2000,
2005 .
, , -, -, , , (, ), (, ),
(, ), (, ), (, - ),
(, )
(, ). ""
, . 1.5.


1.1.

1.2.

1.3.

1.4.

1.5.

Codd E.F. Data Models in Databases Management // Proc. Workshop on Data Abstrac
tion, Database and Conceptual Modelling. Pingree Park, Colo, June 1980.
ACM S1GART Newsletter. January 1981, 74; ACM
SIGMOD Record 11. February 1981, 2 .
,
[6.1].
; , . " ?", , ,

, - . ,
, .
Darwen H. What a Database Really Is: Predicates and Propositions // Date C.J., Darwen H.,
and McGoveran D. Relational Database Writings 19941997. Reading, Mass.:
Addison-Wesley, 1998.
, (
1.3), , .
Date C.J. and Hopewell P. Storage Structures and Physical Data Independence // Proc.
ACM SIGFIDET Workshop on Data Definition, Access, and Control. San Diego,
California. November 1971.
Date C.J. and Hopewell P. File Definition and Logical Data Independence // Proc.
ACM SIGFIDET Workshop on Data Definition, Access, and Control. San Diego,
California. November 1971.
[1.3], [1.4] , .
Date C.J. Relation Database Writtings 1991-1994. Reading, Mass.: Addison-Wesley, 1995.

2

2.1.
2.2.
2.3.
2.4.
2.5.
2.6.
2.7.
2.8.
2.9
2.10.
2.11
2.12.
2.13.




"/"

2.1.
, ,
. " ",
.
.
,

. , "" (. 1),
, .
,
( ). ,
,

76

I.

ANSI/SPARC (Study Group on Data Management Systems),


ANSI/SPARC [2.1], [2.2]. ANSI/SPARC .
,
, , .
, , "". ,
1, ,
, ,
, .
2.2.
ANSI/SPARC : , (. 2.1). .

. 2.1. ANSI/SPARC
( )
, ..
.
( )
, ..
.
(
, ) ""
.
,
.
1, ,
, ,
, , . , ,

2.

77

,
; ,
, ,
- .
, . 2.2.
,
( , PL/I, ,
COBOL)1. , , .

. 2.2.
.
1.
EMPLOYEE (). EMPLOYEE
EMPLOYEE_NUMBER ( ),
DEPARTMENT_NUMBER ( ) SALARY (
).
2. STORED_EMP,
20 . STORED_EMP
: (,
, ) ,
, . ,
STORED_EMP # , -

PL/I COBOL, ,
, .

78

I.
3. , PL/I,
.
PL/I, (
, ).
, PL/I.
4. , , COBOL,
,
COBOL, , , (
).
COBOL .

,
. , #
PL/I EMPNO COBOL.
EMPLOYEE_NUMBER,
#. ,
. , , EMPNO
COBOL EMPLOYEE_NUMBER, , , # . ,
(mapping), . 2.2 (
2.6).
,
- . ,
.
-,
,
,
( , 1).
-, , ,
. , PL/I
COBOL, . 2.2,
.
. , (
) , ,
, , .
3 () 10.
-, ,
() ; ,
,
( , , , ..).
. ,
1, ,
.

2.

79

, . . 2.3
. .

. 2.3.
2.3.
.
1, . (). ,
. .
.
(, PL/I, C++ Java), .

80

I.
( !) , ,
, PL/I, "",
, .
,
,
,

( 1).

, , ..
, . , , , () , ,
..
. , . SQL,
1.
SQL , ,
, PL/I Java (
4).
, ,
. , , .
, (
)2. , ,
. (
SQL, Oracle) ,
.
, , , , , .
,
(Data Definition Language
DDL),
, 3 (Data Manipulation Language DML),
. , PL/I (. . 2.2).
2

Tutorial D,
(.
).
3

"" ( ), ,
.

2.

81

PL/I, .

PL/I, .
DECLARE ( DCL), PL/I,
PL/I,
, PL/I.
PL/I,
; , ,
.
. , PL/I
.
( CALL), , ( ,
). SQL 4.
. ,
. ,
, ,
. ANSI/SPARC, . ,
,
(.. , ). , ,
, .
(
)4.
. ,
, . ( , , 1, .
.)
,
,
(. . 2.2).
4

,
. : ,
. .
. , , 14 ( " ") 25. . ( ).

82

I.

, .
(
.) , , ,
, .. ,
(
). 2.6.
2.4.

( )
. - . , , , ,
, ,
.

. , , ,
, ,
, ..
, , .
,

(. . 2.2).
. , - .
. ,
, , , -,
.
, , ( 2.6), .
,
.
, ,
COBOL ( - ).

, , , 1. ,

2.

83

, ,
, , ,
.. [2.3]. , ,
5. ,
. , "" .
2.5.
. , .
ANSI/SPARC , (
). , , , ,
, , . , .

. , ( )
, (
) () -. ,
1 , 64 (1 = 1024 ).
, , ,
, .. ( . 2.2; . .) .
.

( ) , .
,
, , (
2.11), , . , ,
(
5
, , ,
- (. 9 14).

84

I.

) ( ). .
(
).
2.6.
. 2.3 , , :
.
"-"
, .. ,
.
(..
) ""
, , . (

.) ,
,
.
""
. ,
, ,
.
, ,
,
() ..
,
,
.
, "" , ""
.
1, [1.3],

. ,
[1.4],
(
" " ). 3 10.
,
( ,
"-"),

2.

85

.
, . ,
.
2.7.
1, () ,
, , () , . ,
.
.

,
, .. , ,
,
. ( ) .
,
, .
()
, . (
) .
, . , .

, .
. ,
(.. ). ,
.
( )
, (
) . ,
.
, , ,
, .
.

86

I.


( ) . ( ,
.) , . , ,
, .

.
, ,
.

, . .

,
.
- ,

. , , , .
, -, ,
( ), -,
.
,
,
- , .
. ,
6 (.., , , ),

6
1024 - 1 (); 1024 = 1 (); 1024 = 1 ();
1024 = 1 (); 1024 = 1 (); 1024 = 1 ();
1024 = 1 (); 1024 = 1 (). ,
, gigabyte g ( "gigantic").

2.

87

. , (Very
Large DataBase VLDB) ,
( ). - , .

, 1, ,
,
, (.. ) . ,
, . ,
( ) ,
.
,
, .
2.8.
() , .
(. . 2.3).
1. ,
( SQL).
2. .
3. ( ) ,
"", ,
"" .
4. .
, . , .
, .
.
, ; ,
, (.. ,

88

I.

). , .

; , SQL (. [4.131 [4.271 4).
.
, 2.4

. 2.4.

2.

89


( , , , )
. , ( )
.
, , , , EMPLOYEE SALARY. ( " ,
50 . ".).

, , ,
. ,
,
().
, .
) ,
. , ,
,
.
) , ,
( ) ,
- .

, .
, 1 ( 1.3),
, , . , ,
, . ( 1 ,
, -
. . 2.4 .)

, ,
, ,
7.
7
"" ,
.

90

I.
18.
(run-time manager).
, , - . (
.)



, (.
). ,
.

, ,

.

IV. . 2.4,
.

. ( , ). " " ( ), ..
, . ,
(,
..) , .
, , , , .. ( ) , ,
. ,
, , , , , / .
3.
, ,
- . ,
(dictionary), (directory)
(catalog),
,
( ) . ( 14) .

2.

91


,
.
, , .
,
. ,
. , 10
, ( , SQL).
(
).
, .
, " ", . ( ,
, .) ,
, . , ,
.

, , ,
.
,
.


.
.
,
.
, "" "" ,
. ( .)
2.9.
.
( )
( ), . ,

92

I.

( ).
.
; . , , , ,
(DataBase/Data-Communications
DB/DC). ,
, (, , , ).

( ). 2.12
(.. ,
Internet), .
2.10. "/"
ANSI/SPARC . . 2.3.
.
, , .
,
( , ) ( , ), .
2.5.
1. . ,
2.8, : ,
, , .. ,
,
, 2.8.
.
2. , .
, ,
,
. ,
,
, ,
, ,
2.3. ( ""
. , 2.5,
.
,
. .)

2.

93

. 2.5. "/"
, , .

, . ,
,
, C++ COBOL,
,
- (. 2.3).

). ,
, .. ,
.
, .
,
, ,
. ,

,
, .
, , ,
, (
), .
, ,
.
) .
) .

94

I.
) -.
) .
) .
) .
) , )
( ).
) , CASE- (CASE,
Computer-Aided Software Engineering ) ..
) .
,
, ( ) .
, . , , .

.
( ), . , .
, - , .
,
( , ), "/"
,
.
, 2.12.
2.11.
, .
, , .
, - .
(.. ) .
, .

2.

95

,
.
,
,
. (,
.)
,
( ).
,
,
, .
,
,
, - ..
,
.
,
. ,
.
2.12.
2.10, ( Internet)
. ( ,
, , .)
, , (. 2.9),
.
. 2.10, , . 2.6, ,
, .
2.10, "/",
, , ,
, (. . 2.6). ,
.
.
, ( ) ()

96

I.
. ,
.
,
(" ").
.
,
,

,
.

. 2.6. ,



( ). , . 2.7.
, ()
.
(, ) , , ,
. ,
( ) ,

2.

97

. ,
, . ,
,
. , ,
, , . 2.8. ,
( , ).

. 2.7.
, ,
(, . 2.7). , ,
, ,
,
,
. .
,
(.. ). . ,

98

I.
,
.
(..
).
( ) ,
.

. 2.8. , ,

, . . , :
, , ,

2.

99

, .
, ,
, . , . . 21.
2.13.
. ANSI/SPARC,
: ,
(.. , ); , (.. ); , (
).
( ). , . , , .
, .. ,
, ,
: . . , , , , ,
, , . , .
. ,
( ). , ( ) .
,
.
.
, ( ) (). ,
.
, . (.. ,
,
),
.

100

I.

2.1.

,
( ANSI/SPARC).

2.2.

:


,
,
,
,
-


, ,



""
"
"

2.3.

,
.
2.4. , .
2.5. .
2.6. ?
2.7. , .
2.8. .
2.9. ,
.
2.10. .
2.11. .
ANSI/SPARC,
. ?
?
(, )?
? ?
? -
? ?

2.

101

? , , ? ?
? -
?

,
, , .
2.1.
2.2.

2.3.

ANSI/X3/SPARC Study Group on Data Base Management Systems. Interim Report //


FDT (ACM SIGMOD bulletin). - 1975. - 7, 2.
Tsichritzis D.C. and Klug A. (eds). The ANSI/X3/SPARC Framework: Report of the
Study Group on Data Base Management Systems // Information Systems. 1978. 3.
, [2.1] [2.2], , ANSI/X3/SPARC Study Group. ANSI/X3/SPARC
( Study Group on Data Base Management Systems) 1972 Standards Planning and Requirements Committee (SPARC)
American National Standards Institute on Computers and Information
Processing (ANSI/X3).
. 25 NCITS
(National Committee on Information Technology Standards ). , INCITS, IN, (INternational), N,
(National) NCITS.
, - ( , ), .
, , , , ,
. 42 (!) .
, ,
.
Van Griethuysen J.J. (ed.). Concepts and Terminology for the Conceptual Schema and the
Information Base // International Organization for Standardization (ISO) Technical Report
ISO/TR9007. -July 1987.
(International Standard Organization ISO),
" ". (, )
.
,

102

2.4.

2.5.

I.
. "", , . , ,
, . ,
, .
Kent W. Data and Reality. Amsterdam, Netherlands: North-Holland; New York, N.Y.:
Elsevier Science, 1978.
,
. " ,
, , , , , , " ( ).
, , - , , . .
Odysseas G. Tsatalos, Marvin H. Solomon, and Yannis E. Ioannidis. The GMAP:
A Versatile Tool for Phisical Data Independence. Proc. 20th Int. Conf. On Very Large
Data Bases. Santiago, Chile. September 1994.
GMAP (Generalized
Multi-Level Access Path). ,
"
, ",
.
"-" ( ), , .
, (.
7), , , , , . ,
( 21), , .

.
, , " , ".

3.1.
3.2.
3.3.
3.4.
3.5.
3.6.
3.7.
3.8.
3.9.
3.10.

3.1.
1,
. II
, .

, II (
),
.
.
3.2.
,
, ,
. , , ,
.

104 I.
. ,
( ).
.
( ).
.
(, ),
,
, (restrict), (project)
(join).
. 3.1 ( DEPT)
( ). , "
" (-, ). . 3.2
,
. ( !) .

. 3.1. (
)
(
,
). ,
; ,
SELECT SQL.

.

.
, . 3.2, , -,
. , ,
DEPT DEPT#, , .
DEPT , ,

3.

105

DEPT#. , (. 3.1) DEPT (


). ,
D1. . 3.2.
. , DEPT# , .
, DEPT# D3 (..
, D3),
D3, D3 DEPT .

. 3.2. ,
3.1. DEPT

3.2.

, . 3.2:
(
, " ", ). .
, , , , ,
. ,

106

I.

- . , ,
, .. ,
, .. , ,
. ,
, , .
, , , , , .
,
1. , ,
. ,
, , .
, . ,
, , , . ,
, .
. , ( ) (materialized evaluation);
, (pipelined evaluation).
, . 3.2, , ,
, .. , , . (, ,
, , .) ,
. 3.2 ,
, , .
, . ,
( 3.5).
. 3.1. ,
, .
-, , ,
. , .
,
( , , , , ..),
.
1

, 1, ;
.

3.

107

-:
, ( , ,
, ,
, ..) .
ANSI/SPARC , . , (
2) ,
,
. . , , ,
2. ,
: , .
-, ,
:
,
, .

(
, ). , ,
. , . 3.1
D1 DEPT 1 , ,
1 D1,
, D1 DEPT#
1 . ( IMS 1DMS),
, ,
( 1).
. , ,
26. ,
, ,
; , , ,
. , ,

.
, . .
, . 3.1.
2

, , SQL . , "" ( ,
). (
1) ,
( ).

108

I.

. , ,
25 95 . . , 1 15 .
. .. ,
. .
1. DEPT
DEPT#; ,
#. , DEPT# DEPT #
. (, 1
.)
2. DEPT#
DEPT# DEPT ,
. ,
DEPT# ,
DEPT.

, (
).
.
1. (, ,
).
2.
.
3.
.
4.
.
5. { )
.
, , " , ",
.
. , , , . ( ),
. , ( , ) ,
9.

3.

109

3.3.
,
, ( ),
: , ,
, ? ( 1): "relation"
() (, ;
6). , , , . 3.1, .

. , .
, , -
. .
, .
, , ,
(
).
1969 1970
.. (E.F. Codd), IBM.
1968 , , ,

.
.
"A Relational Model of Data for Large Shared Data Banks",
(. [6.1] 6).

, ,
,
.
, , , , . , ,
. ,
,
, . , .
,
, , ,
-. (tuple),
, . ( 6), , ( ,
). ,

110

I.

; ,
.
II
, , ,
. .
, . 3.1.
, DEPT , .. (..
). , ,
( ), . 3.1, ,
Saito ( 4).
DELETE WHERE # = # ('4') ;
. 3.3.

. 3.3. 4

: , .
, ( ) ( )
, . ,
,
,
.
:= WHERE NOT ( # = # ( ' 4 ' ) ) ;
, , ,
, ( , , ). ,
, , "" "".
. DELETE,
Tutorial D, .
, INSERT UPDATE
( 6).
: ,
( , , .. ). , ,

3.

111

. . [3.3], (relation variable) (


relvar), , ,
, 3. ,
( , , ,
),
,
.
, ,
(relvar) , ! , (..
) . ( ,
,
. ,
.) ,
, 6 9, ,
, , , .
3.4.
1 , .
3.2 , " []". , ,
( , ,
). , ( Tutorial D, "..."
, ).
TYPE EMP# ... ;
TYPE NAME ... ; TYPE
DEPT# . . . ; TYPE
MONEY ... ;
#, , ,
, NAME ..
. 3.4, . 3.1 , .
, , , , : "_:_" () ,
(). ,
"_" , . , .
3



. 5.

112

I.

. 3.4.
, ,
.
-, r r
(
, , ,
).
-, 1, r
,

(..
, . 3.4, .
# ENAME
DEPT# SALARY.
#, ENAME, DEPT# SALARY, ,
, . .
1 Lopez
D1 40 . . .
( # 1, NAME Lopez, DEPT# D1 SALARY 4 .)
2 Cheng
D1 42 . . .
( # 2, NAME
Cheng, DEPT# D1 SALARY
42.)
:
( ),

;
( ), ,

.

3.

113

( ,
. ,
.) , , , , , :
" ,
".
:
-, , (
,
);
-, , , ..,
, ,
;
-, .
, (, ,
!)
. 26 ( 26.2) .
, , ,
, , . DEPT . 3.1
. 3.2 , .
DEPT. " DEPT# DNAME BUDGET".
DEPT, BUDGET > 8. " DEPT#
DNAME BUDGET, 8 . .".
, DEPT# BUDGET DEPT. "
DEPT# BUDGET".
DEPT DEPT#. "
DEPT# DNAME BUDGET,
# ENAME DEPT#
SALARY" (, , ,
DEPT# ).
, , .
, ,
. ,
.
# ENAME,
DEPT# SALARY

114

I.

3.5.
3.2, , ,
, .
, , ,
. , , . ()
,
.
.
. . 3.5 SQL INSERT , "".
, , ( CODASYL;
[1.5]). ,
.
3.9.
, ,
, ,
. ,
( ) , . ,
, SQL, ,
, C++ COBOL (
, ; . . 3.5). ,

, .

( 2).
, , . , ,
( Tutorial D).
( EMP WHERE # = # ('4') ) { SALARY }
. (EMP WHERE ...) ,
,
, # 4. , SALARY, ,
SALARY.
, ,
4. ( ,
:
, .)

3.

115

. 3.5.

.
1. ( ) , .
2. # ( )
(, , ,
,
),
4.
,
.
, ,
:

116

I.
;
;
;
;
;
; ..

: , ,
,
( ).
, , , ,
.
18.
3.6.
2, ,
. , (,
, ) , ("", "-", "-"). ,
( ), ,
. ,
, , ..
. ,
, ,
, (. 18). , ( 17),
.
,
(, , , ).
, . , SQL
TABLES COLUMNS, (.. ) .
4 TABLES COLUMNS
, . 3.6.
4

, ROWCOUNT,
: INSERT DELETE
. ROWCOUNT
(, ),
.

3.

117

. 3.6. ( )
. 2, , ..
, (. . 3.3).
, , DEPT (,
, - ).
.
( COLUMNS WHERE TABNAME = 'DEPT' ) { COLNAME }
. ,
#.
( COLUMNS WHERE COLNAME = '#' ) { TABNAME }
. ?
( ( TABLES JOIN COLUMNS )
WHERE COLCOUNT < 5 ) { TABNAME, COLNAME }
3.7.

, ,
, DEPT , , , .
. () , .
, - , .

118

I.

. [3.3] .
, , ,
, . SQL, ,
CREATE TABLE ( TABLE
, ). ,
, , , , .
CREATE TABLE EMP ... ;
, .
( ,
). ,
. , .
CREATE VIEW AS
) { EMP#, ENAME, SALARY } ;

( EMP WHERE SALARY > 3 3K

. ,
SQL Tutorial D.
, AS
, ,
( ).
,
, ,
. 3.7 . , .

. 3.7. ( )

. , ,
, , , , , , (

DEPT

3.

119

). , [3.3]
.
: ,
, ,
, ,
. , ,
, , . , ,
. , (,
).
, , , , , ( ).
, T.
( WHERE SALARY < 42 ) { #, SALARY }
. 3.7,
, . 3.8.

. 3.8.
, , ,
,
(.. , ).

( WHERE SALARY < 42 ) { #, SALARY }


.
( ( ( WHERE SALARY > ) { #, ENAME,
SALARY } ) WHERE SALARY < 42 ) { #,
SALARY }

.
( 18) .
( WHERE SALARY > AND SALARY < 42 ) { #, SALARY }
, .
, ,

120

I.

(, ).
DELETE.
DELETE TOPEMP WHERE SALARY < 42K ;
.
DELETE EMP WHERE SALARY > AND SALARY < 42 ;
,
( ) . , ,
( ). ,
, .
CREATE VIEW JOINEX AS
( ( EMP JOIN DEPT ) WHERE BUDGET > 7M ) { EMP#, DEPT# } ;
10.
, 2.2 ,
, (view)
, ,
ANSI/SPARC. , ( ). , , , ,
. ANSI/SPARC ,
.
. ( ,
, ,
. 10.)
ANSI/SPARC
. ,
, , :
, ,
5.
.
- ,
. ,
( SQL). , ,
5

27.

3.

121

, , ,
.
. , -, SQL
SQL ( 4),
" " (..
, ).
( )
( ).
,
. .
" " ,
, .
, , " ",
"" .
, , . , ,
,
, , . (
""!) ,
, , (, ). 3.2,

, . , 6 .
. . , ,
, . , , -,
, , , -,
, , . , ( ), .
6

,
, , 3.3: " , , , ... [] ,
. ,
, , ." , , .

122

I.

3.8.
.
. , , II.
.
1 , ,
. ,
,
. BEGIN TRANSACTION, COMMIT
ROLLBACK. , BEGIN
TRANSACTION COMMIT ROLLBACK,
, .
BEGIN TRANSACTION ;
/*
*/
UPDATE account A ;
/* */
UPDATE account ;
/* */
IF < >
THEN COMMIT ;
/* */
ELSE ROLLBACK ;
/* */
END IF ;
.
1. , .. (
), , 7,
.
2. ,
COMMIT, TO
,
- .
. ,
{)
, 1.
3. .
, ,
77, 72
, 77 COMMIT.
COMMIT ,
, .
, , ,
. , , ROLLBACK,
7

, "
" ( - ,
" "). ,
, - , .

3.

123

,
, ( ).
, .
4. , , ,
(serializable). ,
, ( , )
.

15 16.
3.9.
,
. , . . 3.9 . (
)8. . 3.10 , Tutorial D ( VAR ).
, , , . STATUS CITY , , ,
INTEGER () CHAR ( ). ,
, , . 3.9,
, . 5, ,
" , _" 5.3.
, .
S (, ,
). (s#);
(SNAME), ( ,
, . 3.9); (STATUS);
(CITY). ,
.
(, ).
(#), ;
(PNAME); (COLOR); (WEIGHT); ,
(CITY). , ,
( , 5,
8

, , , . . 4.5 .

124

I.

5.4). ,
.

. 3.9. ( )

TYPE S# ... ;
TYPE NAME ... ;
TYPE P# ... ;
TYPE COLOR ... ;
TYPE WEIGHT ...
; TYPE QTY ... ;
VAR S BASE
RELATION { S#
S#,
SNAME NAME,
STATUS INTEGER,
CITY CHAR
PRIMARY KEY { S# } ;
VAR P BASE RELATION
{ P# P#,
COLOR COLOR,
WEIGHT
WEIGHT, CITY
CHAR }

PNAME NAME,

PRIMARY KEY

VAR SP BASE RELATION


{ S# S#,
P# P#,
QTY QTY }
PRIMARY KEY {
FOREIGN KEY {
FOREIGN KEY {

{ p# } ;

S#, P# }
S# } REFERENCES S
P# } REFERENCES P ;

. 3.10. ( )

3.

125

SP .
.
, SP . 3.9 S1 S ,
1 , .. 1 S1 (
300 ). ,
(S#), (#) (QTY). ,
,
s# # , SP. , . 3.9
( S5), .
( 1, 1.3), , . ,
. ,
, , ,
, , , .
.
-, ,
,
.
( ). ,

, , ( )
( )
.
-, , ,
, SUPPLIERS (
), PARTS () SHIPMENTS (),
S, SP. ,
.
,
.
.10.
. ,
, , ,
, , . ,
. .

126

I.

, (.. relvar),
, , .
, ,
, , RESTRICT ( ,
SELECT), PROJECT JOIN.
, 9,
. , , , ( ). , ,
. , INSERT, UPDATE DELETE
.
, ,
.
. ,
. , ( ) , (, , ..).
(, , ) , , ,
. , ,
, .
; "_:
_", , . ,
,
. , , , , . , ( -), , ( -),
. , ( ).
, , ( , , ).
, .
.
9

3.2. 6.

3.

127

.
,
, ( , , , ..).
, .
, . ,
, (
). ,
( ).
,
. , , ,
. ( :
, .) ,
( , ). , , .. .
,
.
BEGIN TRANSACTION COMMIT
( ) ROLLBACK ( ).
, .
, (
, ).
, . , . , ,
, , . (,
!)

3.1.

128
I.



3.2.
3.3.

3.4.
(

TABLE COLUMN
.
3.6, , .. . . 3.6 ,
TABLE
COLUMN.
.
? ?
( S JOIN SP ) WHERE # = #

3.5.

21)

{ S#, CITY }

, ,
.
CREATE VIEW V AS
( ( S JOIN SP ) WHERE P# = P# ('P2') ) { S#, CITY } ;

3.4,

.
( V WHERE CITY = 'London'

3.6.

3.7.
3.8.

{ S# }

?
? , .
, : , ,
.
.
,
,
.


3.1. Codd E.F. Relational Database: A Practical Foundation for Productivity // CACM.
February 1982. 25, 2. (: Robert L. Ashenhurst (ed.). ACM Turing
Award Lectures: The First Twenty Years 19661985. Reading, Mass.: Addison-Wesley,
ACM Press Anthology Series. 1987.)
ACM Turing
Award 1981 . . ,

3.

129

: "
, (
) ".
.
1.
.
2.
,
.
,
,
.
3.2. Date C.J. Why Relational? // C.J. Date. Relational Database Writings 1985-1989.
Reading, Mass.: Addison-Wesley, 1990.
, .
: "
, : ".
:"... . ,
. , ,
;
, ,
... , [] ,
". "
(, )
, ,
. (
). ,
, , , ,
".
3.3. Date C.J., Darwen H. Foundation for Object/Relational Databases: The Third
Manifesto (2d edition). Reading, Mass.: Addison-Wesley, 2000. .
http: //www.thethirdmanifesto.com,
,
. , [20.1 ].
,
. .
, , .
, INTEGER; 3
; N , (.. );
"+" , (..

130

I.
). , . : "
, ".
, . ,
- ( );
, ;
, , () .
(relation variable, relvar) .
, " " :
"
,
. ,
dbvar database variable ( ).
, , ,
,
. ,
,
". , ... [23.4]: " ,
(database value)
(database variable, dbvar), , ". , ()
.
. " " : " [],
,
, .
Chambers Twentieth Century Dictionary,
,
( ). ,
... , ,
".
: " " [20.2], [25.1] "
" [26.44],
.

3.4. . J. Date: "Great News, The Relational Model Is Very Much Alive!", http://
www. dbdebunk. com (August 2000).
1969 , .

3.

3.5.

131

: "Great News, The Relational Model Is Dead!" (


- !).
.
. J. Date: "There's Only One Relational Model!", http://www.dbdebunk.com
(February 2001).
Co 1969

.
, "
", : "
, ( ?!),
".
.

4
SQL
4.1.

4.2.
4.3.
4.4.
4.5.
4.6.
4.7.
4.8.

SQL

SQL
SQL


4.1.
1, SQL

, .
IBM Research 1970- [4.9], [4.10].
- System R
IBM [4.1][4.3], [4.12][4.14];
IBM [4.8], [4.14], [4.21],
. SQL,
, , ,
.., ,
. SQL, 1,
(.. SQL:1999). [4.23]
SQL: 1999; [4.24]
.
. SQL: 1992, SQL:
1999

1
("SQL:2003"),
2002 2004 ,
.

134

I.

. ,
SQL: 1992;
, , ,
" " ( SQL: 1999, , , SQL: 1992). , ,
, , 2. , DB2 IBM
, , .
.
SQL (.
2). 1996 ,
SQL (SQL Persistent Stored Modules SQL/PSM,
PSM), SQL
( ,
CALL , RETURN , SET , CASE , IF , LOOP , LEAVE , WHILE , REPEAT ,
, ,
).
PSM ,
[4.20].
SQL
, .
SQL
,
( , SQL).
, SQL .
[4.23] 2000 , 300
[4.24]. , ,
.
.
, ( 13),
SQL .
, , .
, ,
, ,
, ,
, .

2
, -,
, , ( [4.23] [4.24]). [4.20].

4. SQL

135

4.2. SQL
SQL , .
. . 4.1 ,
SQL (.
. 3.09 3). , CREATE
TYPE (User-Defined Type
UDT) CREATE TABLE (
3, TABLE CREATE TABLE
). CREATE TABLE , , , ( ,
, . 4.1).
.
CREATE
CREATE
CREATE
CREATE
CREATE
CREATE

TYPE
TYPE
TYPE
TYPE
TYPE
TYPE

S# ... ;
NAME ... ;
P# ... ;
COLOR ... ;
WEIGHT ... ;
QTY ... ;

CREATE TABLE S
( S# S#,
SNAME NAME, STATUS
INTEGER, CITY
CHAR(15), PRIMARY
KEY ( S# ) ) ;
CREATE TABLE P
( P# P#,
PNAME NAME, COLOR
COLOR, WEIGHT
WEIGHT, CITY CHAR(15)
, PRIMARY KEY { P# )
) ;
CREATE TABLE SP
( S# S#, : :
P# P#, '
QTY QTY,
PRIMARY KEY ( S#, P# ), FOREIGN
KEY ( S# ) REFERENCES S, FOREIGN
KEY ( P# ) REFERENCES P ) ;
. 4.1. SQL
, "#", , , ,
SQL.

136

I.

";",
SQL,
. .
CHAR SQL
( . 4.1 15).
, , SQL: SELECT, INSERT,
UPDATE DELETE. , , ,
SQL SELECT.
. 4.2.
. ,
SQL ( s. S#, SP. S#), . ( ), ,
, .

. 4.2. ,
SQL
, SQL
SELECT, .

4. SQL
SELECT *;
FROM

137

/* SELECT S.* (.. "*"


*/
/* ) */

S.
"*"_ ,
( 4.6). -, ,
, FROM, ,
. ,
, FROM, ,
( .., , FROM).
. SQL, SELECT * FROM ,
, TABLE .
SELECT 8 ( 8.6).
. INSERT, UPDATE DELETE
SQL 1. . , INSERT,
UPDATE DELETE, SELECT,
( 1 ). .
INSERT
INTO
TEMP ( #, WEIGTH )
SELECT P#, WEIGTH
FROM
P
WHERE COLOR = COLOR('Red') ;
, TEMP
, # WEIGTH. INSERT ' Red' ().
DELETE FROM
SP WHERE P#
=
DELETE SP
' 2 '.
UPDATE S
SET
STATUS = 2 * STATUS ,
CITY = 'Rome'
WHERE CITY = 'Paris' ;
UPDATE , .

138

I.

. SQL . , , INSERT ... SELECT ... ( ,


).
4.3.
SQL , . SQL, , SQL.
, SQL ()
3, ,
. ,
( ),
.
INFORMATION_SCHEMA ( ),
( ), .
, SQL, ( )
. ,
": ". , , -, " ", , -,
" ", , .
.
1. , ,
, , ,
, " ".
(
).
,
" ".
2. , " ",
" ", , ,
. ,
,
. , ,
, .

3
, , SQL ,
" ", ! ,
. , .

4. SQL

139

.
, . , TABLES
, ,
, VIEWS
.
ASSERTIONS. .
CHECK_CONSTRAINTS. .
COLUMN_PRIVILEGES. .
COLUMN__UDT_USAGE.
.
COLUMNS. .
CONSTRAINT_COLUMN_USAGE. .
CONSTRAINT_TABLE_USAGE. .
KEY_COLUMN_USAGE. .
REFERENTIAL_CONSTRAINTS. .
SCHEMATA. .
TABLE_CONSTRAINTS. .
TABLE_ PRIVILEGES . .
TABLES. .
UDT_PRIVILEGES. ,
.
USAGE_PRIVILEGES. .
USER_DEFINED_TYPES. , .
VIEW_COLUMN_USAGE. .
VIEW_TABLE_USAGE. .
VIEWS. .
[4.20] , ,
(
, ).
4.4.
SQL.
CREATE VIEW GOOD_SUPPLIER
AS SELECT S#, STATUS,
CITY FROM S WHERE
STATUS > 15 ;

140
I.
SQL .
SELECT S#, STATUS
FROM GOOD_SUPPLIER
WHERE CITY = 'London'
, , ( FROM).
GOOD_SUPPLIER. S# , GOOD_SUPPLIER
STATUS FROM ( SELECT S#, STATUS,
CITY
FROM
S
WHERE
STATUS > 15 ) AS
GOOD_SUPPLIER WHERE GOOD_SUPPLIER.CITY =
'London' ;
, , .
SELECT
FROM
WHERE
AND
'Lond'

S#, STATUS
S
STATUS > 15
CITY =

, .
.
DELETE
FROM
GOOD_SUPPLIER
WHERE CITY = 'London' ;
, , .
DELETE
FROM
S
WHERE STATUS > 15
AND
CITY = 'London' ;

4.5.
SQL BEGIN TRANSACTION, COMMIT
(. 3), , , START TRANSACTION, COMMIT WORK
ROLLBACK WORK ( WORK ).
ROLLBACK

4.6. SQL
SQL SQL
(.. , ), (..
SQL , ,
). , SQL,
; SQL Ada, , COBOL, Fortran, Java, M
( MUMPS), Pascal PL/I.
SQL .

4. SQL

141

,
SQL, . ,
SQL, ,
. , SQL . , ( ). ,
. (, , , ..
SQL, ,
.)
SQL,
. , . 4.3. ( ,
PL/I.
.)
.
1. SQL EXEC SQL,
,
( PL/I "; ").
2. SQL (
) ,
.
:
SQL, SQL
SQL, ,
. , DECLARE CURSOR
( ",
"); BEGIN END DECLARE SECTION
(. . 5 ), WHENEVER (. . 9).
EXEC SQL BEGIN DECLARE SECTION ;
DCL SQLSTATE CHAR(5) ; DCL P#
CHAR(6) ; DCL WEIGHT FIXED
DECIMAL(5,1) ;
EXEC SQL END DECLARE SECTION ;
P# = ' P2 ' ;
/*
*/ EXEC SQL SELECT P.WEIGHT
INTO :WEIGHT
FROM P
WHERE P.P# = P# ( :P# ) ; IF SQLSTATE = '00000' THEN ...
;
/* WEIGHT - , */
ELSE ... ;
/* */
. 4.3. PL/I SQL

142

I.

3. SQL (..
). ,
SQL.
SQL ,
SQL . INTO SELECT (. . 4) FETCH (
", "),
.
4. INTO SELECT,
. 4.3. ( )
() ,
. /- , INTO,
/- , SELECT.
5. , SQL,
SQL,
BEGIN DECLARE SECTION END DECLARE
SECTION
( PL/I DCL).
6. , SQL,
SQLSTATE.
SQL .
, 00000 , ,
02000 ,
( [4.23]).
, SQL
SQLSTATE ,
, .
, , (. . 9).
7. ,
, . ,
, (,
SELECT), ,
, .
, (,
INSERT ), , SQL
, .
,
, ( ,
), 5, 5.7.
8. SQL ,
.
9. , SQL, ,
, SQLSTATE.
WHENEVER,
.

4. SQL

143

EXEC SQL WHENEVER <condition> <action> }',


<condi tion> () NOT FOUND
( ), SQLWARNING ( SQL)
SQLEXCEPTION ( SQL) ( SQLSTATE
), <action> CONTINUE (), GO TO ( ). WHENEVER
; SQL.
"WHENEVER <condition> GO TO <label>" ,
"IF <condition> GO TO <label> END IF"
SQL. , "WHENEVER <condition> CONTINUE", SQL
, ,
. NOT FOUND, SQLWARNING
SQLEXCEPTION , .
NOT FOUND , , ;
SQLSTATE = 02;
SQLWARNING , ;
SQLSTATE = Olxxx;
SQLEXCEPTION , (
); SQLSTATE [4.23].
WHENEVER ( ), , ( ).
10. 2, , SQL SQL .
, .
.
,
(.. ). . , , ,
.
, "" SQL , ,
,
. "" . , ,
. (
", ") ,
.

144

I.

,
,
.
SELECT.
INSERT.
UPDATE ( CURRENT . ).
DELETE ( CURRENT . ).
.
SELECT. , GlVENS#.
EXEC SQL SELECT STATUS, CITY
INTO :RANK, :TOWN FROM S
WHERE S# = S# ( :GIVENS# )
;
SELECT
SELECT, , .
, S , WHERE, STATUS
CITY RANK CITY, SQLSTATE 00000.
S , WHERE,
SQLSTATE 02000.
, SQLSTATE
.
INSERT. ( ,
#, PNAME, PWT, ; ).
EXEC SQL INSERT
INTO P ( P#, PNAME, WEIGHT )
VALUES ( :P#, :PNAME, :PWT )
;
COLOR CITY , . 6.6 6. , , , ,
, ,
(NULL). ( , , 19;
.)
DELETE. , CITY.

4. SQL

145

EXEC SQL DELETE


FROM SP
WHERE :CITY =
( SELECT CITY FROM
S
WHERE S.S# = SP.S#
) ;
, , WHERE, SQLSTATE
02000. ( WHERE).
UPDATE. ,
RAISE.
EXEC SQL UPDATE S
SET
STATUS = STATUS +
:RAISE WHERE CITY = 'London1
;
,
WHERE, SQLSTATE 02000.
,
, .. , SELECT,
. ,
,
. . 4.4 ( s#, SNAME STATUS)
, .
EXEC SQL DECLARE
SELECT
WHERE
ORDER

X CURSOR FOR
/*
S.S#, S.SNAME, S.STATUS FROM
S
S.CITY = :Y
BY Si ASC ;

*/

EXEC SQL OPEN X ;


/*
*/
DO < S, > ;
EXEC SQL FETCH X INTO :S#, :SNAME, :STATUS ;
/*

*/
END ;
EXEC SQL CLOSE X ;

/* X

*/

. 4.4.
. DECLARE X CURSOR. . . ,
(.. , ).
SELECT,

146

I.

DECLARE, ,
DECLARE CURSOR .
( OPEN X).
, , FETCH X INTO. . .,
INTO. ( , . ,
SELECT
INTO.) , FETCH .
, .
( CLOSE X).
. DECLARE CURSOR, .
EXEC SQL DECLARE <cursor name> CURSOR
FOR <table exp> [ <ordering> ] ;
. <cursor name> . <ordering> .
ORDER BY <order item commalist>
<order item commalist> <order i tem>,
. < order i tem>,
(, )4, ASC ( ) DESC
( ).
(ASC). ORDER BY , . (, ,
ORDER BY, ,
< order item commalist>.)
. (commalist). <xyz>
(.. , BNF). <xyz commalist> ( < xyz>) <xyz>, <xyz>
4

, , <table exp>
.
SQL: 1999, , <order item>
, , ORDER BY A+B, ,
, , SELECT CITY FROM S ORDER BY STATUS.
.

4. SQL

147

( ).
, ,
( ,
SQL).
, DECLARE CURSOR , . , . .
DECLARE CURSOR,
, , .
: OPEN, FETCH
CLOSE.
OPEN .
EXEC SQL OPEN <cursor name>;
(
). (
, , ). ,
. ,
. , (.
ORDER BY), , 5.
FETCH .
EXEC SQL FETCH <cursor name>
INTO <host variable reference commalist> ;
<host variable reference commalist>
.
( )

, INTO.
FETCH
,
SQLSTATE 02 000.
CLOSE .
EXEC SQL CLOSE <cursor name> ;

, , ( 6), " "


.
().

148

I.
() (
).
. ;
, ,
( ,
). , .

, ,
UPDATE DELETE CURRENT. (,
) ,
" ", .. , , , .
EXEC SQL UPDATE S
SET STATUS = STATUS +
:RAISE WHERE CURRENT OF X
;
CURRENT DELETE UPDATE , < table exp> , CREATE VIEW (
10, 10.6).
SQL SQL/CLI
, ( SQL )
"" (.. ) ,
. . , . (, , 1, ,
.) , , .
1.
2.
3.
4.

.
.
SQL .
() .

,
1, (, ,
), SQL .
, SQL. , ,

4. SQL

149

SQL, .
, , SQL , .
SQL, , .
SQL
SQL
SQL. ( ), ,
SQL, . , SQL PREPARE ( , ) EXECUTE
(). ( , ) PL/I.
DCL SQLSOURCE CHAR VARYING (65000) ;
SQLSOURCE = 'DELETE FROM SP WHERE QTY < QTY ( 3 00
)' ; EXEC SQL PREPARE SQLPREPPED FROM :SQLSOURCE ;
EXEC SQL EXECUTE SQLPREPPED ;

1. SQLSOURCE PL/I
,
(..
) SQL,
DELETE.
2. SQLPREPPED, , SQL,
PL/I, ( )
SQL (
SQLSOURCE). , , SQLSOURCE SQLPREPPED,
.
3. SQLSOURCE =...; PL/I
SQLSOURCE SQL DELETE. ,

, ,
,
, "" , SQL.
4. PREPARE (..
) , ,
SQLPREPPED.
5. EXECUTE
SQLPREPPED,
DELETE. SQLSTATE DELETE
, , .

150

I.

, SQLPREPPED SQL, a
PL/I, PREPARE EXECUTE
. , SQL .
, ,
, SQL .
SQL. , ,
, ( !) SQL. SQL,
,

SQL.
, SQL
PREPARE EXECUTE; ,

; , ,
. , EXECUTE IMMEDIATE,
PREPARE EXECUTE .
SQL/CLI
SQL (SQL Call-Level Interface SQL/CLI,
CLI) SQL 1995 . CLI
ODBC (Open Database Connectivity) Microsoft.
, , , , LI, , SQL.
,
, SQL . ( , CLI .)
, SQL/CLI ( ODBC) , SQL,
SQL , . CLI ODBC
, SQL.
.
-, SQL , SQL. ,
SQL, - SQL,
, PREPARE, EXECUTE
.. CLI, , (.. ).

4. SQL

151

; . ( ) "" ,
.
-, , .. SQL/CLI (
, , ),
,
- .
SQL/CLI
SQL, .
char sqlsource [65000] ;
strcpy ( sqlsource,
"DELETE FROM SP WHERE QTY < QTY ( 300 )" ) ;
rc = SQLExecDirect ( hstmt, (SQLCHAR *)sqlsource,
SQL_NTS ) ;

1. SQL/CLI ,
PL/I . ,
SQL/CLI , ..
( ),
, ( ,

). , SQL/CLI
,
( , , )
.
2. strcpy
DELETE SQL sqlsource .
3. ("=") SQLExecDirect
SQL/CLI ( EXECUTE IMMEDIATE SQL)
SQL, sqlsource,
,
.
, SQL/CLI
SQL,
.
. , , CLI, ODBC JDBC
( ODBC Java), , 21, 21.6.

152

I.

4.7. SQL
4.1 , SQL "" , ,
.
. ,
, SQL, , . , SQL . , , ,
6. ,
- ,
; , . ,
. , , " ". ,
, . ,
, . , , ""
,
.
4.8.
, SQL. ,
SQL , , ,
.
SQL : (Data Definition
Language DDL) (Data Manipulation Language
DML). (
), (
). , (), ( ), (
) (
). , SQL
, .. ,
DDL, DML. GRANT,
( 17).
, SQL
CREATE TABLE ( ,
CREATE TYPE).
6

. [20.1].

4. SQL

153

SELECT, INSERT, DELETE

UPDATE , , ,
SELECT , . ,
" ", SQL .
SQL.
, SQL, , .. ,
( ) SQL, , .
, ,
SQL
, , , PL/I.
, SQLSTATE , SELECT INSERT, DELETE UPDATE, .
, , DECLARE CURSOR, OPEN, FETCH, CLOSE, DELETE UPDATE CURRENT. ( SQL
CURRENT , ,
UPDATE DELETE, , CURRENT.) , SQL, PREPARE EXECUTE,
( ODBC JDBC) SQL (SQL CallLevel Interface SQL/CLI).

4.1. . 4.5
, ,
1. (S), () (J) , , (s#), (#) (J#). SPJ () :
S# # J# QTY (
{S#, #, J#} ). SQL .
. .
4.2. 4.2 CREATE TABLE , SQL. , ,
7

. 4.5 . 154 ( . 3.8 . 119).

154

I.
,
. ,
SQL. ? ,
CREATE TABLE -

4.3.

, SQL.
? ,
?

4.4.

SQL
, .
) S10 S;
Smith, New York, .
) , .
) (red) (orange).

. 4.5. , (
)
4.1. , ,
SQL
.

4. SQL

155

, , .
4.2. PART PART_STRUCTURE, .
CREATE TABLE PART
( # #, DESCRIPTION CHAR(1OO),
PRIMARY KEY ( P# ) )
; CREATE TABLE
PART_STRUCTURE
( MAJOR_P# P#, MINOR_P# P#, QTY QTY,
PRIMARY KEY ( MAJOR_P#, MINOR_P# ),
FOREIGN KEY ( MAJOR_P# ) REFERENCES
PART, FOREIGN KEY ( MINOR_P# )
REFERENCES PART ) ;
PART_STRUCTURE , (MAJOR_P#)
(MINOR_P#) .
SQL
( ). . ,
. 4.6,
. ,
PART_STRUCTURE , (.
1, 1.3, " ")
.

. 4.6. PART_STRUCTURE ( )

[3.3] ( )
SQL: 1999 . .
.
4.1.

4.2.

Astrahan M.M., Lorie R.A. SEQUEL-XRM: A Relational System // Proc. ACM Pacific
Regional Conference. San Francisco, Calif., April 1975.
SEQUEL
SQL [4.9]. . [4.2] [4.3], System R.
Astrahan M.M. et al. System R: Relational Approach to Database Management // ACM
TODS. - June 1976. - 1, 2.

156

4.3.

4.4.

4.5.

4.6.

4.7.

I.
System R (
SEQUEL/2, . [4.10]) SQL. System R
, ; . [4.3].
Blasgen M.W. et al. System R: An Architectural Overview // IBM Sys. J. February
1981. - 20, 1.
System R ,
(. [4.2]).
Celko J. SQL for Smarties: Advanced SQL Programming. San Francisco, Calif.: Morgan
Kaufmann, 1995.
" SQL
, , , SQL " ( ).
Chaudhuri S., Weikum G. Rethinking Database System Architecture: Towards a SelfTuning RISC-Style Database System // Proc. 26th Int. Conf. on Very Large Data Bases,
Cairo, Egypt. September 2000.
SQL.
: "SQL .
, ,
SQL. ,
( ,
, )
. ,
, ,
, , ,
. SQL: 1992,
SQL: 1999, ( ) ,
, ,
(Abstract Data Type ADT) .. .
SQL ,
.
SQL, SQL.
".
Eisenberg A., Melton J. SQL: 1999, Formerly Known as SQL3 // ACM SIGMOD
Record. March 1999. 28, 4.
,
SQL SQL: 1999.
Eisenberg A. and Melton J. SQLJ Part 0, Now Known as SQL/OLB (Object Language
Bindings) //ACM SIGMOD. December 1998. 27, 4; Eisenberg A. and Melton
J. SQLJ Part 1: SQL Routines Using the Java Programming Language // ACM

4. SQL

157

SIGMOD. December 1999. 28, 4. . Gray Clossman et al. Java and


Relational Databases: SQLJ // Proc. 1998 ACM SIGMOD Int. Conf. on Management of
Data, Seattle, Wash. June 1998.
SQLJ , SQL Java (
SQL).
0 SQL Java, 1 Java SQL (, , Java,
. 21); 2
Java SQL (,
SQL). 0 SQL: 1999,
1 2
SQL:2003 (. [4.23]).
4.8. Chamberlin D. Using the New DB2. San Francisco, Calif.: Morgan Kaufmann, 1996.
SQL,
SQL [4.9][4.11].
. "
", SQL ( , ).
, : " ...
, ,
; , , , ...;.
[ SQL] , ,
[]".
, !

, ;
19 6, . " ", .
( 4.8), , , , ,
.
4.9. Chamberlin D.D. and Boyce R.F. SEQUEL: A Structured English Query Language //
Proc. ACM SIGMOD Workshop on Data Description, Access, and Control. Ann
Arbor, Mich. May 1974.
SQL ( SEQUEL, ;
).
4.10. Chamberlin D.D. et al. SEQUEL/2: A Unified Approach to Data Definition, Manipulation, and Control // IBM J. R&D. November 1976. 20, 6; . . // IBM J. R&D. January 1977. 21, 1.

158

I.

SEQUEL, [4.1],

, SEQUEL/2. , System R
[4.2], [4.3], SEQUEL/2 ( ;
9), ,
[4.11].
4.11. Chamberlin D.D. A Summary of User Experience with the SQL Data Sublanguage //
Proc. Int. Conf. on Database. Aberdeen, Scotland, July 1980. (. IBM
Research Report RJ2767. April 1980.)
System R SQL .
EXISTS, LIKE, PREPARE EXECUTE
System R.
8.6 (EXISTS), (LIKE) 4.7 (PREPARE
EXECUTE).
4.12. Chamberlin D.D. et al. Support for Repetitive Transactions and Ad Hoc Queries in
System R//ACM TODS. - March 1981. - 6, 1.

System R ,
. { ,
. , 2.8 2.) , , ,
, System R, , ,
, .
, , (
), " ". , ,
.
4.13. Chamberlin D.D. et al. A History and Evaluation of System R // CACM. October
1981. -24, 10.
System R (
, );
,
System R. ,
[4.14].
4.14. Chamberlin D.D., Gilbert A.M., Yost R.A. A History of System R and SQL/Data System //
Proc. 7th Int. Conf. on Very Large Data Bases. Cannes, France. September 1981.

4. SQL

4.15.

4.16.

4.17.

4.18.

4.19.

159

,
System R,
DB2 IBM, SQL/DS ( "DB2 for VM and VSE").
Date C.J. A Critique of the SQL Database Language // ACM SIGMOD Record.
November 1984. 14, 3. (: C.J. Date. Relational Database: Selected
Writings. Reading, Mass.: Addison-Wesley, 1986.)
, SQL .
(
, ).
.
SQL: 1999.
Date C.J. What's Wrong with SQL? // Date C.J. Relational Database Writings 19851989. Reading, Mass.: Addison-Wesley, 1990.
SQL
[4.15] " SQL", " SQL" " ".
.
SQL: 1999.
Date C.J. SQL Dos and Don'ts // Date C.J. Relational Database Writings 1985-1989.
Reading, Mass.: Addison-Wesley, 1990.

SQL, ,
, [4.15], [4.16], [4.16],
, , ..
Date C.J. How We Missed the Relational Boat // Date C.J. Relational Database Writings
1991-1994. Reading, Mass.: Addison-Wesley, 1995.
SQL,
( ) : , .
Date C.J. Grievous Bodily Harm ( ) // DBP&D. May 1998. 11, 5
DBP&D. June 1998. 11, 6. . Fifty Ways to Query // Web- DBP&D
www. dbpd. com. July 1998.
SQL , ,
. ;
SQL. , GROUP BY, HAVING , (
"IN <subquery>").
. 8, 8.6.

160

I.

4.20. Date C.J., Darwen H. A Guide to the SQL Standard (4th edition). Reading, Mass.:
Addison-Wesley, 1997.
SQL (, 1992 ),
SQL/CLI ( 1995 ), SQL/PSM (
1996 ) SQL: 1999. ,
D " ,
". , ,
SQL: 1999.
4.21. Date C.J. and Colin J.W. A Guide to DB2 (4th edition). Reading, Mass.: Addison-Wesley,
1993.
DB2 IBM ( 1993 ) . DB2
System R, , SQL/DS [4.14].
4.22. Fishman N. SQL du Jour. // DBP&D. - October 1997. - 10, 10.
, SQL, " SQL".
4.23. International Organization for Standardization (ISO): Information Technology
Database Languages SQL, Document ISO/IEC 9075:1999. : .
[22.21].
ISO/ANSI SQL: 1999 (
ISO/IEC9075 ISO 9075). , , ,
(ISO/IEC 9075-1, 9075-2 ..). .

1. (SQL/Framework).
2. (SQL/Foundation).
3. (SQL/CLI).
4. (SQL/PSM).
5. (SQL/Bindings).
6. .
7. .
8. .
9. (SQL/MED).
10. (SQL/OLB).

,
2003 , .

4. SQL

4.24.

4.25.

4.26.

4.27.

161

5 2, 5 .
2,
(" "), 11,
": SQL".
13, " Java (SQL/JRT)",

Java SQL (. [4.7]).
14, ", XML (SQL/XML)",
, SQL XML
(. 27).
. , SQL
"" , ; relation
()! ( , ,
.)
International Organization for Standardization (ISO) : (ISO Working Draft) Database
Language SQL Technical Corrigendum 5, Document ISO/IEC JTC1/SC32/WG3
(December 2, 2001).
[4.22].
Raymond A.L. and Daudenarde J.J. SQL and its Applications. Englewood Cliffs, N.J.:
Prentice-Hall, 1991.
SQL, ( -.
).
Raymond A.L. and Nilsson J.F. An Access Specification Language for Relational Data
Base System // IBM J.R&D. - May 1979. - 23, 3.
, System R [4.12], [4.27]. SQL ASL (Access
Specification Language ).
. ( , , ASL
.) ASL scan () insert
(), , .
, .
.
Raymond A.L. and Bratford W.W. Compilation of High-Level Data Language. IBM
Research Report RJ2598. August 1979.
System R
,
- .

162

I.

, (
[18.33]).
4.28. Melton J., Simon A.R.: SQL: 1999 Understanding Relational Components. San
Francisco, Calif.: Morgan Kaufmann, 2002.
SQL: 1999 ( , [26.32]). [14.28] (Melton)
SQL.
4.29. Rozenshtein D., Abramovich A., Birger E. Optimizing Transact-SQL: Advanced Prog
ramming Techniques. Fremont, Calif.: SQL Forum Press, 1995.
Transact-SQL SQL,
, Sybase SQL Server.
Transact-SQL, ( ", ...
SELECT, WHERE, GROUP BY SET").
Transact-SQL,
.
. , "optimizing", , . , ,
.


,
;
. , ,
,
, .
,
,
. ,
"", , ,
.
3,
: ,
.
.
5 6 ( 5 ,
6
).
7 8 ( 7

, 8 ).
9 .
, 10 , .
. ,
, ,
,
. , ,
,
( ) -
, .
, 510 .

164

II.

,
1. , , , ( ,
[3.3]). , ( ), , , , , ,
.
, , ,
, ( , 3.3)
. , . , ,
. ( , , ,
.) ,
, ;
, , .
, (
).
!
. ,
,
. ,
. ,
,
. , ,
.
, SQL. I , SQL

, (,
. [4.22]).
SQL.
, ,
SQL, ,
( 4,
SQL).
1

(
, ); , .

5.1.
5.2.
5.3.
5.4.
5.5.
5.6.
5.7.
5.8.


SQL

5.1.
.
.
, ,
20 V 25-27
VI.
( ) ;
, , , ,
,
. ?
, .
INTEGER ( ), CHAR (
), s# ( ) .. ,
, , s
STATUS INTEGER, ,

.
. .

166

II.

, ,
;
,
.
:
. , ,
INTEGER ,
, ,
(,
, , ). ,
, ; , .
(.. ),
. , ,
, INTEGER CHAR , a s# . ( , , , . 5.2) , , .
,
; ,
,
( " "
, ,
). , INTEGER
.
,"=", "<" ..

,"+", "*" ..

" | | " (), SUBSTR ( ) ..
( , ).
, , , s#, "=", "<" .. , "+", "*" .., ,
, ,
( ,
?).
,
, [3.3].

5.

167

5.2.
, ,
1 ( ,
). , [5.1], .
" ", ,
, 3.
.

{appearances; )
. ,

,
. , ,
, . ,
, ,
,
.
,
. , ,
. , ,
, , ; ,
,
. (,
.)
,
, 3. ,
; , ,
, , XML, , , , , ( .. ..). , ,
.
, , ,
, ( , ), .
, . , , ( ) ; ,
. , 3 (" " 3
), . ,
1

[3.3].

168

II.


() , .
,
, , , , .
, ,
"
" "
" ( ) "",
. , " " ,
" , "
, . , , , ,
(.. ,
" "); ,
.

( , ). , v
, v , , : " ",
" ", " " ( ..). ,
2,
. , ; , - .
, .

; ,
.;
(. 6),
; ,

.
(. 5.5), ,
; ,
,
, .
(. 5.5)
; ,
,
2
, ;
20.

5.

169

, . ( . , , ; ,
, ,
. ,
, , , , .)
,
. ,
, , " " , .
, * ( + )
"*" ().
, , , , .
, , , ,
.
"=".
v1 v2 ( , vl v2
), "="
, , .
": =" ( )
v V, , v V
. (,
, ,
9, - , 3.)
20 .
5.3.
,
, ,
, . ,
3 , - ,
. ,
( "" ); ,
, .

170

II.

. , ,
, ,
; , ,
, .
, , , ,
, ; , . , , , (. 1).
, , ( ) ,
ADT (Abstract Data Type), ; ,
.
, ,
, "", ,
.

, . .
(nonscalar) ,
,
. , (.
6), ,
. ( , ,
,
, .)
(scalar) , (!).
. (encapsulated) (atomic);
(
). 25.
, ; , .
, , ,
, .
, _
, . , . ,
( ,

5.

171

), ,
. ,
4 ( )
; , .
,
, ,
, .
QTY ( quantity
), Tutorial D .
TYPE QTY POSSREP { INTEGER } ;
, , , "
" . , (possible representation possrep), ,
( , INTEGER),
.
,
.
TYPE POINT
/*
*/ POSSREP CARTESIAN { X RATIONAL, Y
RATIONAL P} POSSREP OLAR { R RATIONAL, 0 RATIONAL } ;
POINT
, CARTESIAN POLAR, ,
" "
(CARTESIAN) (POLAR) .
, RATIONAL5. , POINT ( ) .
. , ,
. , PR , PR. ,
POSSREP
, .
4
5

, "" (. 20).

Tutorial D RATIONAL,
REAL. , RATIONAL
, . , 530.00
5.32 RATIONAL; ,
, RATIONAL (
).

172

II.

-,
,
.
_ (
),
.
. , POSSREP "
" , , "" ( ,
, - ), , .
-
_ POINT.
CARTESIAN ( 5.0, 2.5 )
/* = 5.0, = 2.5 */
CARTESIAN ( X1, Y1 )
/* = X1, = Y1, */
/* X1 Y1 - RATIONAL
*/
POLAR ( 2.7, 1.0 )
/* r = 2.7, 8 = 1.0 */
_ ( )
/* */
/* , - POINT */
THE_R ( P )
/* r */
THE_Y ( )
/* , */
/* ( POINT) */
, ,
, _ _,
.
, (, , ) (
, ; ,
).
,
, ,
( ,
). , , , , ,

5.

173

(type implementer) CARTESIAN POLAR. ,


( ) ,
. .
OPERATOR CARTESIAN ( X RATIONAL, Y RATIONAL ) RETURNS
POINT ; BEGIN ;
VAR P POINT ;
/* P - POINT */
< X := > ;
< Y := Y> ;
RETURN ( P ) ; END ; END OPERATOR ;
OPERATOR POLAR ( R RATIONAL, Q RATIONAL ) RETURNS
POINT ; RETURN ( CARTESIAN ( R * COS ( Q ) , R *
SIN ( Q ) ) ) ;
END OPERATOR ;
, POLAR CARTESIAN, SIN COS (, ). , POLAR , .
OPERATOR POLAR ( R RATIONAL, Q RATIONAL ) RETURNS
POINT ; BEGIN ;
VAR P POINT ;
< X : = R * COS ( Q)> ;
< Y :- R * SIN ( Q )>
; RETURN ( P ) ; END ; END OPERATOR ;

_ .
OPERATOR _ ( POINT
RETURN ( < X
> ) ;
END OPERATOR ;

) RETURNS RATIONAL ;

OPERATOR THE_Y ( P POINT


RETURN ( < Y
> ) ;
END OPERATOR ;

) RETURNS RATIONAL ;

OPERATOR THE_R ( P POINT


RETURN ( SQRT ( THE_X
** 2 ) ) ;
END OPERATOR ;

) RETURNS RATIONAL ;
( P ) ** 2 + THE_Y ( P )

OPERATOR THE_Q ( P POINT


) RETURNS RATIONAL ;
RETURN ( ARCTAN ( THE_Y ( P ) / THE_X ( P ) )
) ; END OPERATOR ;
, THE_R _Q _ THE_Y, SQRT ARCTAN ( ,

174

II.

). , THE_R _0 ( ).
, POINT .
, 6,
, QTY.
.
QTY ( 100 )
QTY ( N )
QTY ( N1 - N2 )
_.
THE_QTY ( Q )
THE_QTY ( Ql - Q2 )
. , N, N1 N2
Q, Q1 Q2 QTY "-" , , .
, , , ,
" 100", .
QTY, INTEGER!
QTY(IOO), 100 .

, () 100, QTY(100).
, , , , (.
. 3.8 4.5, , , . 119 154).
.
INTEGER,

TYPE LINESEG POSSREP { BEGIN POINT, END POINT } ;


LINESEG . ,
, , , ( ,
, ).
, , , , . .
5.6.
6

, , ,
, _
(
). [3.3].

5.

175

5.4.
Tutorial D TYPE,
,
.
, ,
5.6, TYPE.
WEIGHT.
TYPE WEIGHT POSSREP { D DECIMAL (5,1)
CONSTRAINT D > 0.0 AND D < 5000.0 } ;
. ,
, 5000.
. WEIGHT.
, , . -
POSSREP CONSTRAINT,
CONSTRAINT TRUE (
CONSTRAINT ,
WEIGHT , ).
WEIGHT . 3.9
3 , . , , , ( ).
, , [3.3], ,
() ,
, .
TYPE WEIGHT
POSSREP LBS { L DECIMAL (5,1)
CONSTRAINT L > 0.0 AND L < 5000.0
} POSSREP GMS { G DECIMAL (7,1)
CONSTRAINT G > 0.0 AND G < 2270000.0
AND MOD ( G, 45.4 )= 0.0 };
, POSSREP CONSTRAINT
(MOD , ; , 1 = 454 ).
.
W WEIGHT, THE_L(W)
DECIMAL( 5 , 1), ,
THE_G(W) DECIMAL ( 7 , 1),
.

176

II.
N DECIMAL ( 5 , 1), , LBS(N)
GMS (454*N), WEIGHT.

Tutorial D,
.
<type def>
::=
<possrep def list> ;

TYPE

<type name>

<possrep def>
::= POSSREP [ <possrep name> ]
{ <possrep component def commalist>
[ <possrep constraint def> ]

<possrep component def>


::= [ <possrep component name> ] <type name>
<possrep constraint def>
: : = CONSTRAINT <bool
exp>

( WEIGHT,
).
1. (list), ,
(commalist). 4
( 4.6); , .
, <xyz> (..
,
-). <xyz list>
<xyz>,
<xyz> .
2. <possr def I is t>
<possrep def>,
<possrep component def commalist>
<possrep component
def>.
3. " [" " ] " ,
( ). , "{" "}" ;
, ,
( ) . ,
,

( , , , ,
, ,
,
).

5.

177

4. <bool > ( "boolean expression"


) (TRUE FALSE).
<bool > -
,
<possrep component name> <possrep
def>

.
. ,
.
5. , < type def>
.
"-" (. 2,
2.6).
6.
( 3, 3.6).
(. 5.5).
, , ( WEIGHT, ). CONSTRAINT .
TYPE
TYPE
TYPE
TYPE
TYPE

S#
POSSREP { CHAR } ;
NAME POSSREP { CHAR } ;
P#
POSSREP { CHAR } ;
COLOR
POSSREP
{
QTY POSSREP { INTEGER } ;

CHAR } ;

( 3, STATUS CITY ,
, , , .)
, , , .
DROP TYPE <type name> ;
< type name> ,
.
, , . , DROP TYPE
, - , , .
,
; , , (,

178

II.

INTEGER). ,
" " (, TYPE Tutorial D),
, ,
. ,
DROP TYPE ,
, TYPE.
5.5.
, , , _,
. ABS RATIONAL.
OPERATOR ABS ( Z RATIONAL ) RETURNS
RATIONAL ; RETURN ( CASE
WHEN Z > 0 . 0 THEN +Z WHEN Z < 0.0
THEN -Z END CASE ) ; END OPERATOR
;
ABS ( "absolute value" )
, z, RATIONAL,
. ABS, ABS (AMTl + AMT2),
RATIONAL.
DIST ( "distance
between" )
(POINT)
(LENGTH).
OPERATOR DIST ( P1 POINT, P2 POINT
RETURN { WITH THE_X ( P1 ) AS
THE_X ( P2) AS X2 ,
THE_Y ( P1) AS Y1 ,
THE_Y ( P2) AS Y2 :
LENGTH ( SQRT (( X1 - X2
+ ( Y1 - Y2
;
END OPERATOR ;

) RETURNS LENGTH ;
X1 ,

) ** 2
) ** 2 ) ) )

, LENGTH RATIONAL.
, , WITH
. .

, "=" ( 7), POINT.
7

" "
, vl = v2 , vl v2
.

5.
OPERATOR EQ ( P1 POINT, P2 POINT
RETURN ( THE_X ( P1 ) = THE_X
THE_Y ( P1 ) = THE_Y {
) ;
END OPERATOR ;

)
(
P2 )

179

RETURNS BOOLEAN ;
P2 ) AND

, , RETURN,
"=" RATIONAL.
, "=" ( , ..
POINT); , ,
, .
">" QTY.
OPERATOR GT ( Q1 QTY, Q2 QTY ) RETURNS BOOLEAN ;
RETURN ( THE_QTY ( Ql ) > THE_QTY ( Q2 )
) ; END OPERATOR ;
RETURN ">"
INTEGER. ,
,
QTY, . ( , ">". POINT.)
, ( , , -, , , )8. , RETURNS
UPDATES;
CALL [3.3].
OPERATOR REFLECT ( POINT
P ; BEGIN ;
THE_X ( P ) := - THE_X ( P
THE_Y ( P ) := - THE_Y ( P
RETURN ; END ; END OPERATOR

) UPDATES
) ;
) ;
;

REFLECT ,
(,), (-, -); . , _. _ _
( , ).
8
, , , , , (. 25).
, , ( ).

180

II.

( ) ( ). ,
REFLECT
_ ( )

: = . . . ;

X ( ) , . ,
, ( , _),
, .
, .
VAR LS LINESEG ;
_ ( THE_BEGIN ( LS ) ) := 6.5 ;
, _ . .
_ ( ) := - _ ( ) ;
, ,
, , .
. := CARTESIAN ( - _ ( ) , THE_Y ( ) ) ;
,
_ ( THE_BEGIN ( LS ) ) := .5 ;
.
LS := LINESEG ( CARTESIAN ( 6.5,
THE_Y ( THE_BEGIN ( LS ) )
) , THE_END ( LS ) ) ;
,
, .
, (

); ,
. ( ,
.)
, , , , (":=");

( 3, ).
, ""

5.

181

[3.3]. ,
REFLECT .
_ ( ) := - _ ()
THE_Y ( ) := - THE_Y ( )
( .)
: -,
; -,
,
9.
.
, " " ; , . 9 16.
, , , , .
DROP OPERATOR REFLECT ;
, -.
.

.
TYPE S# POSSREP { CHAR } ;
S# -. , .
S#

('SI')

( .)
, s#
, .
, # , , QTY
, , ..
_
, .
, WEIGHT, 5.4.
9
, .
; ,
, , ( )
( ).

182

//.

TYPE WEIGHT POSSREP { D DECIMAL (5,1)


CONSTRAINT D > 0.0 AND D < 5000.0 } ;
w WEIGHT,
THE_D

( W )

, w,
DECIMAL( 5 , 1 ) .
, 5.2 ,
.
, , , (, WHERE), .
... WHERE # =

'2'

#, CHAR, - , ( ,
, ).
,
" " # ( , #) CHAR #,
.
... WHERE # = #

('2')

.
(coercion). ,
.
, :
, .
,
( CAST, )
, , .
CAST_AS_CHAR ( 53 0.00 )
, ( , ,
) .
, ,
, .
, , ,
, ,

5.

183

, , . , .
WEIGHT + QTY
/*
*/
WEIGHT * QTY
/*

*/
,
. , :
, . ,
, , ,
, "*", "+".
,
.
WEIGHT >
QTY EVEN >
ODD
( , EVEN
EVEN_INTEGER, ODD ODD_INTEGER,
.)
, . ,
, -, ">",
">" 10. (
, ,
, ,
, , "+" "*".)


, ,
, ,
.
,
,

.
,
; ,
,
. , ,
10
EVEN_INTEGER ODD_INTEGER
INTEGER, ">", ,
(. 20).

184

II.

( ),
!
, , , , ,
.
.
, , , , , ,
,
(
). ,
, , ,
, , , ,
,
(
)... . , !
( ). 26.
5.6. -
,
TYPE, (type generator). ,
; ,
, , . ,
.
VAR SALES ARRAY INTEGER [12] ;
SALES, 12 . ARRAY INTEGER [12] ARRAY,
.
. .
1. ,
, , ,
.
.
2.
, "" .
, ,
ARRAY INTEGER [ 12 ]. ,
.

5.

185

3. ( )
( ).
5.4 , ,
.
.
, , .
4. ,
, ,
, .
. . ,
. .
, , , ( possrep possible representation), , , , -, , , , -,
() () . , ARRAY
INTEGER [ 12 ] .
, , , , ( ; 1 12).
12
, , (), INTEGER.
, ,
_. ,

ARRAY INTEGER ( 2,

5,

9,

9,

15,

27,

33,

32,

25,

19,

5,

1 )

, ARRAY INTEGER [ 12 ] ( ,
" "). ,
SALES [3]
(.. ) ,
SALES ( , " _").
.

186 .
.
, .
SALES := ARRAY INTEGER ( 2,
19, 5, 1 ) ;

5,

9,

9,

15,

27,

33,

32,

25,

.
SALES = ARRAY INTEGER ( 2,
1 )

5,

9,

9,

15,

27,

33,

32,

25,

19,

5,

. (
,
, ).
, ARRAY .
,
lower upper.
"" REVERSE,
,
.
( , , _,
.)
, , , TUPLE RELATION.
.
5.7. SQL

SQL ,
.

BOOLEAN
BIT [ VARYING ] ()
BINARY LARGE OBJECT (n)
CHARACTER [ VARYING ] (n)
CHARACTER LARGE OBJECT(n)
NUMERIC (p,q)
DECIMAL (p,q)

INTEGER
SMALLINT
FLOAT(p)
TIME
DATE
TIMESTAMP
INTERVAL

, , , CHAR CHARACTER,
CLOB CHARACTER LARGE OBJECT, BLOB BINARY LARGE OBJECT
..;
.
.

5.

187

1. BIT BIT VARYING


SQL: 1992 SQL:2003 (!).
2. , "", CLOB BLOB
(
, 25; , BLOB
, "" (
,
BINARY). ,
(
), SQL ,
(locator), ( )
.
3.
. (
. 5). .
SET <target> = <source> ;
, .
. ,
, ":
.
UPDATE T SET C1 = exp1, ..., Cn = expn WHERE p ;

expl, ..., expn ,


1,..., Cn (a r
WHERE p).
4. , . ,
,
10
:







/

/

11

9, 9.12, " " 10, 10.6, " ". , , ,


. , ; ,
SQL:2003, .

188

II.

10 (
). , ,
, , , INTEGER FLOAT (
INTEGER FLOAT).
5. , CHAR (n), CHAR VARYING () CLOB (n).
,

(.. CHAR ()), .
. CHAR (nl) CHAR (n2),
,
,
12. , , ' 2 ' ( ) ' 2 ' (
) .
. CHAR(nl)
CHAR(n2),
CHAR(nl) nl < 2
nl > n2 , 2.
, -
.
[4.20].
DISTINCT
SQL
DISTINCT ; 13
CREATE TYPE. DISTINCT , ( "DISTINCT" , ,
"").
SQL WEIGHT DISTINCT ( Tutorial D 5.4).
CREATE TYPE WEIGHT AS DECIMAL (5,1) FINAL ;
(..
) .
12

,
PAD SPACE [4.20].
13
, ,
SQL . SQL
[4.20].

5.
CREATE TYPE <type name> AS <representation> FINAL ;

189

.
1. FINAL 20.
2. <representation> (
).
, , ,
<representation>, POINT
5.3 DISTINCT SQL.
3. , <representation>
, ,
DISTINCT. ,
SQL " possrep".
,
DISTINCT ( , )
.
4. SQL , CONSTRAINT
Tutorial D. , WEIGHT ,
, WEIGHT
DECIMAL ( 5 , 1 ) (
!) , , 5000.
5. DISTINCT
,
.
. (. 8), , ,
DISTINCT. , , WT WEIGHT.
WT +
14.7 WT *
2 WT +
WT
6. _ . , NW
DECIMAL (5 ,1), WEIGHT ( :
NW) , WT
WEIGHT, DECIMAL(WT) 14
DECIMAL(5,1 ) . SQL
.

14
, SQL: 1999, DECIMAL (WT)
, , SQL:2003.
, ( _ Tutorial D) .

190

II.

DELETE FROM P WHERE WEIGHT =


WEIGHT ( 14.7 ) ;
EXEC SQL DELETE FROM P WHERE WEIGHT
= WEIGHT ( :NW ) ;
EXEC SQL DECLARE Z CURSOR FOR
SELECT DECIMAL ( WEIGHT ) AS DWT
FROM P
WHERE WEIGHT > WEIGHT ( :NW ) ;
7. (. 8), DISTINCT
. ,
DISTINCT ,
DISTINCT, .
SQL , , NW
( ) DECIMAL ( 5 , 1 ) .
DELETE FROM P WHERE WEIGHT =
!!! */

14.7

EXEC SQL DELETE FROM P WHERE WEIGHT =


!!! */

/*
:NW ;

:
/*

EXEC SQL DECLARE Z CURSOR FOR


SELECT DECIMAL ( WEIGHT ) AS DWT
FROM P
WHERE WEIGHT > :NW ; /* :
!!! */
8. , 7, . ,
WEIGHT
DECIMAL( 5 , 1),
. , ,
.
SELECT DECIMAL ( WEIGHT ) AS DWT
INTO :NW
FROM P
WHERE P# = P# ('P1') ;
( ).
SELECT WEIGHT
INTO :NW
FROM P
WHERE P# = P# ('P1') ;
INSERT UPDATE.

5.

191

9. , DISTINCT
CAST.
.
10. (
).
. SQL : , . (

, , ,
; , 15 .) ( ),
ADDWT ( "add weight" ), ,
WEIGHT, DECIMAL( 5 , 1), .
.
ADDWT ( WT, 14.7 )
ADDWT ( 14.7, WT )
ADDWT ( WT, WT )
ADDWT ( 14.7, 3.0 )
, SQL,
[4.20] [4.28].
.
11.
.
DROP TYPE <type name> <behavior> ;
<behavior>
RESTRICT CASCADE; RESTRICT ,
DROP , -
, CASCADE ,
DROP
DROP. . .CASCADE ,
( !).

.
CREATE TYPE POINT AS ( X FLOAT, Y FLOAT ) NOT FINAL ;
CREATE TYPE LINESEG AS ( BEGIN POINT, END POINT ) NOT FINAL }_
1

5
, , , (. 20).
. , , , - (. 25).

192

II.

( , BEGIN END SQL ,


.) (..
)
.
CREATE TYPE <type name> AS <representation> NOT FINAL ;
.
1. NOT FINAL 20.
. , SQL:2003
FINAL.
2. <representation>
<at tribute defini tion commalist>,
; <attribute>
<attribute name>, < type name>.
, ""
, ,
(. 6). ,
<representation>
,
.
.
(.. , )
.
, POINT, TO
(. 3 6), ""
.
3.
( ""),
(observer) (mutator),
, 16 _
Tutorial D. , LS, z, ,
LINESEG, POINT FLOAT,
.

16
, SQL
(..
), , . , "SET . = Z" (
!)
"SET P = P . X ( Z ) " ( ).

5.
193
/* X
*/
SET Z = . ;
/* X
*/
SET . = Z ;
/* BEGIN
LS */
SET X = LS.BEGIN.X ;
SET LS.BEGIN.X = Z ;
4. - ,
CONSTRAINT Tutorial D.
5. ,
, CREATE ORDERING.
.
CREATE ORDERING FOR POINT EQUALS ONLY BY STATE
; CREATE ORDERING FOR LINESEG EQUALS ONLY BY
STATE ;
EQUALS ONLY , "=" "/="
(, , "", SQL
). BY
STATE , ,
i-e i.
CREATE ORDERING ;
, , ,
">". ,
"",
,
; , .
6. , , , .
, SQL , (constructor function), , ,
17.
, -
POINT ()
17

. ,
( ", ") .
. , ,
, ,
( POINT), ,
( ARRAY [ ]), - . , , LINESEG () , , BEGIN END,
.

194

II.
X.
X Y (. 3)
, -. , "" "" , .
POINT

()

.(5.0)

.Y(2.5)

.
LINESEG () . BEGIN ( POINT ()
. X ( 5 . 0 ) . Y ( 2 . 5 ) ) . END
(
POINT () . X ( 7 . 3 ) . Y ( 0 . 8 ) )
. -
NEW , , .
NEW LINESEG () . BEGIN ( NEW POINT
( ) . X ( 5 . 0 ) . Y ( 2 . 5 ) ) . END
(
NEW POINT ( ) . X ( 7 . 3 ) . Y ( 0 . 8 ) )
7. , , , , 6, 6.6 (
" ").
8. ,
( ) .
9.
ORDERING. , ""
ALTER TYPE, ,
( ,
).
SQL ( 6.6), 20 26.

SQL 18 ( SQL ): REF, ROW ARRAY.
ROW ARRAY, REF 26. ,
ROW.
CREATE TABLE CUST
( CUST# CHAR(3),
ADDR ROW ( STREET CHAR(50), CITY CHAR(25)
, STATE CHAR(2), ZIP CHAR(5) )
PRIMARY
KEY ( CUST# ) ) ;
18
, SQL:2003 MULTISET.

5.

195

STREET, CITY, STATE ZIP . , , .


,
( <>.< field name>, <>
).
SELECT
CX.CUST#
FROM
CUST
AS
CX
WHERE
CX.ADDR.STATE = 'A' ;
. CX . 8 ( 8.6), , SQL
,
,
.
INSERT.
INSERT INTO CUST ( CUST#, ADDR )
VALUES ( ' 666 ' , ROW ( '1600 Pennsylvania Ave.',
'Washington', 'DC, '20500' ) ) ;
" "
( " "
, SQL , , , , ).
.
UPDATE CUST AS CX
SET CX.ADDR.STATE = 'TX'
WHERE CUST# = '999 ' ;
.
, , , .
ARRAY . .
CREATE TABLE
ITEM_SALES (
ITEM# CHAR(5),
SALES INTEGER ARRAY
[12], PRIMARY KEY (
ITEM# ) ) ;

196

II.

, ARRAY, ; ( INTEGER) , , 19. , .


( > 0) , ( 12). ( > 0),
[ 1 ] , [ 2 ] , . . . , [ ] , . CARDINALITY () .
, ITEM_SALES.
, (,
, " ", , ).
SELECT ITEM#
FROM ITEM_SALES
WHERE SALES [3] > 10 ;
INSERT INTO ITEM_SALES ( ITEM#, SALES
) VALUES ( 'X4320',
ARRAY t 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ] ) ;
UPDATE ITEM_SALES SET
SALES [3] = 10 WHERE
ITEM# = 'Z0564' ;
, ROW ARRAY
, ,
ROW
ARRAY; , ROW ARRAY.
5.8.

( ).
, , , ( Tutorial D POSSREP,
CONSTRAINT). ( , , ),
.
19

, SQL:2003 .
, , .
() .
VX ROW (FX INTEGER ARRAY [ 1 2 ] ) ARRAY [12]
() VX [ 3 ] . FX [ 5 ] ,
, ,
VX.

5.

197

, ,
, , , , , ,
..
, ,
( ). ,
, , . ,
(, ..),
7.
, ,
, . ;
() , ( ) , , , .
; ,
. ,
. ( , .)
( , ).
, ( ).
, _
( _).
, .
,
, ,

(, ).
,
, ( ARRAY). ,
,
, .
, SQL.
SQL , BOOLEAN, INTEGER,
DATE, TIME .. ( , ,
), .
, DISTINCT ; , (ARRAY ROW, REF). SQL
, .

198

II.

5.1. (":=")
("=").
5.2., :

;
;
;
;
, , .

5.3. :
_

5.4. ?
5.5. , , ,
.
5.6. , , ,
,
f(x) g (), f g .
5.7. . 5.6, ,
, .
5.8. CIRCLE.
_ ? , .
) , , , .
) ,
(, CIRCLE ,
,
,
).

5.

199

5.9. ,
. ,
,
.
5.10. ,
. 3.6 3. ,
?
5.11. ?
5.12.
, (. . 4.5 . 154).
, .
5.13. 5.3, ,
, ()
100. (" QTY, INTEGER!").
. 4.5 ,
, , ,
. . 5.12,
. 4.5.
5.14. . 5.12, , .
, , , , -,
.
)
)
)

J.CITY = P. CITY.
JNAME | | PNAME.
QTY * 100.
) QTY + 100.
) STATUS + 5.
) J.CITY < S.CITY.
) COLOR = P. CITY.
3) J.CITY = P. CITY | | 'burg'.
5.15. ,
, . ,
.

" ".
.

200

II.

5.16. , 5.3 5.4,


SQL.
5.17. . 5.12 SQL.
5.18. SQL .
)
)

DISTINCT? DISTINCT? , DISTINCT?


? ? ,
?

5.19. , -,
SQL.
5.20. ,
"="?
5.21. , , ( ) ,
. .
5.22. , SQL .
.
5.23. POINT SQL, " " 5.7. , X Y. ,
POINT, ,
R 6?
5.24. CARDINALITY COUNT SQL?
. COUNT 8.6 8.

5.1.

Cleaveland J.C. An Introduction to Data Types // Reading, Mass.: Addison-Wesley,


1986.

6.1.
6.2.
6.3.
6.4.
6.5.
6.6.
6.7.




SQL

6.1.
, ,
,
. ,
( ),
, . ,
, ,
;
, .
6.2.
.
Ti (i = 1, 2, . . ., ),
, ( ),
( t),
<Ai,Ti,vi>, Ai , Ti vi
Ti. , t
.

202

II
, t.

<Ai, Ti, vi> t.


<Ai, Ti> t
Ai ( Ai Aj , i=j).
vi , 1 Ai t.
Ti .
t.
t t,
( )
, t. .
TUPLE { 1 1, 2 2,

..., An }

MAJOR_P#, MINOR_P# QTY; : #, # QTY,


# { ' 2 '), # ( ' 4 ' ) QTY (7) (
, , 2, 4 7).
, .

.
TUPLE { MAJOR_P# P#, MINOR_P# P#, QTY QTY }
. .
.

Tutorial D
.
TUPLE { MAJOR_P# #('2'), MINOR_P# #('4'), QTY QTY(7) }
( ; .
" TUPLE".) ,
1
, .
, " Ai"
, Ai (
).

6.

203


(, MINOR_P# #, # ).

,
, . .
( )
.
, ,
. ,
,
.
(
). ,
, , ! (. ).
. ,
, ( ..);
n-2. (..
) - -. . -
Tutorial D.
TUPLE { }

, "0- ". ,
. , , , .
6.4.
TUPLE
Tutorial D TUPLE,
()
3. .
2

n- (
, , , ..).
.
3

,
. ,
, -,
(.. , "
").

204

II.

VAR ADDR TUPLE { STREET


CHAR, CITY
CHAR, STATE
CHAR, ZIP
CHAR } ;
TUPLE .
TUPLE { <attribute commalist> )
<attribute> <attribute name>, <type name>.
TUPLE; , ,
ADDR, , .
.
, ADDR.
TUPLE

{ STREET ' 1 6 0 0 Pennsylvania A v e . ' ,


STATE 'DC', ZIP ' 2 0 5 0 0 ' }

CITY

'Washington',

, ,
ADDR . , , , , .
,
(
).

, .
, , , .
, .

, (. 7).
(. 9).
(. 9).
(. 1113).

, .
.
. tl t2 (..
tl = t2 ) ,
1, 2, . . . , An i (i = 1, 2,
. . ., ) vl Ai tl v2 Ai
t2.

6.
205
( ,
), tl t2
, ( ,
).
, ,
- !
- ,
( - ).
,
, "<" ">" (.. "
").
, [3.3] ( 7)
, .. ,
,
( , , ). , ADDR , ,
.
TUPLE { STREET 1600 Pennsylvania Ave.',
CITY 'Washington', STATE 'DC', ZIP '20500' }

ADDR { CITY,

ZIP }

.
TUPLE

CITY

'Washington',

ZIP

'20500'


. , ADDR ,
,
ZIP FROM ADDR
.
'20500'

,
, , . , .
ADDR { CITY,

ZIP }

, ,
ADDR " " STREET STATE, a
.
TUPLE { CITY CHAR, ZIP CHAR }
.

206

II.

WRAP UNWRAP
.
TUPLE { NAME NAME, ADDR TUPLE { STREET CHAR, CITY CHAR,
STATE CHAR, ZIP CHAR } }
TUPLE { NAME NAME, STREET CHAR, CITY
CHAR, STATE CHAR, ZIP
CHAR }
, , 1 2. , , , 1 , ( 1 , ). , NADDR1 NADDR2 1
2, . .

NADDR2 WRAP { STREET, CITY, STATE, ZIP } AS ADDR
NADDR2
STREET, CITY, STATE ZIP ADDR, .
1, ()
.
NADDR1 := NADDR2 WRAP { STREET, CITY, STATE, ZIP } AS ADDR ;

NADDRl UNWRAP ADDR
NADDRl
ADDR ( )
STREET, CITY, STATE ZIP,
2, ()
.
NADDR2 := NADDRl UNWRAP ADDR ;


TUPLE, ,
, 5 (
,
),
, . ( ). , X ,
,
. X ,
. [3.3].

6.

207

6.3.
. , , ,
,
: 6.3 , 6.4 , 6.5
(relation variable, relvar).
.
( ), , 4, , .
r ,
6.2. r (
, ) , .
r ,
; r
. ( ,
.)
r r (, ) , .
.
RELATION { 1 1, 2 2,

..., An Tn }

( , , . 4.6 4).

.
RELATION { MAJOR_P# P#, MINOR_P# P#, QTY QTY }

4
,
, .
() . ,
(intension), (extension).

208
II.

.
.

Tutorial D
.
RELATION
TUPLE {
TUPLE {
TUPLE {
TUPLE {
TUPLE {
TUPLE {

{
MAJOR_P#
MAJOR_P#
MAJOR_P#
MAJOR_P#
MAJOR_P#
MAJOR_P#

#('P1'),MINOR_P# P#('P2'), QTY QTY(5) }


P#('P1'),MINOR_P# P#('P3'), QTY QTY(3) }
P#('P2'),MINOR_P# P#('P3'), QTY QTY(2) }
P#('P2'),MINOR_P# P#('P4'), QTY QTY(7) }
P#('P3'),MINOR_P# P#('P5'), QTY QTY(4) }
P#('P4'),MINOR_P# P#('P6'), QTY QTY(8)

,
,
,
,
,
}}

,
.
RELATION [ <heading> ] { <tuple exp commalist> }
<heading>,
<attribute>, ,
,
< tuple exp coimalist>. , < tuple exp>
,
, , <heading>,
.
, , - . ,
,
, .
, ,
- , - ( ..); , -. (..
) - ( ). , ,
.
(
).
.

6.

209

, ,
.
RELATION
Tutorial D RELATION, () .
.
VAR PART_STRUCTURE ...
RELATION { MAJOR_P# P#, MINOR_P# P#, QTY QTY } ... ;
( , .) , RELATION ,
TUPLE, , TUPLE RELATION. ,
RELATION (, PART_STRUCTURE), , .
.
. , , PART_STRUCTURE
. , , , ,
. , (

).
6.4.
(.. ) . , , ; , , . , .
, .
1. ( )
.
2. - (,
).
3. - (, ).
4. .
, . 3.8 (. . 119).
. 6.1, .

210 II.
.
. , S# si .
S# S# S#('S1')

. 6.1. , . 3.8
,
. 3.8.
1.
6.2,
,
,
. ,
, ;
, 5, 1.
, , . 6.1,
.
. , , (
) ! ,
. . "
" , 19 (
).
2. - (, )
, - (, ),
(
, , ,
, ).
, , , , , . , . 6.1 () , SNAME,
CITY, STATUS, S#, ,
5
"" , "
" , .. (. 12 13).

6.

211

, 6.
, " " " " ( ..), " " (.. "");
, .
. , , - ""
, .
,
,
, ,
, .
3. - (, )
,
(); , . ,
;
, , .
, . 6.1
, - .
, " ", " "
"97- " , , ,
" "; ,
"". ,
, , , " - ", "
", " " .. ( ),
,
.
. , N
, N , N > 1,
, , , ,
. ,
! - , , N > 1, N= 1. 26 (. [26.12][26.14] [26.17]), 27.
6
, , ,
, ( , ,
).

212

II.

. ,
(
) , COBOL (. SQL
ORDER BY, 4). ,
;
, (),
, , " -
". ,

.
; , ,
. 4.

,
; (
, ).
. ,
,
( , ), , , - .
, ( ) ,
" " . ,
, . 6.1, , s# CITY
( 6.5, " s# CITY"), ,
, " ",
S1 . , ( , ),
" " .
, !
, , [6.3] [6.6].


,
, (), .
1. ,
.

6.

213

2.
,
.
3.
,
, , s1 s# (' S1').
4. ,
.
. ,
. ,
SQL.
SELECT S.CITY, S.STATUS * 2,
P.CITY FROM S, P ;
?
5. ,
.
6. ,
.
.
.
,
,
(. " " ).
, ( , SQL),
(NULL),
(. 19).
, "" ( ),
n- (. 22).
,
, "" , ;
, . , , , ,
. , .
, ,
( ). , ,
, , . ,

214

II.

. ,
, , , . (
), ,
.
,
, , , . ,
. , , , ,
(, , ).

6.3,
. , , ,
, , , . ,
, ,
, , , . ,
, .
. 6.2.
, , -, PQ
, -, , , , , S5,
PQ, (, ).

. 6.2. ,

6.

215

, , , . . ,
.
, ... , ( !) ( !)
, . , ,

# ,
.
..., (, , ). ; .
.
(.. ) ... []
. ,
, ( )
... .
( , ).
, (). , 12 ( 12.6),
, -
; , ,
. , , ,
! 12.

216

II


, ,
, , ,
, , , . ( : "
", , , , , ,
.) ,
, . , ,
, ,
!
, ,
- . ( ) . , ,
, , , - (.. ), , . ,
. , , (Darwen) [6.5], . TABLE_DEE, TABLE_DUM
DEE DUM (DEE , aDUM ).
. !
DEE DUM.
DEE DUM ? , . , (. 7),
,
. ,
( [6.5]); DEE TRUE, , a DUM FALSE,
. ,
. ( ,
, , DEE "",
yes .)
Tutorial D TABLE_DEE TABLE_DUM , , .
RELATION { } { TUPLE { } }

RELATION { } { }
;
, DEE DUM .
[6.5].

6.

217


6.3 ,
. ,
"<" ">" , , ,

, .

<bool > , <relation comp>, .
<relation exp> <relation > <relation exp>
, <relation exp> ( ), , <relation > .
=. .
.
.
.
.
.
<relation comp>
, <b1 >, ,
WHERE. .
1. S { CITY } = { CITY }
: " CITY CITY?"
2. S { S# } SP { S# }
( ): " , ?"
, ,
, ,
(.. , ). . .
IS_EMPTY ( <relation exp> )
TRUE, ,
<relation exp> ,
FALSE.

218


, t r.
t r
TRUE, t r, FALSE (" " ; t r "t r", "t r",
, , "t [] r").
, .
TUPLE FROM r
, r ;
.
, , (, , ..),
. .

, , 6.2,
,
, , 6.3, . 7, . S,
S { S#, CITY }
(), .
RELATION { S# S#, CITY CHAR }
.
ORDER BY

ORDER BY, SQL (. 3).
, , , .
.
ORDER BY ( ),
, ,
"<" ">" ( !).

6.

219

ORDER BY ,
.
ORDER BY ,

.
ORDER BY CITY , . 6.1.
, .
, ,
.
6.5.
(relation variable, relvar).
3,
( , , ). (
10), ,
, .

.
VAR <relvar name> BASE <relation type>
<candidate key def list>
[ <foreign key def list> ] ;
<relation type> .
RELATION { <attribute commalist> }
<attribute commalist> . RELATION,
6.3). <candidate key def list>
<foreign key def list> .

( . 3.9).
VAR S BASE RELATION
{ S# S#,
SNAME NAME, STATUS
INTEGER, CITY CHAR
} PRIMARY KEY { S#
} ;

220

II.

VAR P BASE RELATION { # #,


PNAME NAME,
COLOR COLOR,
WEIGHT WEIGHT,
CITY CHAR }
PRIMARY KEY { P#};
VAR SP BASE
RELATION { S#
S#, P# P#, QTY
QTY }
PRIMARY KEY { S#, P# }
FOREIGN KEY { S# }
REFERENCES S FOREIGN KEY { P#
} REFERENCES P ;

1. ().
RELATION { S# S#, SNAME NAME, STATUS INTEGER, CITY
CHAR } RELATION { P# P#, PNAME NAME, COLOR COLOR,
WEIGHT WEIGHT, CITY
CHAR } RELATION { S# S#, P# P#,
QTY QTY }
2. , , , , ( ..),
,
.
3. , , ( ,
),
.
4.
, .
5. 9,
,

,<candidate key def> .
PRIMARY KEY { <attribute name commalist> }
6. 9.
7.
.
8. 3, , ,
. ,
,
. , S
.

6.

221

S# , SNAME
STATUS, CITY
9. ,
.
,
, .
Tutorial D
, , DEFAULT
{ <default spec commalist> },
<default speo <afctribute name>
<default> (< > < >). ,
s
DEFAULT { STATUS , CITY ' ' }.
.
, (. 19).

.
DROP VAR <relvar name> ;
"" (..,
, );
.
.
. , DROP , ,
, - ,
- .

,
( ), .. .
Tutorial D.
<relation assignment>
: : = <relation assign cormalist>
; <relation assign>
: : = <relvar name> := <relation exp>
7: -,
<relation exp> <relation assign>,
-, <relation assign>
7

, 9 5.

222

II.

, .
<relation assign> , , <relation exp> ,
, <relvar name> ( ). , .
, , S'
SP', , , , S SP, .
VAR S' BASE RELATION
{ S# S#, SNAME NAME, STATUS INTEGER, CITY CHAR }
... ; VAR SP1 BASE RELATION
{ S# S#, P# P#, QTY QTY } ... ;
<relation assignment>.
1. S' := S , SP1 := SP ;
2. S' := S WHERE CITY = 'London' ;
3. S' := S WHERE NOT ( CITY = 'Paris' ) ;
, <relation assign> , -, , , , -, , .
,
S '
S, .
2.
3.

S := S WHERE CITY = 'London' ;


S := S WHERE NOT ( CITY = 'Paris' ) ;

,
S , , ,
. Tutorial D
INSERT, DELETE UPDATE,
<relation assign>.
.
1. INSERT S RELATION { TUPLE { S# S# ('S6'),
SNAME NAME ('Smith'),
STATUS 50,
CITY 'Rome' } } ;
.
S := S UNION RELATION { TUPLE { S# S# ('S6'),
SNAME NAME ('Smith'),
STATUS 50, CITY 'Rome' } }
;

6.
223
, , ,
S6
S. INSERT
, ,
" ".
. DELETE UPDATE.
2. DELETE S WHERE CITY = 'Paris' ;
.
S := S WHERE NOT ( CITY = 'Paris' ) ;
3. UPDATE S WHERE CITY = 'Paris'
{ STATUS := 2 *
STATUS, CITY :=
'Rome' } ;
.
S := WITH ( S WHERE CITY = 'Paris' ) AS T1 ,
( EXTEND Tl ADD ( 2 * STATUS AS NEW_STATUS,
'Rome' AS NEW_CITY ) ) AS
T2 T2 { ALL BUT STATUS, CITY } AS T3 , ( T3
RENAME ( NEW_STATUS AS STATUS,
NEW_CITY AS CITY ) ) AS
T4 : ( S MINUS Tl ) UNION T4 ;
,
; , .
.

INSERT, DELETE UPDATE.
INSERT <relvar name> <relation exp>;
DELETE <relvar name> [ WHERE <bool exp> ] ;
UPDATE <relvar name> [ WHERE <bool exp>
]
{ <attribute update commalist>

};

<attribute update>
.
<attribute name> := <x>
, <b1 > DELETE UPDATE ,
.
,
, , INSERT, DELETE UPDATE
8. , UPDATE, ,
8

, , CURRENT DELETE UPDATE


SQL (. 4.6) (, , )
.

224

.
, () , , .
1. ,
.
2.
!
, , (. 9), si S4
. "" UPDATE,
,
. , , .
UPDATE S WHERE S# = S# ('S1') OR Si = S#
('S4') { STATUS := <
> } ;
, " , " , , . , .
() " t t' ",
, t (.. t)
t' (, , )9.
, " "
. -
" " " ",
, , , .

, 3.4
3,
, , , ,

( " ").
, , , , , , ,
. ,
9
, , -.
6.2, -
.

6.
225
( ) ,
, (.. , ), ,
.
,
, ,
. 9.
6.6. SQL

SQL ;
,
. (
, ,
) ( , ). .
"" ( SQL constructed) (
<row value constructor>) .
[ ROW ] ( < commalist> )
, commalist
<>;
ROW, . , , ( SQL "-
"). .
ROW

#('2'),

#('4'),

QTY(7)

.
5, SQL
ROW ( Tutorial D TUPLE),
, , 10. .
DECLARE ADDR ROW ( STREET
CHAR(50), CITY
CHAR(25), STATE
CHAR(2), ZIP
CHAR(5) ) ;
, ,
5.7 5. ,
10

, " SQL" , " ", , TUPLE ( !).

226

II.

r1 = 2 , , rl 2 .
, SQL "<" ">" !

; [4.20].
SQL
( " ", " " ..), WRAP UNWRAP. ,
- " ",
, -, , SQL
- .

SQL ; . SQL , ( multiset , ,
, , ,
); . ( , ,
, SQL.) SQL , .
.
"" ( , SQL
constructed) ( <table value constructor>) .
VALUES <row value constructor commalist>
commalist . ,
,
VALUES (
,
( #(' 1 ' ),
( #('2'),
( #('2'),
( #(' ' ),
( #(' 4 ' ),

# ( ' 1' ) ,

# ( ' 2 ' ) ,

QTY ( 5 )

#(' ' ), QTY(3)


#(''),
#('4'),
#(' 5 ' ), QTY(4)
# ( ' 6 ' ) , QTY(8)

) ,
QTY(2)
QTY(7)
) ,
)

,
,

)
)

, ,
6.3, ,
.
SQL
RELATION. (
INSERT, DELETE UPDATE). ,
- ( "=").
SQL , ,
, .
<row value constructor> IN <table exp>

6.

227

, TUPLE FROM.
( <table exp> )
, , <table exp> ,
, ; .
. , , < table name>
< table exp> (!?).

, SQL
.
,
, , .
SQL .
CREATE TABLE <base table name>
( <base table element cornmalxst> ) ;
<base table element>
<column definition>
<constraint>, 11 .
<constraint> ,
.
9 , SQL
(, ,
- ),
.
<column definition> (
) .
<column name> <type name> [ <default speo ]
defaul t speo
( ),
,
INSERT ( 4, 4.6,
", ").
DEFAULT <default>, <default> , 12 NULL (. 19).
, ,
11
<base table element> LIKE T,

.
12
, .
CURRENT_DATE.

228

II.
(NULL-);
.. "
" (
SQL).
. , , ,
, (
4). , , , ( ARRAY [ ]),
.

CREATE TABLE
. 4.1 4. , ( )
SQL ,
. , ORDER BY
(. 7 8). "
" ( , , ) , , ; ,
.
. .
'DROP TABLE <base table name> <behavior> ;
( DROP TYPE, 5)
<behavior> RESTRICT CASCADE. ,
RESTRICT , DROP ,
- , CASCADE
, DROP DROP. . .CASCADE , . , ALTER TABLE
. .
.
, ,
( , ).
, .
.
.
.
.
ALTER TABLE S ADD COLUMN DISCOUNT INTEGER DEFAULT -1 ;

6.

229

DISCOUNT ( INTEGER) . ; ,
-1.
, INSERT, DELETE UPDATE SQL
4.

. SQL, ,
. , .
, , 5 ( 5.7).
CREATE TYPE POINT AS ( X FLOAT, Y FLOAT ) NOT FINAL ;
POINT , , .
CREATE TABLE NADDR (
NAME ... , ADDR ...
, LOCATION POINT
... ,
, 5, ,
, , SQL
, ,
POINT Tutorial D. SQL
13 Tutorial D. , ,
("") POINT,
. , , ( , ).
SELECT NT.LOCATION.X,
NT.LOCATION.Y FROM NADDR AS NT
WHERE NAME = ... ;
UPDATE NADDR AS NT
SET NT.LOCATION.X =5 .0
WHERE NAME = ... ;
, , SQL , ( 5.7 5), .
13
,
- , .

230

II.

, .
, , ,
( ).
SQL ,
. ( !)
14.
, SQL
, "OF",
.
, POINT .
CREATE TYPE POINT AS ( X FLOAT, Y FLOAT ) NOT
FINAL REF IS SYSTEM GENERATED ;

"OF", , .
CREATE TABLE POINTS OF POINT
( REF IS POINT # SYSTEM GENERATED ... ) ;

1.
( REF ) REF { T ).
15
REF(T) ,
"OF" (. . 3).

REF (POINT),
. , , POINT
"OF".
2. REF IS SYSTEM GENERATED CREATE TYPE
, REF
( , , REF IS USER
GENERATED, ).
. REF IS SYSTEM GENERATED ,
IN.
3. POINTS
POINT "OF". OF
,
14

!
20 26.
15
, , .
, , .

6.

231

( "of)
! 16.
, , , ST,
( SQL!)
, TABLE (ST),
ROW(ST).
;
ST.
POINTS , Y;
POINT.
, ,
REF.

.
REF IS <column name> SYSTEM GENERATED
<column name> , ;
"" .
. POINTS (POINT#, X Y, ),
.
. , "OF" , ,
" ", , SQL.
, ( ), ,
SYSTEM GENERATED, ..
, INSERT UPDATE,
.
.
4. POINTS , SQL
( ) (typed table), ,
(referenceable table). ,
16
, , ,
ST, ,
ST "OF",
.

232

II.
: " ..., , . ".
: ", , ... . , ".

,
SQL: 1999 SQL " "17,
26. , ,
.
. 5,
Tutorial D " ";
TUPLE,
() . , , Tutorial D , .
TUPLE { 1 1, 2 2,

. . . , An }

, ,
.
, SQL Tutorial D
. ;
" ",
. SQL.
CREATE TYPE P0INT1 AS ( X FLOAT, Y FLOAT ) NOT
FINAL ; CREATE TYPE P0INT2 AS ( X FLOAT, Y FLOAT
) NOT FINAL ; DECLARE V1 P0INT1 ; DECLARE V2
P0INT2 ;
, V1 V2
. ,
.
6.7.

. ,
17
, SQL
REF, REF ,
,
" ".

6.

233

, ,
, . TUPLE, , , .
(,
). ,
( )
. , RELATION , ,
.
. , , ,
. , ,
,
(, ..). , , . , 5,
, , , , , , , , ..
(
), .

. ,
.
1.
2.
3.
4.

.
.
.
- .


;
TABLE_DEE TABLE_DUM,
. ,

(, ,ORDER BY).
, , ,
5 , .
, (, , , ..) - " ". ( ,

234

II.

, , ,
.) , , , , , .
,
, ,
.
,
, , . , ,
,
.
( INSERT, DELETE UPDATE). , , , , " " " "
.
, SQL,
. SQL ,
( , SQL ).
"" ALTER TABLE. , SQL
;
( 26).

6.1. .
6.2. .
6.3. ,
:
)

;
)
;
)
;
)
.

6.4. , , . 4.5 (. .
154), Tutorial D :
)
)

6.

235

6.5.
, .
6.6. ,
,
, .
6.7. Tutorial D?
) RELATION { S# S#, P# P#, J# J#, QTY QTY } { }
) RELATION { TUPLE { S# S#('S1'), P# P#('P1'),
J# J#('J1'), QTY QTY (200) } }
B) RELATION { TUPLE { } }
) RELATION { } { TUPLE { } }
) RELATION { } { }
6.8. .
6.9. .
6.10. :
) ,
) .
, ,
, , ,
.
6.11. , TRUE,
, FALSE .
IS_EMPTY.
6.12. ORDER BY ?
6.13. .
6.14. , , ""
, "" .
.
6.15. Tutorial D
, .
a)

si,
1, J2, 500.
b) s , S10
Smith, New York; .
c) .

236

II.

) , .
) .
) S1
S9.
6.16. , . ,
.
INSERT, DELETE UPDATE?
.
6.17. ,
.
" ". - ?
6.18. , , SQL?
6.19.{ . 5.23.) POINT POINTS SQL, "
" 6.6. POINT , X and Y. , POINT , R and 8?

,
.
6.1.Codd E.F. A Relational Model of Data for Large Shared Data Banks // CACM. June
1970. 13, 6. (: Milestones of Research. Selected Papers 1958-1982
(CACM 25th Anniversary Issue) // CACM. January 1983. 26, 1. .
: Derivability, Redundancy, and Consistency of Relations Stored in Large
Data Banks // IBM Research Report RJ599. August 1969. 19.
. (Codd)
.)
. 30 ,
, - . ,
,
, . , ,
.
.
" " ",
". . -,

6.
( ,
). -, -

237

DECLARE N INTEGER ;
N , ;
.
" " " ",
.
6.2.

Codd E.F. The Relational Model for Database Management Version 2. Reading,
Mass.: Addison-Wesley, 1990.

1980-
(
"the Relational Model Version 1" RM/V1),
.
"the Relational Model Version 2" RM/V2.
.
( ,
),
. , 3 (,
), RM/V2
18 , 3 ,
, , , , ,
.
18 .
A
B
C
D
E
F
I
J
L

M
N
P
Q
S
T
V
X
Z

, , , . (., , [6.7] [6.8].)


. 5, (.. ) . , S. S# = . # , . ,
.
DCO (Domain Check Override ).
, . ,

238

II.
, DCO , ,
, , S. S# P. # (, , ).
. DCO
. , (..
), ,
, DCO. ,
.

THE_S#

( S# )

= _#

( # )

CHAR. , ,
5
(.. ),
. ,
DCO ..
6.3. Darwen H. The Duplicity of Duplicate Rows // . J. Date and Hugh Darwen. Relational
Database Writings 1989-1991. Reading, Mass.: Addison-Wesley, 1992.
, [6.6]
( ), ,
.
, .
:
, (
) ( ,
, " " ,
- ).
6.4. Darwen H. Relation-Valued Attributes // . J. Date and Hugh Darwen. Relational
Database Writings 1989-1991. Reading, Mass.: Addison-Wesley, 1992.'
6.5. Darwen H. The Nullologist in Relationland // J. Date and Hugh Darwen. Relational
Database Writings 1989-1991. Reading, Mass.: Addison-Wesley, 1992.
" " , ,
. (
"", NULL- SQL!)
, , ,
,
.
. . ,
2 (" ")
3 (" ").

6.

239

6.6. Date C.J. Double Trouble, Double Trouble // http://www.dbdebunk.com, April


2002. : Date C.J. Why Duplicate Rows Are
Prohibited // Relational Database Writings 1985-1989. Reading, Mass.: AddisonWesley, 1990.
( )
,
. , ,
(. 18). . [6.3].
6.7. Date C.J. Notes Toward a Reconstituted Definition of the Relational Model Version 1
(RM/V1) // J. Date and Hugh Darwen. Relational Database Writings 1989-1991.
Reading, Mass.: Addison-Wesley, 1992.
RM/V1 [6.2]
. ,
" 1", - " 2". .
, ,
"" , (
[3.3]).
6.8. Date C.J. A Critical Review of Relational Model Version 2 (RM/V2) // J. Date and
Hugh Darwen. Relational Database Writings 19891991. Reading, Mass.: AddisonWesley, 1992.
RM/V2 [6.2].
6.9. Date C.J. The Database Relational Model: A Retrospective Review and Analysis //
Reading, Mass.: Addison-Wesley. 2001.
( 160 ) , 1970- . , ( ).

Derivability, Redundancy, and Consistency of Relations Stored in Large Data Banks


( [6.1]).
A Relational Model of Data for Large Shared Data Banks [6.1].
Relational Completeness of Data Base Sublanguages [7.1].
A Data Base Sublanguage Founded on the Relational Calculus [8.1].
Further Normalization of the Data Base Relational Model [11.6].
Extending the Relational Database Model to Capture More Meaning [ 14.7].
Interactive Support for Nonprogrammers: The Relational and Network Approaches
[26.12].

6.10. Roth M.A., Korth H.F., Silberschatz A. Extended Algebra and Calculus for Nested
Relational Databases //ACM TODS 13. December 1988. 4.
; .
"

240

II.
NF2" ( NF ), NFNF
, (NFNF Non First Normal Form).
,
.
-, ,
NF2, ,
"
" (
[6.10]).
-, ,
NF2, . ,
(Roth)
, ( )
,
(
),
, ,
. ,
. ,

, ,
,
.

7

7.1.
7.2.
7.3.
7.4.
7.5.
7.6.
7.7.
7.8.
7.9.
7.10.

7.1.
,

. [5.1] [7.1];
""
[7.1]. "" ,

.
1. , ,

(
,
,
).
2. , (

), , .
. 7.1
.

242

II.

. 7.1. ( )
, , , , , .
; ,
, , "
", .
( , ,

7.

243

)
;
, .
,
, .
, ,
; , RELATION
,
.
, , ,
! 7.10.
, (..
"", ). ,
(, ) , ,
, .
, , , , " R ";
,
R.
" R " . , ,
SC S,
s# CITY .
, ,
SC " s
s# CITY"; , sc

S s# CITY .
,
. ,
- .
.

( 7.2). 7.3 7.4 , 7.5 ,
. 7.6
, . 7.7
. , 7.8 , , ,

244

II.

, EXTEND SUMMARIZE. 7.9


. , 7.10 .
. SQL 8 , .
7.2.

3, , , . ,
; ,
, , . (
; , , ,
, ,
.)
, 3
. ,
; , ,
. ( ,
5, ), , ,
. ? ,
.
S JOIN P

CITY,
. , , ? ,
, (, ,
). , (!) .
, ,
, ,
. (, ,
, , , SQL
SQL; , [7.2] [7.10]. , , .)

7.

245

, ,
, , , , , .
, , ,
, s JOIN P CITY.
( S JOIN P ) WHERE CITY = 'Athens'
,
, , () ()
, , . ,
,
, ,
, , .
,
RENAME, ( )
. , RENAME , , ,
. ( ,
.) , .
S RENAME CITY AS SCITY
( , . "" ) , ,
S, ,
SCITY, CITY, .

. ,
RENAME !
( , , , S JOIN SP ) , , (
).
(
).

246 II.
, RENAME ,
RENAME ( PNAME AS PN, WEIGHT AS WT )
.
( RENAME PNAME AS PN ) RENAME WEIGHT AS WT
, .

SQL, ,
, S. S# ( ).
7.3. -
,
RENAME. Tutorial D.
. .
.
:
(""), , , ("-")
.. , JOIN WHERE.
, , .
<relation >
: : = RELATION { <tuple exp
commalist> } | <relvar name> |
<relation op inv> j <with exp>
| <introduced name> | (
<relation exp> )
<relation exp> , (.. ). (. 6);
< tuple exp> ,

. <relvar name>

7.
247
{<relation exp>) ;
.
<relation op inv>
::= <project> | <nonproject>
<relation op inv> , <project>, , , <nonproject>.
.
( ).
<project>
::= <relation exp>
{ [ ALL BUT ] <attribute name comnalist> }
<relation exp> <nonproject>.
<nonproject>
::= <rename> | <union> \ <intersect> \ <minus> \
<times>
| <where> | <join> \
<divide> <rename>
: : - <relation exp> RENAME ( <renaming cowmalist> )
<relation exp> <nonproject>.
<renaming> , (
<renaming> , ). commalist <renaming>,
.
<union>
: : = <relation > UNION <relation exp>
<relation exp>
<nonproject>, ,
<>.
<intersect>
: : = <relation exp> INTERSECT <relation exp>
<relation exp>
<nonproject>, ,
<intersect>.
<minus>
::= <relation exp> MINUS <relation exp>
<relation
<nonproject>.

exp>

<times>
::= <relation exp> TIMES <relation exp>

248

II.

<relation exp>
<nonproject>, ,
< times>.
<where>
::= <relation exp> WHERE <bool exp>
<relation exp> <nonproject>.
<1 > , <relation exp>, .
<join>
::- <relation exp> JOIN <relation exp>
<relation exp> <nonproject>,
,
<joi.n>.
<divide>
::= <relation exp> DIVIDEBY <relation exp> PER <per>
<relation exp> <rjct>.
<r>
::=

<relation exp> |

( <relation exp>, <relation exp> )

<relation exp> <nonprojct>.


<with exp>
::= WITH <name intro commalist> : <exp>

WITH, <wi th exp>,


, . <wi th exp>
; <wi th exp> <relation exp>, <tuple exp> <scalar exp>
, , , <>, ,
<relation exp>, < tuple exp> <scalar exp>. <name intro> ,
, <with exp>
<>, , .
. WITH
; ,
(
). 7.5.
<name intrc
::= <> AS <introduced name>

7.

249

<introduced name>
<wi th exp> , <> (
).
7.4. -

, , .
(, , ) (
), , ,
; , , , . , , S, ,
, , .
, ;
,
. ,
, .

; , ,
. , ,
,
.
, ,
; , .
.
( ) , , (union compatibility).
; ,
.
:
b , a UNION
b , t, b .
. , B , . 7.2 (
S; , , ,
1). A UNION (. . 7.2, )
, , 1,
. , , ;
(, ,
" "). , ,

250

, , ( ).

. 7.2. ,
, , . , , (
): b ,
a UNION b ,
t, , t b
{.. ). , .

, ,
, .
b ,
INTERSECT b , t,
, t b.
. , . 7.2. A INTERSECT (. 7.2, ) ,
1.

7.

251

, , .
b , a MINUS b ( ), , t, ,
t , b.
. , . 7.2. A MINUS (. 7.2, ) , 1, MINUS A
(. 7.2, ) , 1 . , MINUS
(), , (, "5 2" "2 - 5" ).

( ) , , .
, ,
. ;
, , , .
, ,
(
, ). ,
1
{ Al al, A2 2,

. . . , Am am }

B1 b1,

B2 b2,

...,

Bn bn

- .
{ Al al, A2 2,

..., Am am, Bl bl, B2 b2,

..., Bn bn }

. , . .
,
, , , (..
). , ,
1

Tutorial D ,
TUPLE.

252

II.

, . ,
- , ;
,

. ,
, , RENAME, .
, () a TIMES b b,
, ,
(-) b,
t, , t (-) , , , b.
,
, b, .
. , B . 7.3 (
, ,
). A TIMES (
)
.

. 7.3.

, X Y (, , ), 0
( , "=", "", ">", "<" ..), X Y X Y
(TRUE FALSE). 6-
( ) X Y ( ),

7.

253

, , , , ,
X Y TRUE.
a WHERE X Y
. ,
( ). . , X, Y, . . ., Z (, , ), , X, Y, . . ., Z. ,
,
, , , , ,
TRUE .
a WHERE p
""
, .. ,
. . 7.4 ( ).

. 7.4.
.
1. , WHERE, ,
; , , ,
9.
2. . ,
t
, t ( , , - , ),
. ,

254

II.
. 7.4, . , .

S WHERE ( ( SP RENAME S# AS X ) WHERE X = S# ) { P# } = P { P# }


,
.
3. .
a WHERE p1 OR p2 (a WHERE p1 ) UNION ( a WHERE p2 )
a WHERE p1 AND 2 ( a WHERE p1 ) INTERSECT ( a WHERE p2 )
a WHERE NOT ( ) a MINUS ( a WHERE p )

, , Y, . . ., Z (, ,
). X, , . . . ,
z,
{ X, Y,

..., Z }

, .
, { X, Y, . . . , z }.
{ , , . . . , z z }, X, Y... z Z.
,
"" , , ,
, ()
.
.
1.
(, ).
2. ,
, , "
" (.. ) . ,
"
#, PNAME, COLOR CITY", "
WEIGHT "
.
{ ALL BUT WEIGHT }
. 7.5. , ( CITY)
( " "),

7.

255

S . , , . ,
.

. ,
; , ,
.
.
( ,

, 3). , b, , .
X1,

2,

...,

Xm,

Y1,

Y2,

...,

Yn

Yl,

Y2,

...,

Yn,

Zl,

Z2,

...,

Zp

, Y, Yl, Y2 , . . . , Yn ( ),
, X1, 2, Xm,
b z, Z1, Z2, . .
. , Zp. .
,
RENAME xi (i = 1,
2, . . . , m) , z j (j = 1, 2,
. . . , ).
Yk ( = 1, 2, . . ., n)
, (
).
{ X I , 2 , . . . , X m } , { Y l, Y 2 , . . . , Y n } { Z l , Z 2 ,
. . ., Zp } , , , Y z.
() b .
a JOIN b
{ X, Y, Z } ,
{ X , Y , z z },
, Y, b,
Y z Z.
( s JOIN P
CITY) . 7.6.
. (
. 7.6), ,

256

II.


( ) , ,
.

. 7.5.

. 7.6. S JOIN P
, , . ,
.
= 0 ( , b ),
a JOIN b 2 a TIMES b.
m = p = 0 ( , b
), a JOIN b a INTERSECT b.
2
Tutorial D, [3.3],
TIMES.

7.

257

9-.
( , ), , . , b (.. );
X b , , y 8. 6- X b y .
( a TIMES b ) WHERE X 9
, , b, , t,
t , X TRUE t.
, "" s CITY CITY (,
0 ">", CITY CHAR, ">" " ").
.
( ( S RENAME CITY AS SCITY ) TIMES
( P RENAME CITY AS PCITY )
) WHERE SCITY > PCITY
, . (,
CITY;
.)
. 7.7.

. 7.7. ""
0 ("="), 0-
, .
,
, ,
.
,

258

II.

( ), ! , ( ).
S JOIN P
.
{ ( S TIMES ( P RENAME CITY AS PCITY ) ) WHERE CITY =
PCITY )
{ ALL BUT PCITY }
. Tutorial D 8-, (..
, ).

[7.4] "", , , (Small Divide) (Great Divide).


Tutorial D <divide>, <r>
<relation exp>, <divide>, <r> <relation exp>.
, ; [7.4].
,
;
, ,
. , .
. ,
b, , .
XI, 2,
m
Yl, Y2,

...,
...,

Yn

xi (i = 1, 2, . . ., m)
Yj (j = 1, 2, . . ., ).
:
XI,

2,

...,

Xm,

Yl,

Y2,

...,

Yn

, , (-) . { XI, 2, ..., }


{ Yl, Y2, . . ., Yn }, , Y.
b ( , , )
.
a DIVIDEBY b PER

7.

259

{ X } ,
{ X }, , , { , Y } { Y }, b. , , X, ,
Y Y b. , !
. 7.8 . (DEND)
S
S#; (MED) SP S# #; (DOR) , . , ,
, ,
; ( ) ,
. , DIVIDEBY ;
, ,
"" (, " ,
"), , . ( ,

, ,

. 8.)

. 7.8.

260

II

,
, ,
.
S WHERE ( ( SP RENAME S# AS X ) WHERE X = S# ) {
p# } =
P { P# }
,
, ,
. .
1.
( ( SP RENAME S# AS X ) WHERE X = S# ) { P# }
, .
2. .
3. ,
.
DIVIDEBY, .
S JOIN ( S { S# } DIVIDEBY P { # } PER SP { S#, P# } )
, . , , DIVIDEBY,
, ,
.
7.5.
.
, . 3.8 (. . 119).
7.5.1. , 2
{ ( SP JOIN S ) WHERE # = # ('2') ) { SNAME }
. SP S , SP
(..
SNAME, STATUS CITY).
, , 2.
, SNAME. , SNAME.*

7.

261

7.5.2. ,

{ ( ( WHERE COLOR = COLOR ('Red') )
JOIN SP ) { S# } JOIN S ) { SNAME }
SNAME. ,
, .
( (

( WHERE COLOR = COLOR ('Red') ) { P# }


JOIN SP ) JOIN S ) { SNAME }

, ,
. 18.
7.5.3. ,
( ( S { S# } DIVIDEBY { # } PER SP { S#, P# } )
JOIN S ) { SNAME }
.
( S WHERE
( ( SP RENAME S# AS X ) WHERE X = S# ) { P# } = P {
P# } )
{ SNAME }
, SNAME.
7.5.4. , ,
, , S2
S { S# } DIVIDEBY ( SP WHERE S# = S# ('S2') ) { P# }
PER SP { S#, P# }
, s#
7.5.5. ,

( ( ( S RENAME S# AS SA ) { SA, CITY }
JOIN ( S RENAME S# AS SB ) {SB,
CITY } ) WHERE SA < SB ) { SA, SB }
, SA SB ( S#,
, ). , s#
"<". SA < SB :
(, );
, , ( , ) , (,).

262

II.

, ,
WITH
, 3.
WITH ( S RENAME S#
AS SA ) { SA, CITY } AS Tl,
( S RENAME S#
AS SB ) { SB, CITY } AS T2,
Tl JOIN T2 AS
T3,
T3 WHERE SA <
SB
AS T4 :
T4 { SA, SB }
WITH , . , .
7.5.6. , 2
( ( S { S# } MINUS ( SP WHERE P# = P# ('P2') ) { S# } )
JOIN S ) { SNAME }
, SNAME.
,
. ,
.
. , ,
. 6 .
WITH S { S# } AS Tl,
SP WHERE P# = P# ('P2') AS
T2,
T2 { S# } AS T3,
Tl MINUS T3 AS T4,
T4 JOIN S AS T5,
T5 { SNAME } AS T6 :
T6
. , , WITH
(.. Ti),
, . ,
" " (, , PRTV [7.9]),
. ,
.
, ,
; , , ,
S.
, ,
( "").
3
, WITH
DIST (. 5.5 5), 6.5 6 UPDATE .

7.

263


- (.. T6).
6, 5
SNAME, 5; 5, 4 S,
4 .. ,
,
.

, 18
.
7.6.
.
, .. .
, , , , , ,
, , RENAME ( ,
, RENAME,
[7.1]). .
, , ( ),
. , , (. 7.6),
- . ,

( , ,
)4.
( ) ,
.
. , ,

4
. -, ,
, . -,
RENAME, (
[7.1]) , . -, [3.3]
" " , " ",
( RENAME
) , remove
() nor (" ").

264

II.

. . . , , , , .
(
).
, .. ,
(
).
, .. , , (. 6).
, .. ,
(. 9).
, .. , (. 10).
, .. ,

(. 16).
, .. , (.
17).
, (,
). , , , . ,
( ( SP JOIN S ) WHERE P# = # ('2') ) { SNAME }
" , 2" (.
7.5.1), , , , , .
( ( SP WHERE # = # ('2') ) JOIN S ) { SNAME }
(. ",
"? ""?)
,
( 3.5 3). ,

,
(
, ). 18.

7.

265

.
, .
, [7.1], , ,
, , .. , ( ,
).
.
7.7.
,
.

, UNION . , a, b ,
.
( a UNION b ) UNION

a UNION ( b
UNION )
UNION ;
.
a UNION b UNION
INTERSECT, TIMES JOIN (
MINUS). . ,
, , , UNION ( a , b , ), ,
Tutorial D. .
, UNION, INTERSECT, TIMES JOIN ( MINUS) . , .
a UNION
b
b UNION a
INTERSECT, TIMES JOIN.

18. TIMES , ,
, ,
, , (
) .

266

II.


,
.
r , a empty
, r.

r WHERE TRUE = r ( ).
r WHERE FALSE = empty.
r { X, Y, . . . , z } = r, x,Y,..., z r ( ).
r { } = TABLE_DUM, r = empty, TABLE_DEE ( ).
r JOIN r s r UNION r s r INTERSECT r = r.
r JOIN TABLE_DEE = TABLE_DEE JOIN r = r (.. TABLE_DEE , ,
,
).
rTIMES TABLE_DEE = TABLE_DEE TIMES r = r ( ).
r UNION empty = r MINUS empty = r.
empty INTERSECT r = empty MINUS r = empty.


JOIN, UNION INTERSECT
(.. )5; ,
, n- > 1.
= 1 = 0? , , , , "",
"" ""
( , Tutorial D ).
. , s ( RT).
.
s r,
, BS r.
s , :
s TABLE_DEE (
, );
5

MINUS . ,
.

7.
267
s RT;
s "" 6
RT, , RT, , RT.
7.8.
, ,
. SEMIJOIN, SEMIMINUS, EXTEND,
SUMMARIZE TCLOSE.
Tutorial D <nonproject>, , .
<semijoin>
::= <relation exp>
SEMIJOIN <relation exp>
<semiminus>
::= <relation exp> SEMIMINUS <relation exp>
<extend>
::= EXTEND <relation exp> ADD ( <extend
add commalist> )
commalist
<extend add>, .
<extend add>
<> AS <attribute
name>
<summarize>
: : = SUMMARIZE <relation exp> PER
<relation exp> ADD ( <summarize
add commalist> )
commalist
<summarize add>, .
<summarize add>
::= <summary type> [ ( <scalar exp>
) ] AS <attribute
name>
< summary type>
::= COUNT | SUM | AVG | MAX | MIN | ALL |
ANY | COUNTD | SUMD | AVGD | ...
<tclose>
: : = TCLOSE <relation exp>
<relation exp>, ,
<nonproject>.
6
, , " "
(., , [13.20]).

268

II.

, , b, X Y ,
"" 7.4. b
( ), a SEMIJOIN b, .
( a JOIN b ) { X, Y }
, b b, . , ,
, b.
. s#, SNAME, STATUS CITY , 2.
S SEMIJOIN ( SP WHERE P# = #

('2')

, , ,
,
; , SEMIJOIN.
SEMIMINUS (. ).

b ( ), a SEMIMINUS b, .
a MINUS ( a SEMIJOIN b )
, , ,
b.
. S#, SNAME, STATUS CITY , 2.
S SEMIMINUS

( SP WHERE # = #

('2')

,
, . ,
, . , , ,
WEIGHT * 454, WHERE (
7, , 5.4,
, 1 = 454 ).
EXTEND . ,
EXTEND , ,
7
, "*" .
. ?

7.

269

, ,
. ,
.
EXTEND P ADD ( WEIGHT * 454 ) AS GMWT
( , ,
)
, , , GMWT. , ,
GMWT,
WEIGHT * 454 (. 7.9).

. 7.9. EXTEND
. , EXTEND
; ,
, . ,

. ( , EXTEND ALTER TABLE . . . ADD COLUMN SQL .)
GMWT , .., ,
.
( ( EXTEND P ADD ( WEIGHT * 454 ) AS GMWT )
WHERE GMWT > WEIGHT ( 10000.0 ) ) { ALL BUT GMWT }
. , WHERE .
WHERE ( WEIGHT * 454 ) > WEIGHT ( 10000.0 )
(. , 7.4.)
.
, ,
EXTEND a ADD exp AS Z
, , .

270

II.
, Z.

t, t , z,
.
Z, z. , , , , . z .
.
1. EXTEND S ADD 'Supplier' AS TAG

S "Supplier" (, ,
, , , ,
).
2. EXTEND ( JOIN SP ) ADD ( WEIGHT * QTY ) AS SHIPWT
EXTEND , ,
.
3. ( EXTEND S ADD CITY AS SCITY ) { ALL BUT CITY }
, CITY, . , .
S RENAME CITY AS SCITY
, RENAME ! ,
EXTEND ( ). , , RENAME,
,
.
4. EXTEND P ADD {WEIGHT * 454 AS GMWT, WEIGHT * 16 AS OZWT)
"
EXTEND".
5. EXTEND S ADD COUNT ( ( SP RENAME Si AS X ) WHERE X =
S# ) AS NP
. 7.10.
.
) ( ( SP RENAME s# AS X ) WHERE
x = s# ) ,
.
)
COUNT
( ).

7.

271

, NP , ,
S#. NP
S5; S5
COUNT .

. 7.10. EXTEND
.
, ,
,
( ). COUNT, SUM, AVG, MAX, MIN, ALL ANY. Tutorial D
<agg op inv>
<scalar exp>, .
.
<agg op name> ( <relation exp> [, <attribute name> ] )
< > COUNT,
<attribute name> ; ,
<relation exp> ,

<relation exp>. .
SUM ( SP WHERE S# = S# ( ' S 1 ' ) , QTY SUM
( ( SP WHERE S# = S# ( ' S 1 ' ) ) { QTY }
)|
: S1, S1.
,
, COUNT ( )
SUM; MIN , , ; ALL ANY,
, TRUE FALSE, AVG .

272

II.

,
SUMMARIZE, , , . , , ,
.
,
,
", ".
, ",
". ,

SUMMARIZE SP PER P { # } ADD SUM ( QTY ) AS TOTQTY


# TOTQTY, # #,
# (. 7.11 ). , SP , (
),
.

. 7.11. SUMMARIZE
,
SUMMARIZE a PER b ADD summary AS Z
, , .
, b ,
(.. b
). , (
b) 1, 2, . . ., An.
b, Z.
t, t
b, z. Z
summary ,

7.

273

{ 1, 2, . . ., An },
t. (, { 1, 2, . . ., An }, t,
summary .)
b Z, summary
Z. , , b, , b . Z
summary.
.
SUMMARIZE ( JOIN SP ) PER P { CITY } ADD COUNT AS NSP
.

, , (, ); , .
.
1. , ,
.
2. "
SUMMARIZE", , .
SUMMARIZE SP PER P { # } ADD ( SUM ( QTY ) AS TOTQTY,
AVG ( QTY ) AS AVGQTY )
3. <sumnarize> ( )
.
SUMMARIZE <relation exp> PER <relation exp>
ADD ( <summarize add commalist> )
<summarize add>
, , .
<summary type> [

( <scalar exp> ) ] AS <attribute name>

<summary type> COUNT, SUM, AVG, MAX, MIN, ALL, ANY, COUNTD, SUMD AVGD. "D"
( "distinct" ) COUNTD, SUMD AVGD " ". <scalar exp>
, <relation exp>,

274

II.

SUMMARIZE. <scalar exp>


, <summary type> COUNT.
, , <summarize add> <agg op inv>. <agg op inv>
, .
, <summarize add>
SUMMARIZE; ,
SUMMARIZE
.
4. , SUMMARIZE , EXTEND. ,

SUMMARIZE SP PER S { S# } ADD COUNT AS NP
, .
( EXTEND S { S# }
ADD ( ( ( SP RENAME S# AS X ) WHERE X = S# ) AS Y,
COUNT ( Y ) AS NP ) ) { S#, NP }
.
WITH (
(
(
(
: T4 {

S { S# } ) AS Tl,
SP RENAME S# AS X ) AS T2,
EXTEND Tl ADD ( T2 WHERE X = S# ) AS Y ) AS T3,
EXTEND T3 ADD COUNT ( Y ) AS NP ) AS T4
S#, NP }

, Y . 6.4..
5. .
SUMMARIZE S PER S { CITY } ADD AVG ( STATUS ) AS AVG_STATUS
, PER,
" , " ,
, .
.
SUMMARIZE S BY { CITY } ADD AVG ( STATUS ) AS AVG_STATUS
PER <relation exp> BY <attribute
name commalist>. , ,
, , .
6. .

7.

275

SUMMARIZE SP PER SP { } ADD SUM ( QTY ) AS GRANDTOTAL


, ,
.
SUMMARIZE SP BY { } ADD SUM ( QTY ) AS GRANDTOTAL
, . , sp
SP, , sp .
sp , ,
( , - ),
, , ( ,

sp). , ;
GRANDTOTAL, QTY
sp.
, , sp , ,
(.. ).
, " " (..
, ), sp .
SUMMARIZE SP PER TABLE_DEE ADD SUM ( QTY ) AS GRANDTOTAL
, , GRANDTOTAL,
, . , ,
PER,
.
SUMMARIZE SP ADD SUM ( QTY ) AS GRANDTOTAL
, PER PER TABLE_DEE.

"Tclose" (transitive closure).
; .
. , X Y,
. ,
TCLOSE , + , ,
, , .

276

II.

{ X , Y }
+,
zl, z2, . . ., zn,
, .
{

X ,

Y zl

},

X z l,

Y z2

},

...,

X zn,

, , (, ) +, . ,
+ .
24.
7.9.
, , , , GROUP () UNGROUP (), , , ,
, , .
SP GROUP { #, QTY } AS PQ
, , ,
. 7.12.
.
, (
, ).
,
SP GROUP { P#, QTY } AS PQ
" SP s#", s# SP, GROUP. ,
.
-, , .
{ S# S#,

PQ RELATION { P# P#, QTY QTY }

, PQ ( PQ, , # QTY) SP (, " SP" s#).


-, s# SP ( ). s# (, s) PQ (, pq),
, .
SP (, ), #
QTY "" (,).

7.

277

, S# s,
"" , q,
s#, s, PQ, pq.

. 7.12. SP S#
,
. 7.12. ,
S5 ( SP). , R GROUP { 1, 2, . . ., An }
AS , nR - + 1, nR R. . , SPQ , . 7.12. ( ) SP,
.
SPQ UNGROUP PQ
, ,
.
-, , .
{ S# S#, P# P#, QTY QTY }
, # QTY (
PQ), SPQ (..

278

S#). -, SPQ PQ, SPQ


( ). S# (, s), # QTY (, q), , .
SPQ "" ,
(, ) PQ
SPQ.
S# (, s), S#
SPQ,
(, ), PQ,
SPQ.
, S# s, "
" # QTY (, q),
s#, s, #,
, QTY, q.
, , SP, .
, R UNGROUP ( ,
,
{ Al, A2, . . . , An }) , nR+n-1, nR
R.
, GROUP UNGROUP
,
"nest" ( ) "unnest" ( ).
(/), nest/unnest NF2 [6.10], .
,
GROUP UNGROUP ( ,
).
r ,
, r. r,
, r,
. ( ,
[6.4]). , TWO (. 7.13)
THREE. THREE
( RVX
), ONE, TWO.
ONE,
THREE, , THREE
ONE; ,

7.

279

.
, ONE RVX ( , ONE )8. , , r
RVX , r
RVX ,
:
r RVX ;
RVX r.

. 7.13. , ,
()
7.10.
.

,
.
RENAME.

, , , (
, , ), , , . ( , , ,
, , .) RENAME ( ), SEMI JOIN , SEMIMINUS , EXTEND
8

11 , , ,
, (
, ).

280

II.

SUMMARIZE,

TCLOSE GROUP
UNGROUP. ,
EXTEND ( , ).
,
(.. );
, . [7.3]
: " ... ... ,
"; , .
, , , "" , . ( , .) , (
7.6) [3.3] "
", ,

; , , RENAME, EXTEND, SUMMARIZE, GROUP, UNGROUP, , remove nor.
. , , ,
, . , ( 18).
, , WITH ; , , ,
.
, , (,
, R R R). , ,
,
.

7.

281

7.1. , , ,
?
7.2. .
s JOIN SP JOIN P? ?
(. !)
7.3. r . r?
7.4. , , , .
.
7.5. a JOIN b. b , a TIMES b,
, a INTERSECT b.
.
a JOIN b, b?
7.6.
(, , , ) . ,
( )
.
7.7.
. TIMES DIVIDEBY
?
7.8. , 1 0,
,
n * 1 = l * n = n
n * 0 = 0 * n = 0
( ) ? ,
, .
7.9. 7.2 ,
, .
,
. -
?

282

II.

7.10. ,
. ,
(..
)?
7.11. (
)?
) SUMMARIZE r PER r { } ADD COUNT AS .
) SUMMARIZE r ADD COUNT AS .
) SUMMARIZE r BY { } ADD COUNT AS CT.
) EXTEND TABLE_DEE ADD COUNT ( r ) AS CT.
7.12. , r , .
SP GROUP { } AS X
, r, SP. , .
r UNGROUP X

,
. . (
, , ,
.) ( ) .
S

{ S#, SNAME, STATUS, CITY


} PRIMARY KEY { S# }
P
{ P#, PNAME, COLOR, WEIGHT, CITY
} PRIMARY KEY { P# }
J
{ J#, JNAME, CITY
} PRIMARY KEY {
J# }
SPJ { S#, P#, J#, QTY }
PRIMARY KEY { S#, P#,j# }
FOREIGN
KEY
{
S#
}
REFERENCES S FOREIGN KEY {
P# } REFERENCES P FOREIGN
KEY { J# } REFERENCES J
7.13. . '
7.14. .
7.15. J1.

7.

283

7.16. ,
300 750 .
7.17. " -,
".
. "" ", ", " ".
7.18. "
", ,
.
7.19. " -
", ,
.
7.20. " -
", ,
.
7.21. , .
7.22. ,
.
7.23. ,
.
7.24. ,
, .
7.25. ,
.
7.26. ,
.
7.27. ,
S1.
7.28. 1,
S1.
7.29. , , ,
.
7.30. , ,
, 350 .
7.31. ,
S1.

284

II.

7.32. , si.
7.33. , ,
.
7.34. ,
, si.
7.35. ,
, .
7.36. , ,
s1.
7.37. , ,
.
7.38. ,
1 , ,
.
7.39. 1
, 1,
.
7.40. ,
.
7.41. ,
S1.
7.42. , .
7.43. .
7.44. , , ,
, S1.
7.45. , ,
.
7.46. , ,
.
7.47. " ", , .
7.48. (, Sx Sy), ,
.
.
, , .

7.

285

7.49. ""
, " - " .
7.50. "" ,
7.49.

7.1.

Codd. E.F. Relational Completeness of Data Base Sublanguages // Randall J. Rustin


(ed.). Data Base Systems, Courant Computer Science Symposia Series 6. Englewood
Cliffs, N.J.: Prentice-Hall, 1972.

( [6.1], ).
. . "
" , ,
, . (
, , " ...
, ". [6.1].)
RENAME
. ,

, SQL ( ) SQL.
8, 8.4.

7.2.

Darven H. ( Andrew Warden). Adventures in Relationland // Date


C.J. Relational Database Writings 1985-1989. Reading, Mass.: Addison-Wesley, 1990.
, ,

.

7.3.

Darven H. Valid Time and Transaction Time Proposals: Language Design Aspects //
Etzion O., Jajodia S., Sripada S. (eds.). Temporal Databases: Research and Practice. New
York, N.Y.: Springer-Verlag, 1998.

7.4.

Darwen H. and Date C.J. Into the Great Divide // Darwen H. and Date C.J. Relational
Database Writings 1989-1991. Reading, Mass.: Addison-Wesley, 1992.
,
[7.1], , (Hall), (Hitchcock) (Todd) [7.10], ,
,
. ( ,
.) , , ,

286

II.
, (..
, ). ("Small Divide", , "Great
Divide", ).
. Tutorial D, . , (
) .
"" ( . . 7.7).
, . , , {, Y}
{Y} ( X Y ).
A DIVIDEBY {X} ,
{ }, , {X , Y }
{Y }, .
, ,
X , Y (
) Y .

7.5.

C.J. Date. Quota Queries ( ) // Date C.J., Darven H., and McGoveran D.
Relational Database Writings 1994-1997. Reading, Mass.: Addison-Wesley, 1998.
(quota query) ,
. ,
" ". Tutorial D
.
QUOTA ( 3, DESC WEIGHT )
.
( EXTEND P
ADD COUNT ( ( RENAME WEIGHT AS WT ) WHERE WT > WEIGHT
) AS #_HEAVIER ) WHERE #_HEAVIER < 3 ) { ALL BUT
#_HEAVIER }
WT #_HEAVIER . , 2,
6. ,

, .
. [3.3] , , RANK.

7.6.

Goldstein R.C. and Strnad A.J. The MacAIMS Data Management System // Proc. 1970
ACM SICFIDET Workshop on Data Description and Access. November 1970.
. [7.7].

7.
7.7.

287

Strnad A.J. The Relational Approach to the Management of Data Bases // Proc. IFIP
Congress. Ljubljana, Yugoslavia. August 1971.
MacAIMS [7.6], [7.7] . , . ,

(, , ). , ,
MacAIMS .

7.8.

Notley M.G. The Peterlee IS/1 System // IBM UK Scientific Centre Report UKSC0018.-March 1972.
. [7.9].

7.9.

Todd S.J.P. The Peterlee Relational Test Vehicle A System Overview // IBM Sys. J.
1976. -15, 4.
Peterlee Relational Test Vehicle (PRTV) , IBM UK, , .
IS/1 [7.8], , ,
. n- ISBL (Information System Base Language
). , [7.10].
, , ISBL
[7.10]. PRTV .
RENAME, EXTEND SUMMARIZE.
(.
18).
, ,
(. WITH
).

.

7.10. Hall P.A.V., Hitchcock P., and Todd S.J.P. An Algebra of Relations for Machine
Computation // Conf. Record of the 2nd ACM Symposium on Principles of
Programming Languages. Palo Alto, Calif. January 1975.
7.11. Klug A. Equivalence of Relational Algebra and Relational Calculus Query Languages
Having Aggregate Functions // JACM 29. July 1982. 3.

(. 8),
,
.

8

8.1
8.2.
8.3.
8.4.
8.5.
8.6.
8.7.
8.8.
8.9.




SQL

8.1.

.
.
(, , ..), ,
,
,

. , : "
,
2".
(
, 7).
S S#.


, 2.

290

II.

s#
CITY.

.
s# CITY ,
SP s#
#, 2.

, , , .., . ,
, , , , . , ,
. ,
, ( ,
, ),
.
, , .
. ,
.
, - ,
:
, . , ,
, . ,
" " .
8.4 .
, . (Kuhns) [8.6].
, ..
, [6.1], [8.1]
, " ALPHA". ALPHA , QUEL [8.5], [8.10][8.12],
SQL, ALPHA,
QUEL.

. , , , .. ,
.
, v ,
"v" t .
, " , "
QUEL .

8.

291

RANGE OF SX IS S ;
RETRIEVE ( SX.S# ) WHERE SX.CITY = "London" ;
SX,
, S ( RANGE
). RETRIEVE : " SX S# ,
CITY London".
, ( ,
), . 8.2.
. : , , , (, - ).
(Lacroix) (Pirotte) [8.7]
, ,
, .. ,
, . ( , ,
.)
. , , QBE
(Query-By-Example ), [8.14];
QBE , .
QBE, "QBE-" .
8.7, QBE 8.8.
. ,
, ( ),
(. 7).
. [3.3].
8.2.
7, , (
) Tutorial D,
[3.3], .
, .

. , , ,
, .
.

292

II.

<rela tion exp>, 7.


<relation >
: : = RELATION { <tuple exp
commalist> } | <relvar name> |
<relation op inv> j <with exp> |
<introduced name> j ( <relation
exp> )
, <relation exp> ,
, <relation op inv>,
,
.
<range var def>
::= RANGEVAR <range var name>
RANGES OVER <relation exp commalist>

<range var name> < tuple exp>,


, :

<range attribute ref>;


<quantified bool exp>;
<1 >;
<proto tuple> <> (
<>) <proto tuple>.

<range attribute ref>


: : = <range var name> . <attribute
name>
AS <ttribute name> ]
<range attribute ref> <>,
, :
<bool >;
<proto tuple> <> ( <>) <proto tuple>.
<bool exp>
::= ... ,
| <quantified bool exp>
<bool >
<bool > ,
.

1
< tuple exp>, , , . ,
, .

8.

293

<bool > <relation


op inv> (.. <b1 > WHERE).
( )
<proto tuple>,
<relation op inv>
(.. <proto tuple>
WHERE).
. ( ) <1 >
(Well-Formed Formula WFF, ""). .
<quantified bool exp>
::= <quantifier> <range var name> ( <bool exp> )
<quantifier>
::= EXISTS | FORALL
<relation op inv>
: : = <proto tuple> [ WHERE <bool exp> ]

, 7, <relation op inv>
<relation exp>, ,
, .
<proto tuple>
::- . . . .
, <proto tuple>,
<proto tuple>.
. <proto tuple> "prototype tuple"
{-); , .

(
, , ).
RANGEVAR SX RANGES OVER S
; RANGEVAR SY RANGES OVER
S ; RANGEVAR SPX RANGES
OVER SP ; RANGEVAR SPY
RANGES OVER SP ; RANGEVAR
PX RANGES OVER P ;
RANGEVAR SU RANGES OVER
( SX WHERE SX.CITY = 'London' ) ,
( SX WHERE EXISTS SPX ( SPX.S# = SX.S# AND
SPX.P# = P# ('P1') ) ) ;

294

II.

SU , , 1. , SU sx SPX.
, , , , , .
.
( );
. , 3. , , 3, (
), , ,
.
, . ,
,
. ( , SQL).

( ,
) , .
, .
v , q .
.
v NOT p
, .
V ( AND q)
( OR q) , , ,
q.
V,
, EXISTS V (p)
FORALL V(p).

EXISTS V(p) FORALL v(p) ,
.
.
V <range var
name> V <range var name>.
V <range attribute
ref> V. <range a t tribu te ref>.

8.
295
V ,
",
, '
, .
,
.

SX.S# = S# {'S1')
SX.S# = SPX.S#
SPX.P# PX.P#
SX, SPX .
,
.WEIGHT < WEIGHT ( 15.5 ) AND PX.CITY = 'Oslo'
NOT ( SX.CITY = 'London' )
SX.S# = SPX.S# AND SPX.P# PX.P#
PX.COLOR = COLOR ('Red') OR PX.CITY = 'London'
sx, SPX .

EXISTS SPX ( SPX.S# = SX.S# AND SPX.P# =
P# ('P2') ) FORALL PX ( PX.COLOR = COLOR
('Red') )
SPX ,
SX . , "".

2: EXISTS FORALL. EXISTS


, a FORALL . , , v ,
EXISTS V (
)
FORALL V ( )
, V
. : "
V, ".
: " V".
, , V "
2
"" "quantum", , ,
"". EXISTS FORALL, , 3
(" ") V (" ").

296
II.
2003 ", , : "V " (, ). EXISTS V(p)
, TRUE {);
FORALL v(p) , FALSE {), .
EXISTS . , .
EXISTS SPX ( SPX.S# = SX.S# AND SPX.P# = P# ('P2') )
,
.
SP (, SPX),
, S#
SX. S# ( ), # SPX 2.
SPX . SX .
EXISTS
OR (). , , -, r
tl, t2, . . . , tm, -, V ,
, , , p(V)
, V ,

EXISTS V ( ( V ) )
.
FALSE OR ( tl } OR . . .

OR p ( tm )

, , R (.. =0), FALSE.


r, ( ).
( 1, 2,
3 ) ( 1,
2, 4 ) (
1, 3, 4
)
, , ,
, , , ,
INTEGER. .
EXISTS V ( V.C > 1 )
: TRUE
EXISTS V ( V.B > 3 )
: FALSE
EXISTS V ( V.A > 1 OR V.C = 4 ) : TRUE
FORALL, , .

8.

297

FORALL ( .COLOR = COLOR ('Red') )


.
, , ,
COLOR Red.
.
, EXISTS OR, FORALL AND (). , r, V
(V) , EXISTS, TO

FORALL V ( ( V ) )
.
TRUE AND p

( tl ) AND . . . AND p

( tm )

, , r ,
TRUE. R,
, , EXISTS. .
FORALL V ( V.A > 1 )
: FALSE
FORALL V ( V.B > 1 )
: TRUE
FORALL V ( V.A = 1 AND V.C > 2 ) : TRUE
. . ,
, .
FORALL V ( ) = NOT EXISTS V ( NOT p )
, " V "
, " V,
". , () " , ,
> " " , ,
, , > " ( , ).
FORALL,
EXISTS; , , (
). ,
.

, ,
.
EXISTS ( > 3. )

298

II.

,
. ,
.
,
(, ), 3. , ,
(, ). ,

EXISTS ( > 3)
, .
WFF.
EXISTS ( > 3 ) AND x <
, .
. . ,
WFF , .
EXISTS ( > 3 ) AND
< EXISTS ( > 3 )
AND <
, ,
, ,
. , , ,
, TRUE FALSE.
. , , . , , ..
, .
, , 3,
,
, . (, , , , ,
.)

<relation op inv>
<relation def>. 7.
.
<relation op inv>
: : = <proto tuple> [ WHERE <bool exp> ]
<proto tuple>
::= ... .

8.
299
, .
<proto tuple>

-.
WHERE
, (
) <proto tuple>.
,
<relation op inv> (" , ").
SX.S# WHERE SX.CITY = 'London'
SX - .
SX WHERE , ( )
<proto tuple> .
(" 2"; .
EXISTS "" ).
SX.SNAME WHERE EXISTS SPX ( SPX.S# = SX.S# AND
SPX.P# = P# ('P2') )
SX ,
SPX ( WHERE) , , -.
, ,
<relation op inv>, , , <proto tuple>,
, WHERE <bool >,
TRUE. ( WHERE , WHERE TRUE.) .
, - ,
( ,
),
(
AS ),
. ,
, , , . , .
)
, , .
) AS , , .

300

II.
, -
vi . Aj AS Bj, . , Vi, , ,
Aj, j .
V1, V2, ..., Vm ,
-, , ,
rl, r2, ..., rm. , r 1', r2', ..., rm'
, AS, a r'
r 1', r2', ..., rm'.
r r',
WHERE.
. , , WHERE;
WHERE .
, , ,
.
, <relation op
inv>, r Bj.
.

8.3.
.
( ).
7 (
).
8.3.1. , 20
{ SX.S#, SX.STATUS }
WHERE SX.CITY = 'Paris' AND SX.STATUS > 20
8.3.2. ,
( 7.5.5)
{ SX.S# AS SA, SY.S# AS SB }
WHERE SX.CITY = SY.CITY AND SX.S# < SY.S#
, AS - . , WHERE,
WHERE sx.s# < SY.S#, SA < SB.

8.

301

8.3.3. 2
( 7.5.1)
SX WHERE EXISTS SPX ( SPX.S# = SX.S# AND SPX.P# = P# ('P2') )
-. .
{ SX.S#, SX.SNAME, SX.STATUS, SX.CITY }
WHERE EXISTS SPX ( SPX.S# = SX.S# AND SPX.P# = P# ('P2') )
8.3.4.
( 7.5.2)
SX.SNAME
WHERE EXISTS SPX ( SX.S# = SPX.S# AND .
EXISTS PX ( PX.P# = SPX.P# AND
PX.COLOR = COLOR ('Red') ) )
( , ) .
SX.SNAME
WHERE EXISTS SPX ( EXISTS PX ( SX.S# = SPX.S# AND
SPX.P#
=
PX.P#
AND
PX.COLOR = COLOR ('Red')
) )
( )
( ) ,
,
. , , . ,
.
Q1 V1

( Q2 V2

( wff )

Q1 Q2 EXISTS,
FORALL.
.
Q1 V1 Q2 V2

( wff )

, .
SX.SNAME
WHERE EXISTS SPX EXISTS PX ( SX.S# = SPX.S# AND
SPX.P# = PX.P# AND
PX.COLOR
=
COLOR
('Red') )
-
.

302

II.

8.3.5. ,
S2
SX.SNAME
WHERE EXISTS SPX ( EXISTS SPY ( SX.S# = SPX.S# AND
SPX.P# = SPY.P# AND
SPY.S# = S# ('S2') )
)
8.3.6.
( 7.5.3)
SX.SNAME WHERE FORALL ( EXISTS SPX ( SPX.S# = SX.S# AND
SPX.P# = PX.P# ) )
KBaHTopaFORALL.
SX.SNAME WHERE NOT EXISTS PX ( NOT EXISTS SPX
( SPX.S# = SX.S# AND
SPX.P# = PX.P# ) )
8.3.7. ,
2 ( 7.5.6)
SX.SNAME WHERE NOT EXISTS SPX
( SPX.S# = SX.S# AND SPX.P# = P# ('P2') )
, 8.3.3.
8.3.8. , , ,
S2 ( 7.5.4)
SX.S# WHERE FORALL SPX ( SPX.S# S# ('S2') OR
EXISTS SPY ( SPY.S# = SX.S#
AND SPY.P# =
SPX.P# ) )
: "
sx, SPX, ,
S2 , SPY
SPX sx". ,
, ,
. q
,
IF p THEN q END IF
,
.
( NOT p ) OR q
,
.

8.

303

SX.S# WHERE FORALL SPX ( IF SPX.S# = S# ('S2') THEN


EXISTS SPY ( SPY.S# = SX.S# AND
SPY.P# = SPX.P#
) END IF )
: " SX, SPX, SPX S2, SPY , SPX, sx".
8.3.9. , 16 ,
S2
RANGEVAR PU RANGES OVER
( .# WHERE PX.WEIGHT > WEIGHT ( 16.0 ) ),
( SPX.P# WHERE SPX.S# = S# ('S2') )
; PU.P#

.
.
( ) ,
SP .
.# WHERE PX.WEIGHT > WEIGHT ( 16.0 )
OR EXISTS SPX ( SPX.P# = PX.P# AND
SPX.S# = S# ('S2') )
8.4.

, . .
[7.1] , , , ,
. ,
, .
, , , 3.
, , 4
. . 8.1
( . 4.5 4).

3
, [7.1], [8.2]. ,
,
, , . ,
, , , ,
, (., , [7.11]).

304

II.

. 8.1. , ( )
: " , ,
(Athens) 50 ". .
{ SX.SNAME, SX.CITY } WHERE EXISTS JX FORALL PX EXISTS SPJX
( JX.CITY = 'Athens'
AND JX.J# = SPJX.J#
AND PX.P# = SPJX.P#
AND SX.S# = SPJX.S#
AND SPJX.QTY > QTY (
50 ) )
SX, PX, JX SPJX , ,
, s, P, J SPJ. ,
, .
1.
(.. ), , . " , " ,
( 7), WHERE, ,
. .

8.

305

SX. s 5 .
. 6 .
JX. J, CITY = ' Athens'2 . .
SPJX. SPJ, QTY QTY (50) 24 .
2. , . .

( ..) 5*6*2*24 = 1 440 .


. .
( ), , , s# , , S, SPJ.
.
3. 2
" WHERE,
". .
JX.J# = SPJX.J# AND PX.P# = SPJX.P# AND SX.S# = SPJX.S#
,
s# s# ,
# #
, J#
J# .
, ( ) .

306

II.

( .)
4. .
EXISTS V ( v ,
r)
, r.
FORALL V
" , ",
V, .
r.j
.

(. [7.4]).
.
EXISTS JX FORALL PX EXISTS SPJX
, .
EXISTS SPJX.
SPJ ( SPJ . S#, SPJ.P#, SPJ. J# SPJ.QTY).
,

FORALL PX. .
.

EXISTS JX. J
(J. J#, J. JNAME J. CITY). .

8.

307

5. 4
-. - .
(SX.SNAME, SX.CITY)
, .

, , ,
, ,
(!).
. , (. 18, , [18.4]).
, .
, ( ) ,
. ,
. , , ( QUEL),
, ,
. , , , . , , , , , . (
, 18.)
, .
7, 7.6,
.
, , ,
, , . , , , ,
[7.1]. ( 7 ,
" " " ", , , , . , ,
.)

. ,
,

308

II.

. , , , .
, , ,
L , ,
L (
, )
L L
( ). SQL , (. 8.9). QUEL
. ,
, , .
,
.
,
- . , , , .. .
,
EXTEND SUMMARIZE ( 7).
, , .
. , , , , ,
. :
, , , , .
, , (Ullman)
[8.13]. ,
.
8.5.
, , EXTEND SUMMARIZE
.
- < tuple se
lector inv> (" "),
.
<1 >
.
7, <agg op
inv> (" ")
<relation exp>.

8.

309

, ; (
).
8.5.1. ,
10 000
{ .#, .WEIGHT * 454 AS GMWT }
WHERE PX.WEIGHT * 454 > WEIGHT ( 10000.0 )
, AS - (
8.3.2) .
WHERE . WEIGHT * 454
.
8.5.2.
"Supplier"
{ SX,

'Supplier' AS TAG }

8.5.3. ,

{ SPX, PX.WEIGHT * SPX.QTY AS SHIPWT } WHERE PX.P# = SPX.P#


8.5.4.

{ .#,

SIM ( SPX WHERE SPX.P# = PX.P#,

QTY )

AS TOTQTY }

8.5.5.
SUM ( SPX, QTY ) AS GRANDTOTAL
8.5.6.

{ SX.S#, COUNT ( SPX WHERE SPX.S# = SX.S# ) AS #_OF_PARTS }
8.5.7. , ,

RANGEVAR PY RANGES OVER P ;
PX.CITY WHERE COUNT ( PY WHERE PY.CITY = PX.CITY
AND PY.COLOR = COLOR ('Red') ) > 5
8.6. SQL
8.4, , . SQL?
, " , , , ...".

310

II.

SQL ,
, [4.8]. ,
IN <subquery> (. 8.6.10,
). , SQL , , 4.
, SQL - , -
, - . ,
7 SQL . ( ,
SQL , , ,
.)
SQL < table exp>,
.
, , .
SQL , 4 (.
. 4.1).
8.6.1. ,
10 ,
SELECT
FROM
WHERE
AND

PX.COLOR, PX.CITY
P AS PX
PX.CITY <> 'Paris'
PX.WEIGHT > WEIGHT ( 10.0 ) ;

.
1. 5, SQL
"". " " "
", , "< = " ">=".
2. AS PX FROM
( ) ,
. (
!) ,
, , ,
, ,
(. 8.6.12).

4
, [4.19], IN <subquery> ! ,
, "
" (Structured Query Language), ""
(Structured). ,
SQL,
.

8.

311

3. SQL
, .
SELECT P.COLOR, P.CITY
FROM
P
WHERE P.CITY <> 'Paris'
AND
P.WEIGHT > WEIGHT { 10.0 ) ;
, ,
(, ,
). ,
FROM P
FROM P AS P. , ,
() P.COLOR WHERE
SELECT , ,
.
4. 4,
, .
SELECT COLOR, CITY
FROM P
WHERE CITY <> 'Paris'
AND WEIGHT > WEIGHT ( 10.0 ) ;
SQL,
, . ( !) ,
. , ,
! , 5
ORDER BY (. ).
5. SQL ORDER BY,
4 DECLARE CURSOR,
.
SELECT P.COLOR, P.CITY
FROM

WHERE P.CITY <> 'Paris'


AND
P.WEIGHT > WEIGHT ( 10.0 )
ORDER BY CITY DESC ; /*
6. , SELECT *,
4.
SELECT
FROM
WHERE
AND

*
P
P.CITY <> 'Paris'
P.WEIGHT > WEIGHT ( 10.0 )

, 4.6 4.

312

II.
"*" SELECT * ( ),
FROM.
, (
). ,
,
.
SQL (.. SQL,
) ,
"*"
(,
ALTER TABLE).

7. { !) , , , , . SQL
SELECT,
DISTINCT, .
SELECT
FROM
WHERE
AND

DISTINCT P.COLOR, P.CITY


P
P.CITY <> 'Paris'
P.WEIGHT > WEIGHT ( 10.0 ) ;

, .
( 6),
SQL ,
, SQL ( ) , a
(
). , SQL .
, SQL
,
,
. ,
, (,
, [6.6]), SQL.
8.6.2. (
8.5.1)
SELECT .#, P.WEIGHT * 454 AS
GMWT FROM
P ;
AS GMWT " ". , # GMWT. AS GMWT , ;
. ,
SQL , .

8.

313

8.6.3. ,

SQL . .
1. SELECT S.*, P.P#, P.PNAME, P.COLOR, P.WEIGHT
FROM
S,
WHERE S.CITY = P.CITY ;
2. S JOIN P USING CITY ;
3. S NATURAL JOIN P ;
6 S (
CITY).
. ,
,
SQL ( JOIN SQL: 1992).
.
-, FROM S TIMES P. ( ,
.
. , , 7.7,
t t.)
-, WHERE
, CITY
( , ).
-, SELECT
, SELECT. .
, , SQL FROM
, WHERE ,
SELECT-FROM-WHERE, , (,
, "" ).
8.6.4. , ,
, ,
SELECT DISTINCT S.CITY AS SCITY, P.CITY AS
PCITY FROM
S JOIN SP USING S# JOIN P USING
P# ;
,
(, ).
6
SQL:2003, -, , "SELECT * FROM".

314

II.
SELECT DISTINCT S.CITY AS SCITY, P.CITY AS PCITY FROM
NATURAL JOIN SP NATURAL JOIN P ;

. CITY ,
.
8.6.5. ,
(. 8.3.2)
SELECT A.S# AS SA, B.S# AS
SB FROM
S AS A, S AS
WHERE A.CITY = B.CITY AND
A.S# < B.S# ;
. , SA SB , WR.
8.6.6.
SELECT COUNT(*) AS
N FROM
S ;
, N,
, 5. SQL 7: COUNT, SUM, AVG, MAX, MIN, EVERY ANY.
SQL, .
. DISTINCT (, SUM (DISTINCT
QTY) ), ,
. MAX, MIN, EVERY ANY DISTINCT .
COUNT(*)
DISTINCT
.
( 19)
,
DISTINCT,
COUNT (*), ,
.
, COUNT ,
.
7
EVERY - ALL SQL ( ALL ). ANY SOME. , SQL/OLAP, SQL " " (. 22).

8.

315

. COUNT,
. , 8.2, EVERY
TRUE,
.
8.6.7.
2
SELECT ( SP.QTY ) AS MAXQ, MIN ( SP.QTY ) AS MINQ
FROM
SP
WHERE SP.P# = P# ('P2') ;
, FROM WHERE,
. ,
, . , , .

, 8 SQL. ,
, , , " ", . ,
.
SELECT AVG ( SUM ( SP.QTY ) ) /* !
! */ FROM
SP ;
, , .
SELECT AVG ( X )
FROM ( SELECT SUM ( SP.QTY ) AS X
FROM
SP
GROUP BY SP.S# ) AS POINTLESS ;
GROUP BY , , FROM,
.
. AS POINTLESS , SQL (
[4.20]).
8.6.8.
( 8.5.4)
SELECT SP.P#, SUM ( SP.QTY ) AS TOTQTY
FROM
SP
GROUP BY SP.P# ;
8

. ,
. , , ,
, .

316

II.

SQL .
SUMMARIZE SP BY { # } ADD SUM ( QTY ) AS TOTQTY
.
( SPX.P#, SUM ( SPY WHERE SPY.P# = SPX.P#, QTY ) AS TOTQTY )
, , GROUP BY,
SELECT .
( ) .
SELECT P.P#,
FROM P ;

WHERE

( SELECT SUM ( SP.QTY )


FROM
SP
SP.P# = P.P# ) AS TOTQTY

, , .
, GROUP BY. (, , TOTQTY
, .)
8.6.9. ,

SELECT SP.P#
FROM
SP
GROUP BY SP.P#
HAVING COUNT ( SP.S# ) > 1 ;
HAVING ,
WHERE . , HAVING
, WHERE . HAVING
.
8.6.10. 2 (. 7.5.1)
SELECT DISTINCT S.SNAME
FROM S
WHERE S.S# IN
( SELECT SP.S#
FROM
SP
. . .
WHERE SP.P# = P# ('P2') ) ;
. WHERE . , SELECT-FROMWHERE-GROUP BY-HAVING, .
,

8.

317

IN ,
. , ( , ).
2, , {S1,S2,S3,S4}.
, , .
SELECT DISTINCT S.SNAME
FROM
S
WHERE S . S IN ( S # ( ' S 1 ) ' , S # ( ' S 2 1 ) ,

S#('S3'),

S#('S4')

, " 2" ,
, .
SELECT
FROM
WHERE
AND

DISTINCT S.SNAME
S, SP
S.S# = SP.S#
SP.P# = P# ('P2') ;

8.6.11.
(. 8.3.4)
SELECT DISTINCT
S.SNAME FROM
S WHERE
S.S# IN
( SELECT SP.S#
FROM
SP
WHERE SP.P# IN
( SELECT P.P# FROM
P
WHERE P. COLOR = COLOR ( ' Red' ) ) )
;
. .
.
8.6.12. , ,
S
SELECT
FROM
WHERE
(

S.S#
S
S.STATUS <
SELECT MAX (
S.STATUS ) FROM
;

S )

,
S S.
8.6.13. 2
. 8.6.10. ,
SQL.

318

II.

SELECT DISTINCT
S.SNAME FROM
S
WHERE EXISTS
( SELECT *
FROM
SP
WHERE SP.S# = S . S #
AND
SP.P# = P# ( ' P 2 ' )

);

. EXISTS (SELECT ... FROM ...) SQL TRUE , SELECT ...


FROM ... . , SQL EXISTS
( ;
. [19.6]).
. SQL ,
, (correlated subquery),
(
S),
. 8.6.8.
8.6.14. ,
2 ( 8.3.7)
SELECT DISTINCT S.SNAME
FROM
S
WHERE NOT EXISTS
( SELECT *
FROM
SP
WHERE SP.S# = S.S# AND
SP.P# = P# ('P2') ) ;
.
SELECT DISTINCT
S.SNAME FROM
S
WHERE S.S# NOT IN
( SELECT SP.S#
FROM
SP
= P# ( ' P2 ' ) ) ;

WHERE SP.P#

8.6.15. ,
(. 8.3.6)
SELECT DISTINCT
S.SNAME FROM
S
WHERE NOT EXISTS
(
SELECT * FROM
P
WHERE NOT EXISTS
( SELECT *
FROM SP
WHERE SP.S# = S.S#
AND
SP.P# = P.P# ) ) ;

8.

319

SQL - FORALL; , " FORALL"


, .
, , ,
, , , [8.4]. , , ""
, . ,
, .
SELECT DISTINCT S.SNAME
FROM
S
WHERE ( SELECT COUNT ( SP.P# )
FROM
SP
WHERE SP.S# = S.S# )
= ( SELECT COUNT ( P.P#
)
FROM
P ) ;
(: " , ".) ,
( NOT EXISTS)
, . , , ( ).
.
,
.
SELECT DISTINCT S.SNAME /* !
! */
FROM
S
WHERE { SELECT SP.P#
FROM
SP
WHERE SP.S# = S.S#
) = ( SELECT P.P#
FROM
P ) ;
SQL , , ( , ,
, , , ). . 8.11.
8.6.16. , 16 ,
S2, ,
(. 8.3.9)
SELECT P.P#
FROM P
WHERE P.WEIGHT > WEIGHT ( 16.0 )
UNION

320

II.

SELECT SP.P#
FROM
SP
WHERE SP.S# = S# ('S2') ;
UNION, INTERSECT EXCEPT ( SQL EXCEPT
MINUS ). SQL ( UNION ALL , INTERSECT ALL
EXCEPT ALL), ( ) . .
8.6.17.
> 10 000 (. 8.5.1)
SELECT P.P#, P.WEIGHT * 454 AS GMWT
FROM
P
WHERE P.WEIGHT * 454 > WEIGHT ( 10000.0 ) ;
WITH,
5 9 7.
, WITH
. SQL WITH, . P.WEIGHT *
454, .
WITH Tl AS ( SELECT P.P#, P.WEIGHT * 454 AS GMWT
FROM
P )
SELECT T1.P#, Tl.GMWT FROM
Tl
WHERE Tl.GMWT > WEIGHT ( 10000.0
) ;
, , WITH (
<name intro> ) SQL
<name> AS (<>), Tutorial D <> AS <name>. , WITH ,
SQL TCLOSE.
,
. 4.6, .
SQL .
, SQL . SQL
[4.19] , , , , . (
.)
9

, .

8.

321

8.7.
8.1, , (),
. , <bool >, (membership condition).
.
R { <pair commalist> }
R , <pair> ,
R,
( ). ,
TRUE , R , <pair> =
TRUE . ,
.
SP

S#

S # ( ' S 1 ' ),

#(' P 1 ' )

,
, , , s# si, # 1.
,
SP { S# SX, # }
TRUE

TRUE , ,
, S#
SX ( ), # ( ,
).
, , . 8.1.

8.1. ,
.

322

II.

SX
SX WHERE S { S# SX }
SX WHERE S { S# SX, CITY 'London' }
{ SX, CITYX } WHERE S { S# SX, CITY CITYX }
AND
SP { S# SX, P# P#('P2') }
{ SX, PX } WHERE S { S# SX, CITY
CITYX } AND P { P# PX,
CITY CITYY } AND
CITYX
CITYY
,
S,
. "
, 2" (,
). " ,
, ".
8.3,
( ).
8.7.1. 20
( 8.3.1)
SX WHERE EXISTS STATUSX
{ STATUSX > 20 AND
S { S# SX, STATUS STATUSX, CITY 'Paris' } )
, , ( ,
). , , , , .
8.7.2. ,
(. 8.3.2)
{ SX AS SA, SY AS SB } WHERE EXISTS CITYZ
( S { S# SX, CITY CITYZ }
AND S { S# SY, CITY CITYZ
} AND SX < SY )
8.7.3. (.
8.3.4)
NAMEX WHERE EXISTS SX EXISTS PX
( S { S# SX, SNAME
NAMEX }
AND SP { S#
SX, P# PX }
AND P { P# PX, COLOR COLOR('Red') } 1

8.

323

8.7.4. ,
, S2 (. 8.3.5)
NAMEX WHERE EXISTS
SX EXISTS PX
( S { S#SX, SNAME NAMEX }
AND SP
{ S# SX, P# PX }
AND SP { S# S#('S2'), P# PX } )
8.7.5. ,
(. 8.3.6)
NAMEX WHERE EXISTS SX ( S { S# SX, SNAME
NAMEX } AND FORALL PX ( IF P { P#
PX }
THEN SP { S# SX, P# PX
} END IF )
8.7.6. ,
2 (. 8.3.7)
NAMEX WHERE EXISTS SX ( S { S# SX, SNAME
NAMEX } AND NOT SP { S# SX, P#
P#('P2') } )
8.7.7. , , ,
, S2
(. 8.3.8)
SX WHERE FORALL PX ( IF SP { S# S#('S2'), P#
PX } THEN SP { S# SX, P#
PX } END IF )
8.7.8. , 16 ,
S2, ,
(. 8.3.9)
PX WHERE EXISTS WEIGHTX
( { # PX, WEIGHT WEIGHTX }
AND WEIGHTX > WEIGHT ( 16.0 )
) OR SP { S# S#('S2'), P# PX }
, , (.. ). , , (Ullman) [8.13].
8.8.
,
, (Query-By-Example QBE) [8.14]. ( QBE , .)
; . , QBE : " ,

324

II.

, S2"
.

.
( ), .
, , (.. ); .
("." present) (_NX), , _sx, _sx _,
_, , S2. QBE
(.
8.3.5 8.7.4) ,
10; , QBE
.
QBE SQL ( ).
, QBE. QBE , .
8.8.1. , ,
> 20 ( 8.7.1)

, ">"
"=". , , ( , P._sx). , , , Paris, , (
, , ,
).
"." , ,
.

10

, QUEL (., , [8.5]).

8.

325

, "." .

:
, ,
, .
, , ; ,
, .
, QBE
SNAME .

,
.
8.8.2. ,

UNQ. unique (
DISTINCT SQL).
8.8.3. ,
,
,

"." , a "DO." .
; STATUS , a s# .

326

II.

8.8.4. ,
, > 20,
( 8.8.1)
, ,
"" (., , 8.8.1).
"", ,
.

(condition box), .

,
(, ,
, ).
8.8.5. , 16 19

8.8.6. (
8.6.2)

8.8.7. , 2
( 7.5.1)

SP .
, .
SX, , , SX 2.

8.

327

, QBE EXISTS
( ,
, , , QBE
).
11 NOT EXISTS.
(, " , "
. 8.7.5) QBE,
.
8.8.8. ,
,
( 8.6.3)

: S
( ) .
, ,
. , .
, , SX
, SX, .
8.8.9. ,
( 8.6.5)

_SX < _SY .


8.8.10. 2

QBE .
11

, .
. QBE "" NOT
EXISTS, . ,
, , , ,
, - NOT. QBE
. [8.3]. . . 8.2.

328

II.

8.8.11.
( 8.6.8)

"G. " ( GROUP BY


SQL).
8.8.12. ,

8.8.13. , 16 ,
S2, ,
( 8.7.8).

8.8.14. 7 ( , 24,
)

, "I. " , .
. , ( ); , .
. .
8.8.15. ,
300

"D. " .

8.

329

8.8.16. 2 ,

8.8.17. , ,

8.9.
, . :
, ,
,
.
: . ,
,
.
-
WHERE,
(Well-Formed Formula WFF). (EXISTS FORALL), , () (AND, OR, NOT .) .. , ,
-.
. , ,
(. 7.6 7).
,

,
.
, , ,
.
, ,
(
EXTEND SUMMARIZE).
SQL. SQL
().
, ,
,
.

330

II.

SQL . ,
,
UNION, INTERSECT
EXCEPT. ORDER BY
,
( ).
, .
SELECT,
DISTINCT, ,
SELECT *.
FROM, .
WHERE, EXISTS.
GROUP BY HAVING,
COUNT, SUM, AVG ..
() 12 SELECT, FROM WHERE.
, SQL ( ). ,
, FROM, ,
WHERE, ,
, SELECT.
, ;
[4.20].
, , . , ,
. , ,
, -, .

8.1. () q , , ,
. ? ( "=>" "", "" "". ,
=> B B => , .)
12

, FROM , SELECT ,
WHERE , (!).

8.

331

) EXISTS ( q ) q
) FORALL { q ) q

8.2.

EXISTS x ( p (x) AND q ) EXISTS x ( p (x) ) AND q

FORALL x ( p (x) AND q ) FORALL x ( p (x) ) AND q

FORALL x ( p (x) ) => EXISTS x ( p (x) )

e)

EXISTS x ( TRUE ) s TRUE

FORALL x ( FALSE ) s FALSE

p (x, )
. ?
) EXISTS EXISTS ( (,) ) EXISTS EXISTS ( (,) )
) FORALL FORALL ( (,) ) FORALL FORALL x ( (,) )
) FORALL ( (,) ) NOT EXISTS x ( NOT p(x,y) )
) EXISTS x ( (,) ) NOT FORALL x ( NOT (,) )
) EXISTS x FORALL ( (,) ) FORALL EXISTS x ( (,) )
) EXISTS FORALL ( (,) ) => FORALL x EXISTS ( (,) )

8.3.

() q(y) ,
, .
?
) EXISTS ( () )
EXISTS x EXISTS
) EXISTS x ( IF p(x)
IF FORALL x ( p(x)

8.4.

AND EXISTS { q(y) )


( p(x) AND q(y) )
THEN q(x) END IF ) e
) THEN EXISTS x ( q(x) ) END IF

" , ,
, S2".
.

SX.S# WHERE FORALL SPY ( IF SPY.S# = S# ( ' S2') THEN


EXISTS SPZ ( SPZ.S# = SX.S# AND
SPZ.P# = SPY.P# )
END IF )
( SPZ ,
.) ,
S2 ?
, SX SPX?
8.5.

,
(
).

832

II.
{ PX.PNAME, PX.CITY } WHERE FORALL SX FORALL JX EXISTS SPJX
( SX.CITY = 'London' AND
JX.CITY = 'Paris' AND
SPJX.S# = SX.S# AND
SPJX.P# = PX.P# AND
SPJX.J# = JX.J# AND
SPJX.QTY < QTY { 500 )
)
) .
) . - ,
?

8.6.

"
".

8.7.


PART_STRUCTURE, . 4.6 4.
" ,

(, 1)". ,
PART_BILL (, , ,
PART_STRUCTURE),
( ).
, PART_BILL
(
). , .

8.8.

, S
LS, PS, AS ..,
(, LS
). , ,
, ,
, .
" S1?".
( )? .

8.9.

, SQL .

8.10. SQL EXTEND


SUMMARIZE?
8.11. SQL ?
8.12. SQL
" 2".

8.

333


, . , . ( , , , .)
8.13. . 7.137.50 .
8.14. . 7.13-7.50, SQL.
8.15. . 7.137.50 .
8.16. . 7.13-7.50, QBE.

8.1.

8.2.

8.3.
8.4.

8.5.

Codd E.F. A Data Base Sublanguage Founded on the Relational Calculus // Proc. 1971
ACM SIGFIDET Workshop on Data Description, Access and Control. San Diego,
Calif. November 1971.
Date C.J. A Note on the Relation Calculus // ACM SIGMOD Record 18. 1989.
4. : An Anomaly in Codd's Reduction Algorithm // C.J. Date and Hugh
Darwen. Relational Database Writings 19891991. Reading, Mass.: Addison-Wesley,
1992.
Date C.J. Why Quantifier Order Is Important // C.J. Date and Hugh Darwen. Relational
Database Writings 1989-1991. Reading, Mass.: Addison-Wesley, 1992.
Date C.J. Relational Calculus as an Aid to Effective Query Formulation // C.J. Date and
Hugh Darwen. Relational Database Writings 19891991. Reading, Mass.: AddisonWesley, 1992.
SQL, ( ).
, , ( ) SQL.
Held G.D., Stonebraker M.R., and Wong E. INGRES A Relational Data Base System
// Proc. NCC 44. Anaheim, Calif. Montvale, N.J.: AFIPS Press, May 1975.
1970-
: System R IBM Ingres ( , INGRES) ( ).
, DB2 ( System R)
Ingres ( Ingres).
. Ingres "University Ingres" [8.11], .
[1.5].

334

II.
Ingres SQL, QUEL (Query Language),
SQL. , QUEL - ,
QUEL . ,
Ingres, QUEL. . [8.10][8.12].

8.6.

Kuhns J.L. Answering Questions by Computer: A Logical Study // Report RM-5428-PR,


Rand Corp. Santa Monica, Calif., 1967.

8.7.

Lacrorix M., Pirotte A. Domain-Oriented Relational Languages // Proc. 3rd Int. Conf.
on Very Large Data Bases. Tokyo, Japan., October 1977.

8.8.

Merrett .. The Extended Relational Algebra, A Basis for Query Languages //


Shneiderman B. (ed.). Databases: Improving Usability and Responsiveness. New York,
N.Y.: Academic Press., 1978.
, ,
EXISTS FORALL,
, "" "".
, " ", "
", " " ..

8.9.

Negri , Pelagatti G., Sbattella L. Formal Semantics of SQL Queries // ACM


TODS. - September 1991. - 16, 3.
: " SQL
,
SQL ,
(Extended Three Valued Predicate Calculus E3VPC),
.
E3VPC ;
[] , SQL". , SQL, ( 1986 ).
. ,
, 19 18.

8.10. Stonebraker M. (ed.) The INGRES Papers: The Anatomy of a Relational Database
Management System // Reading, Mass.: Addison-Wesley, 1986.
"University Ingres",
, .
8.11. Stonebraker M., Wong E., Kreps P., Held G. The Design Implementation of INGRES //
ACM TODS. September, 1976. 1, 3. ( [8.10].)
"University Ingres".
8.12. Stonebraker M. Retrospection on a Data Base System // ACM TODS. 1980. 5,
2. ( [8.10].)

8.

335

Ingres ( 1979 ).
, .
8.13. Ullman J. D. Principles of Database and Knowledge-Base Systems: Volume I. Rockville,
Md.: Computer Science Press, 1988.
, , . ,
.
, , ,

WHERE. "
", , .
X WHERE X S AND X.CITY = 'London'
() , , , , .
X WHERE NOT ( X S )
, ( , S, ).
, ,
. ( , ) . ,
.
8.14. Zloof M. M. Query By Example // Proc. NCC 44. Anaheim, Calif., 1975.
Montvale, N.J.: AFIPS Press, 1977.
( ) QBE.
, .

9

9.1.
9.2.
9.3.
9.4.
9.5.
9.6.
9.7.
9.8.
9.9.
9.10.
9.11
9.12.
9.13.

( )
SQL

9.1.
,
, (,
" ", ).

( ).
(
) ,
;
,
.
,
,
( -
).

338

II.

, , ,
, ,
TRUE. - [9.15],
- (
) .
, -, .
1. 1 100
.
2. 20.
3. - ,
.
4. .
5. .
6. 20
500.
.
, ,
.
,

, , , . , , Tutorial D.
CONSTRAINT SC1
IS_EMPTY ( S WHERE STATUS < 1 OR STATUS > 100 ) ;
,

[9.5].
, , . , ;
(.. ) . ,
, SCI ("suppliers
constraint one" ). ,
, ,
, .
1, Tutorial D
( SX , ).

9.

339

CONSTRAINT SC1
NOT EXISTS SX ( SX.STATUS < 1 OR SX.STATUS > 100 ) ;
CONSTRAINT SC1
FORALL SX ( SX.STATUS > 1 AND SX.STATUS < 100 ) ;
, .
, , ,
.
, .
,
, . .
DROP CONSTRAINT <constraint name> ;
9.2.
, ,
, , 1. , , , ( , ,
, , , ). , S () , ,
, s#
( s#), SNAME (
NAME) ..
, ,
; , ,
9.1, .
1.
1 100
.
.
s , s 1 100 .
( )
2.
1
, ( ,
) .
.
2
,
Tutorial D ( Tutorial D ). ,
, 8,
( , ).

340

II.
FORALL s# S#, sn NAME, st INTEGER, sc CHAR (
IF { S# s#, SNAME sn, STATUS St, CITY sc } S THEN St
1 AND st 100 )

(
).
si, sn, st sc, :
Si si, SNAME sn, STATUS st CITY sc, st
1 100.
, , 1 , . ,
,
, "" ( ),
.
(IF)
, ('THEN,)
.
"" ( ), .
8; .
IF p THEN q
q , ,
. (.. ) ,
, a q , ; , IF THEN q (NOT ) OR q.
, ,
FORALL, " (IF) ...
" " (FORALL) , ...".
26 (
).
. , ,
, , . ,
.
2. 20.
FORALL s# S#, sn NAME, st INTEGER, sc
CHAR ( IF { S# s#, SNAME sn, STATUS st,
CITY sc } S THEN ( IF sc = 'London' THEN
st = 20 ) )
.

9.

341

3. - ,
.
IF
EXISTS # #, pn NAME, p1 COLOR, pw WEIGHT, pc CHAR
( { # #, PNAME pn, COLOR pi, WEIGHT pw, CITY pc }
) THEN
EXISTS p# P #, pn NAME , p1 COLOR , pw WEIGHT , pc CHAR
( { P# p#, PNAME pn, COLOR p1, WEIGHT pw, CITY pc }
P AND p1 = COLOR ('Blue') )
, "
", ,
.
. ,
, .
, .
FORALL # P#, pn NAME, p1 COLOR, pw WEIGHT, pc
CHAR ( IF { P# p#, PNAME pn, COLOR p1, WEIGHT pw, CITY pc
} P THEN EXISTS q# P#, qn NAME, ql COLOR,
qw WEIGHT, qc CHAR
( { P# q#, PNAME qn, COLOR ql,
WEIGHT qw, CITY qc } G P
AND ql = COLOR ('Blue') ) )
4. ,
FORALL x# G S#, xn G NAME, xt G INTEGER, xc G CHAR,
y# G S#, yn G NAME, yt G INTEGER, yc G CHAR ( IF
{ S# x#, SNAME xn, STATUS xt, CITY xc } G S AND
{ S# y#, SNAME yn, STATUS yt, CITY yc } G S THEN (
IF x# = y# THEN xn = yn AND xt = yt AND xc = yc ) )
,
{S#} (, , )
; ,
. KEY {S#}
Tutorial D
. (, .
, ,
,
, ,
.)
. ,
9.10.
, , .
(IF) , (THEN)
.

342

II.
2 3, ,
1 ( , 5). , 6 .

(IF)
, (THEN)
.
, (
).
5. .
FORALL s# S#, # #, q e QTY
( IF { S# s#, P# p#, QTY q }
SP
THEN EXISTS sn NAME, st INTEGER, sc CHAR
( { S# S#, SNAME sn, STATUS st, CITY SC } S ) )
, {S#}
,
{S#} . ( 9.10). ,
, SP S, 14 3.
6. 20
500.
FORALL s# e
S#, sn NAME, st INTEGER, sc CHAR,
p# P#, q QTY
( IF { S#
s#, SNAME sn, STATUS st, CITY sc } S AND
{ S# s#, P# p#, QTY q } SP
THEN st> 20 OR q < QTY ( 500 ) )
,
.
Tutorial D
26 Tutorial D
( ). ,
.

,
, " ", ,
, " ". ,
9.9, , ,
.

1.

9.
20.
CONSTRAINT SC2
FORALL SX ( IF SX.CITY = 'London'
THEN SX.STATUS = 2 0 END IF ) ;

343

, Tutorial D (
IF/THEN) "END IF".

2. - ,
.
CONSTRAINT PC3
IF EXISTS PX ( TRUE )
THEN EXISTS PX ( PX.COLOR = COLOR ( ' B l u e ' ) )
END IF ;
3. .
CONSTRAINT SC4
FORALL SX FORALL SY ( IF SX.S#
=
SY.S#
THEN SX.SNAME =
SY.SNAME
AND SX.STATUS =
SY.STATUS
AND SX.CITY
=
SY.CITY
END IF ) ;
4. .
CONSTRAINT SSP5
FORALL SPX EXISTS SX ( SX.S# = SPX.S# ) ;
5. 20
500.
CONSTRAINT SSP6
FORALL SX FORALL SPX
( IF SX.S# = SPX.S#
THEN SX.STATUS 20 OR SPX.QTY 500 END IF ) ;
9.3.
1 ("
1 100 ").
FORALL s# S#, sn 6 NAME, st INTEGER, sc CHAR
( IF { S# s#, SNAME sn, STATUS st, CITY sc } S
THEN st > 1 AND st < 100 )
. ,
4 , S.
, (.. ,
), ,
( ,
4
, , 8,
,
, "" ,
( ).

344

II.

). , , S
. ,
"" ( ,
), ,
S ( S ), .
, (, ,
), , , . , , ,
; , (.. ),
, ,
, , , . , ,
( , .. , , ). .

.
.
, .
2000 .

, , , . , ; ,
.
, ,
: , , , , , , TRUE.
9.4.

, . , R . R
"", ,
R ( , ). ,

9.

345

: , , R
, R. , , , 9.1, ( ),
1, 2, 4, 5 6,
5 6. , "",
5.
, R , a RP R. , , ,
R , RP R (
, RP), , RP
FALSE. , ( ), .

, ,
FALSE.
, D 6 D Rl, R2, ..., Rn ( ). , , , RP1, RP2, ..., RPn. D, , DP, .
DP RP1 AND RP2 AND ... AND RPn
( ) .

, ,
FALSE.

,
R
, R (, 9.2,
, ). ,
[3.3], , R
, ,
R. ,
.
6
D, , (. [3.3])
.

346

II.

, FALSE ,

.
FALSE ,
.
. , ,
RPi RPj (i j), .
, DP . , , AND
. , , , , , , ,
.
9.5.
. ,
, , . .
1, , , , S, ( "
1 100"). , ,
. ,
() 200, .
1. .
2. .
3. ( ).
! , ,
. , ,
,
() , , , , .
,
. ,
.
IF { S# s#, SNAME sn, STATUS st, CITY sc } S THEN ...
,
, "
S", , , , S.

9.

347

. , , (. 13), ,
,
,
INSERT, , .
(, , ). .

, ,
FALSE.
9.4 , ,
. ? , , (. ). , ,
7

COMMIT.
, , ,
, ; ( )
, , , (.. COMMIT). ,
,
. , , ,
. 16;
, , .
( [9.16]
.)
9.6.
, , . , , " ".
7

, ,
,
. ,
,
. , , "
, ".

348

II.

, (.. ), , . ,
, 8.
,
, . ( )
, ; , , . ,
, , ,
(
). ,
.
, , . , , , . , S
, .
(S#) ,
(SNAME) (STATUS), (CITY). ,
1 100 20, .
.
,
.
S# , SNAME, STATUS
CITY.
( , ,
, , .)
, , (S#, SNAME, STATUS CITY),
9,
8
3 6,
. ""
.
, 7, ;
, .
9
" " ,
9.3 9.4. ( )
, .

9.

349

(.. , , ). ,
S , , .
( !), (.. ,
S). , .
{ S# S#('S1'), SNAME NAME('Smith'), STATUS 20, CITY 'London' }
S , , ,
, s1, Smith, 20
. , :
IF ( s S ) = TRUE THEN XPS ( s ) = TRUE
.
s :
{ S# s#, SNAME sn, STATUS st, CITY sc }
s# S#, sn NAME, st
INTEGER sc CITY.
XPS .
XPS(S) , XPS
s# = s#, SNAME = sn, STATUS = st
CITY = sc.
Ho 6,
, . ,
, ,
, , ,
. , , S .
{ S# S#('S6'), SNAME NAME('Lopez'), STATUS 30, CITY 'Madrid' }
, S6,
Lopez, 30 . , :
IF ( s S ) = FALSE THEN XPS ( s ) = FALSE
:
IF NOT { s S ) THEN NOT XPS ( s )

350

II.

:
se s

XPS

( s )

,
,
, TRUE. , ,
.
9.7.

, , , ( ) . , , ""
- "", , , ""
" " ( ..). , , . . ,
S1 . , , S1 10, () ,
.
, ,
, - , , , ! , S1
( INSERT),
- , , . , , , - (..
, FALSE). , , ( , ,
, DELETE).
, , , . ,
10

, S1 , S1
, S1 ,
( ).

9.

351

,
.
, ,
. , , . ,
; , ( , ), INSERT, DELETE UPDATE .
, . , ,
; . ,
, .
" " ,
( ). ,
.
,
.
, ; , , - , (..
, - , ).
, , !
:
,
, ;
,
, .
: , , , (
), , , ,
( ). "" ,
,
.
9.8.
, , , , . , ( ).

352

II.


( , ). ,
,
S#, SNAME STATUS (
CITY).
, .
CITY, S# SNAME, STATUS CITY.
, , ,
, , ( CITY
,
, "
"). (,
) . ,
.
s# , SNAME, STATUS
.
, . ?
, .
1. 1 100
.
2. 20.
3. - ,

.
4. .
5. .
6. 20
500.
, ( s#, SNAME STATUS) SST. ,
SST, 3, , , ;
, . , SST, . ,
5.
FORALL s# S#, # #, q
QTY ( IF { S# s#, P# p#, QTY q
} SP
THEN EXISTS sn NAME, St INTEGER
( { S# s#, SNAME sn, STATUS st } SST ) )

9.

353

. CITY , s SST. ,
SST S , SST
S ( SST
S)11.
1, 2, 4 6. ,
, 2 ,
EXISTS, , .
FORALL s# S#, sn NAME, st INTEGER
( IF { S# s#, SNAME sn, STATUS st }
SST THEN EXISTS SC CHAR
( { S# s#, SNAME sn, STATUS st, CITY sc }
S AND ( IF sc = 'London' THEN st = 20 ) )

S.
9.9.
(
, , [3.3]). , :
, ,
. .
,
.
,
.
,
.
,
, .
, .


.
5, ,
,
11

,
! (. 9.10.)

354

II.

. , ,
, , .
( 5).
TYPE WEIGHT POSSREP { D DECIMAL (5,1)
CONSTRAINT D > 0.0 AND D < 5000.0 } ;
: WEIGHT
,
,
5000.
, ,
WEIGHT,
WEIGHT. WEIGHT , . , ( , )
. , aWEIGHT.
WEIGHT ( 7500.0 )
( " WEIGHT ").
, , , , ,
,
(, , !).

, , Tutorial D

. , .

, , , 9.2 ; ,
, ,
. ,
, .
VAR S BASE RELATION
{ S#
S#,
SNAME
NAME, STATUS
INTEGER, CITY
CHAR } ... ;
s#, SNAME, STATUS CITY , , , S#,

9.

355

NAME, INTEGER CHAR. , . , (


).
. , (
INSERT UPDATE) , ,
. ,
, .

; ,
, . 9.2,
(
).
, ,
. , ( , ), ,
12; , " " " ",
. ,
, , ,
.
(" ").
CONSTRAINT TRC1 FORALL SX'
FORALL SX { SX'.S# SX.S# OR SX'.STATUS < SX.STATUS ) ;
. ,
, SX , , . , , , : " SX' ,
SX
, SX, SX'".

12

, , .

356

II.

, TRC1
( S).
("
, ,
").
CONSTRAINT
TRC2
FORALL
SUM ( SPX' WHERE SPX'.P# = .#, QTY
) SUM { SPX WHERE SPX .P# = PX.P#, QTY
) ;
.
9.10.
9.1,
, , , (
). .

, R . , R ; , R .
, R , ,
S ,
s#. , 3.
, R.
R ,
.
) . R
.
) .
.
.
.
, ,
, ,
. , ,
13
, ;
[3.3], .
, (,
).

9.

357

{S#,CITY}
{S#}. , "" ,
,
, "",
. , , , 14.
, ,
, ( )
. , , 1 ,
, , 2, ; , , , 1 ,
2 . .
Tutorial D .
KEY { <attribute name commalist> }
.
VAR S BASE RELATION
{ S#
S#, SNAME
NAME, STATUS
INTEGER, CITY
CHAR } KEY { S# }
;
.
PRIMARY KEY, KEY. " " .
VAR SP BASE
RELATION { S#
S#, P# P#, QTY
QTY }
KEY { S#, P# } ... ;

(.. , ).
, .
VAR ELEMENT BASE RELATION { NAME
NAME,
SYMBOL CHAR, ATOMIC#
INTEGER } KEY { NAME }
KEY { SYMBOL } KEY {
ATOMIC# } ;
14
, ,
: , ""
( ), "", , 12.

358
II.
, .
VAR MARRIAGE BASE RELATION { HUSBAND
NAME,
WIFE
NAME,
DATE /* */ DATE
}
/* ,
*/
/* , ,
*/
/* ...*/
KEY { HUSBAND, DATE }
KEY { DATE, WIFE } KEY
{ WIFE, HUSBAND } ;
, . , .
, 9.2,
.
.
, .
,
. ,
. , ,
(, , ).
S WHERE S# = S#

('S3')

,
(, , ).
S WHERE CITY =

'Paris',

,
, .
.
1. , " ",
(.. " ",
),
.
2. , ,
, "
",

.
, " " " ",

9.

359

, ( ,
, 10 18).
.
!
, ,
, . , , , ,
, ,
[3.3].
(,
S {S#,CITY}).
,
. ,
.
SK R, R, R
SK . ,
SK R,
SK R.
. 11.
, ,
( ,
). ,
,
(, , -
). , -,
, ,
, .

,
.
( ,
), ;
. , , ELEMENT, {SYMBOL}
, {NAME} {1#}
. ,
. ,
.
(, )
,
( ) , , , .

360

II

[9.14],
, , ,
, , . ( [9.9]:
" [ ] ,
".) ,
, , .
.

, R2,
R1. ,
{S#} SP. ,
{S#} SP,
S
{S#} ( ). , {#} SP,
{#} ( ). 15.
, R2 . R2
R2, , FK,
:
) Rl (R1 R2
) ;
)
FK, FK () FK , a FK'
();
) FK R2
FK',
R1.
.
1.
; , FK, ,
( ,
, . 7). ,
FK FK' , .
2. , FK
CK, ; , R1
15

, .

9.

361

, R2
FK. , (
. 3.8 . 119) S5 S, SP,
S5 - .
3. FK ,
CK.
4. FK ,
( , ). ,
FK ,
. R2
, R1
, . ,
- ,
(. . 12).
5. .
.
S SP
, ,
, ,
, , .
.
() (), 16, , .
s#
#
S SP
, .
6.
, , R2,
.
R3 R2 R1
, , Rn, R (n-1) ,
..., R2, R1, , Rn R(n-l), , R(n-l)
R(n-2) , ..., , R2 R1 .
Rn R(n-l)

R(n-2) ... R2 R1

16
(, , )
, .

362

II.

, Rn R1, Rn R1.
7. , R1 R2,
, . ,
,

.
( ,
).
VAR EMP BASE RELATION
{ # #, ..., MGR_EMP# EMP#, ... }
KEY { # } FOREIGN KEY { RENAME MGR_EMP# AS EMP# }
REFERENCES EMP ;
MGR_EMP# , #; ,
4 MGR_EMP# , , . ( . 1, , .)
, ,
( ).
. ,
.
8.
, , ,
. Rn, R(n-l), R(n-2), ..., R2, Rl
, Rn , R(n-l),
a R(n-l) , R(n-2) , ..., ..,
, R1 , Rn.
, ,
Rn
, .
Rn R(n-l) R(n-2) ... R2 Rl Rn
9. ,
"",
.
,
. ,
, . ,
("
"), CITY
S ;
, ,
. .

9.

363

10. ,
,
(. 10.2 10).
,
(
).
11. ,
,
(,
[9.9]).
,
[9.14].
12.
( ).
. - 17.
" " ,
, .
,
: " , ".
.
FOREIGN KEY { <item commalist> } REFERENCES <relvar name>
;
<relvar name> , , <item> <attribute name> , .
RENAME <attribute name> AS <attribute name>
( RENAME
. 7.)
(
, . . 3.9 3). , 9.2,

(
,
17
,
"" (), ,
,
, . ,
,
"" . 19.

364

II.

), ,
" ";
, . , "
".

Tutorial D.
DELETE S WHERE S# = S# ('S1') ;
, DELETE , , ..
si, . , : -, , S1, -, .
, , .
, . , , ,
. , ""
, S1. ,
, .
VAR SP BASE RELATION { ... } ...
FOREIGN KEY { S# } REFERENCES S
ON DELETE CASCADE ;
ON DELETE CASCADE , CASCADE
. ,
DELETE "" ( )
.

RESTRICT ( ).
RESTRICT ,
DELETE "" , ( ).
, NO ACTION, , :
DELETE , , .
( NO ACTION,
,
,

9.

365

, RESTRICT.)
.
1. DELETE ,
. ,
,
? , ,
.
UPDATE, DELETE, .

CASCADE.

UPDATE
.
RESTRICT. UPDATE ,
(
).
NO ACTION. UPDATE
( ).
2. , CASCADE, RESTRICT NO ACTION
; ,
.
()
. .
.
.
, ,
.

, .
, , (. ).
,
, ; , ( ,
, ).
3. , R2 R1, ,
, ,
.
R2 R1
, CASCADE.
DELETE R1
( ) DELETE
R2. , R2,

366

II.
, R3,
, , , DELETE R2
.
R3 R2 R1

, , , R3 R2. DELETE
( , R3 R2, ),
. .
, , R2
- , R3.
4. ,
, (
" "), , , , .
9.11. ( )
,
. , , (
)
.
. , (,
)
. , 1 (" 1
100 ") ,
S,
, .
, . .
1. , ,
. , ,
. ,
-

9.
367
18, (, S).
2.
, . ,
, . 1,
. " " .
) ,
(, ,
).
) (.. /
).
) (, ,
).
) (,
).
) (,

)19.
, ,
.
. ( SQL,
Tutorial D, [3.3] , - ;
, SQL, SQL
, .) , LONDON_SUPPLIER, .
CREATE VIEW LONDON_SUPPLIER
AS SELECT S#, SNAME,
STATUS FROM
S WHERE
CITY = 'London' ;
,
, SQL S CITY,
18
,
, . , , , , ,
, -, , .
, , (. [9.5]).
19

, .
, ! ,
, "" (..
).

368

II.

CITY (. 10). , ,
,
!
.
CREATE TRIGGER LONDON_SUPPLIER_INSERT
INSTEAD OF INSERT ON LONDON_SUPPLIER
REFERENCING NEW ROW AS R
FOR EACH ROW
INSERT INTO S ( S#, SNAME, STATUS, CITY )
VALUES ( R.S#, R.SNAME, R.STATUS, 'London' ) ;
,
CITY, London,
, (
, ).
, . .
SQL, ,
SQL ( SQL
).
1. , CREATE TRIGGER, ,
, :
( " INSERT
LONDON _S UPPLIER ");

ON

,
TRUE , ( ,
, npoc TRUE);
( "INSERT
INTO S ...").
,
(, ) .
"-" (Event-Condition-Action ) .
2. INSERT, DELETE ,
UPDATE (, ),
(COMMIT), ,
, ..
3. , (BEFORE), (AFTER)
(INSTEAD OF) , , ,
.
4. , (FOR EACH ROW)
(FOR EACH STATEMENT), ,
.

9.

369

5. , , ,
, ,
, ,
.
6. , ,
.
, , , , , ,
, .
,
.
(
) ,
, , ,
.
, 1
2, ..

.
"" INSERT, DELETE
UPDATE ,
( INSTEAD OF,
).
, , . , ,
.
9.12. SQL
SQL (, , , ) ,
9.9.
SQL ,
,
. ,
5, , WEIGHT
DECIMAL (5,1), ,
5000.
SQL () .
SQL .
,
,

370

II.

( , ), ,
.
SQL . , (assertion),
, .
( ,
SQL , ,
, "
".)
SQL ,
.
, (
), SQL , .

SQL CREATE TABLE
ALTER TABLE. , . .
. CONSTRAINT <constraint name>,
. ( , , -,
). ,
, ( "" ), .

SQL .
PRIMARY KEY ( <column name commalist>
) UNIQUE ( <column name commalist> )
<column name commalist>
20.

PRIMARY KEY , UNIQUE .
PRIMARY KEY
NOT NULL, .. ,
NOT NULL (. ).
20

. 9.10.

9.

SQL .

371

FOREIGN KEY ( <colmn name commalist> )


REFERENCES <base table name> [ ( <column name
commalist> ) ] [ ON DELETE <referential action> ] [ ON
UPDATE <referential action> ]
<referential action> NO ACTION ( ), RESTRICT, CASCADE, SET DEFAULT SET
NULL21. SET DEFAULT SET NULL 19;
9.10. <column name commalist>
, ,
.
.
, ( ) .

SQL .
CHECK ( <bool > )
, .
, ,
(.
) ,
<bool > FALSE.
. , , <bool > SQL ;
,
.
CREATE TABLE, .
CREATE TABLE SP
( S# S# NOT NULL, P# P# NOT NULL, QTY QTY NOT
NULL,
PRIMARY KEY ( S#, P# ),
FOREIGN KEY ( S# ) REFERENCES S
ON DELETE CASCADE
ON UPDATE
CASCADE, FOREIGN KEY ( P# )
REFERENCES P
ON DELETE CASCADE
ON UPDATE CASCADE, CHECK ( QTY
> QTY ( 0 ) AND QTY < QTY { 5000 ) ) ) ;
21
, , <ref erential action> (
CASCADE) , ( )
! ,
SQL .

372

II.

, s# # , , S .
, ,
NOT
NULL <column name>.
CHECK ( <column name> IS NOT NULL )
, , NOT NULL.
, SQL , , () "1 = 2" (
, , , "
"!).

SQL, . CREATE ASSERTION, .


CREATE ASSERTION <constraint
> CHECK ( <bool exp> )
;
DROP ASSERTION.
DROP ASSERTION <constraint name> ;
, DROP
SQL (, DROP TYPE , DROP TABLE , DROP VIEW ), DROP
ASSERTION RESTRICT CASCADE.
9.1,
SQL.
.
1. 1 100
.
CREATE ASSERTION SC1 CHECK
( NOT EXISTS ( SELECT * FROM S
WHERE S.STATUS < 0
OR
S.STATUS > 100 ) ) ;
2. 20.
CREATE ASSERTION SC2 CHECK
( NOT EXISTS ( SELECT * FROM S
WHERE S.CITY = 'London'
AND
S.STATUS 20 ) )
;
3. - ,
.

9.

373

CREATE ASSERTION CHECK


( NOT
EXISTS ( SELECT * FROM P )
OR EXISTS ( SELECT * FROM P
WHERE P.COLOR = COLOR ('Blue') ) ) ;
4. .
CREATE ASSERTION SC4 CHECK
( UNIQUE ( SELECT S.S# FROM S ) ) ;
UNIQUE SQL,
TRUE,
,
FALSE.
5. .
CREATE ASSERTION SSP5 CHECK
. ( NOT EXISTS
( SELECT * FROM SP
WHERE NOT EXISTS
( SELECT * FROM S
WHERE S.S# = SP.S# ) ) ) ;
6. 20 500.
CREATE ASSERTION SSP6 CHECK
( NOT EXISTS ( SELECT * FROM S, SP
WHERE S.STATUS < 20 AND
S.S#
= SP.S# AND
SP.QTY > QTY ( 500
) ) ) ;.
. .
CREATE VIEW LONDON_SUPPLIER
AS SELECT S#, SNAME,
STATUS FROM
S WHERE
CITY = 'London' ;
, .
UNIQUE ( S# ) '
, , .
CREATE ASSERTION LSK CHECK
( UNIQUE ( SELECT S# FROM LONDON_SUPPLIER ) ) ;

SQL ,
, , . . ,

374

II.

SQL 22
(DEFERRABLE) (NOT DEFERRABLE);
DEFERRABLE,
(INITIALLY DEFERRED)
(INITIALLY IMMEDIATE);
. NOT DEFERRABLE , DEFERRABLE .
SET CONSTRAINTS <constraint name commalist> <option> ;
<option> IMMEDIATE DEFERRED.
.
SET CONSTRAINTS SSP5, SSP6 DEFERRED ;
DEFERRABLE ,
IMMEDIATE. DEFERRABLE IMMEDIATE ; ,
SET IMMEDIATE . COMMIT SET IMMEDIATE
DEFERRABLE; , .

CREATE TRIGGER SQL .


CREATE TRIGGER < trigger name>
<before or after> <event> ON <base table
name> [ REFERENCING <naming commalist> } [
FOR EACH <row or statement> ] [ WHEN (
<bool exp> ) ] <action> ;
.
1. ,
<before or after>, BEFORE AFTER ( SQL
INSTEAD OF,
).
2. <event> INSERT, DELETE UPDATE.
UPDATE OF
<column name commalist>.
3. <naming>
.

22

NOT
DEFERRABLE. , FK , NOT DEFERRABLE.

9.

375

OLD
ROW
AS
<name> NEW ROW
AS
<name>
OLD
TABLE AS <name>
NEW
TABLE
AS
<name>
4. <row or statement>
ROW STATEMENT (STATEMENT
). ROW ,
, ,
STATEMENT ,
, .
5. WHEN, , <action>
, <bool >
TRUE.
6. <action> SQL (
, .. ,
, ,
BEGIN END).
, DROP TRIGGER.
DROP TRIGGER <trigger name> ;
DROP ASSERTION, DROP TRIGGER
RESTRICT CASCADE.
9.13.
.

( , ; , , ,
). , .
,
.
(IF) ,
(THEN) .
( , .)
, Tutorial D, , , -
, ,
, ,
. , (
),
.

376

//.

, , ,
, (..
, ),
.
, ,
, "",
,
, ,
"". , , .

, ,
FALSE.
.
. , (
, , ). , . , . , . ,
, ,
, ,
( ). , ,
.
, ( ),
(
, ), , , ,
, ,
, ,
.
, .
(
) .
,
,
.


.
.

9.

377

,
, . ,
.
, , , .
,
( - !)
. ,

, ;
, , ,
(
CASCADE).
,
.
SQL.
SQL ; , , . SQL ( ) (""),
( ),
Tutorial D ( ,
SQL , ). , SQL . ,
, SQL .

9.1.
9.2.

9.3.

,
16 9.1?
16 9.1
Tutorial D, . ,
, ?
?
-
, Tutorial D
, 9.2.
) : ,
, , , , , (London, Paris,
Rome, Athens, Oslo, Stockholm, Madrid, Amsterdam).
) ,

, "S",
0 9999.
) 50 .

378

9.4.

9.5.

II.
) .
) .
) ,
.
) ,
.
) ,
.
) ,
.
) .
) 19.
) 2.
)
50 .
) ,
.
) , .
) ( ) .
) , .
. 9.3
:
) ,
;
) , .
, ,
. 4.5 (. . 154), ,
:
) UPDATE J7
CITY New York;
) UPDATE 5
# 4;
) UPDATE S5
S# S8,
RESTRICT;
) DELETE S3,
CASCADE;

9.

379

) DELETE 2,
RESTRICT;
) DELETE J4,
CASCADE;
) UPDATE s1-PlJ1 s# S2;
) UPDATE S5-P5-J5
J# J7;
) UPDATE S5-P5-J5
J# J8;
) INSERT S5-P6-J7; .
) INSERT S4-P7- J6;
) INSERT S1-P2 - j j j ( j j j
).
9.6. , - " " .
, .
9.7.


.

, , ,
;
, .
, .
.
COURSE
{ COURSE#, TITLE }
/*
*/
PREREQ
{ SUP_COURSE#, SUB_COURSE# } /*
*/
OFFERING { COURSE#, OFF#, OFFDATE, LOCATION } /*
*/
TEACHER
{ COURSE#, OFF#, EMP# }
/*
*/
ENROLLMENT{ COURSE#, OFF#, EMP#, GRADE } /* */
EMPLOYEE { EMP#, ENAME, JOB }
/*
*/
PREREQ , ,
(SUB_COURSE#)
(SUP_COURSE#).
-
. . (.. ).

9.8.

,
.
DEPT { DEPT#, . . . , MGR_EMP#,
... } EMP { #, ..., DEPT#,
... }

380

II.
(MGR_EMP#),
(DEPT#). .

9.9.

,
.
{ #, ..., JOB, ...
} PGMR { #, ..., LANG,
... }
, .
.

9.10. .
, (..
)? -
"" ( "-") ?
9.11. , R .
, R?
9.12. , .
() .
) A WHERE . . .
) { . . . }
) A TIMES
) A UNION
) A INTERSECT
) A MINUS
) A JOIN
3) EXTEND A ADD exp AS Z
) SUMMARIZE A PER ADD exp AS Z
) A SEMIJOIN
) A SEMIMINUS
,
(, UNION
).
9.13. . 9.10, "" "
" ().
9.14. . 9.3 SQL.
9.15. . 9.7-9.9 SQL.
9.16. , (
) .
?

9.

381

9.17. 9.7 , s1 London , (


), S1 London.
. , .
. .

9.1.

Aiken A., Hellerstein J.M., and Widom J. Static Analysis Techniques for Predicting the
Behavior of Active Database Rules//ACM TODS. March 1995. 20, 1.
, [9.2], [9.5], ,
( ).
, , Starburst
IBM (. [18.21], [18.48], [26.19], [26.23] , [26.29], [26.30] [9.25]).

9.2.

Baralis E. and Widom J. An Algebraic Approach to Static Analysis of Active Database


Rules // ACM TODS. September 2000. 25, 3. :
Baralis E. and Widom J. An Algebraic Approach to Rule Analysis in Expert Database
Systems // Proc. 20th Int. Conf. on Very Large Data Bases. Santiago, Chile.
September 1994.
"", , . , , , ( 9.11) , .
( ) ,
.
,
. , ,
.

9.3.

Bernstein P.A., Blaustein .., Clarke E.M. Fast Maintenance of Semantic Integrity
Assertions Using Redundant Aggregate Data // Proc. 6th Intern. Conf. on Very Large
Data Bases. Montreal, Canada. October 1980.
, , : "
". , , , , ,
: "
". ,
, ,
( , )

382

9.4.

9.5.

II.
, ,
.
Buneman .P., Clemons E.K. Efficiently Monitoring Relational Databases // ACM
TODS. September 1979. 4, 3.

( ), , , , . ( avoidance algorithm), , ,
, .
, ,
.
( ) .
Ceri S., Widom J. Deriving Production Rules for Constraint Maintenance // Proc. 16th
Intern. Conf. on Very Large Data Bases. Brisbane, Australia. August 1990.
SQL,
, , , . ( [9.12].)
.

9.6.

Ceri S., Cochrane R.J., Widom J. Practical Applications of Triggers and Constraints:
Successes and Lingering Issues // Proc. 26th Int. Conf. on Very Large Data Bases, Cairo,
Egypt. September 2000.
: " ... , ". ,
, , , , "
", .

9.7.

Ceri S., Fraternali P., Paraboschi S., and Tanca L. Automatic Generation of Production
Rules for Integrity Maintenance //ACM TODS. September 1994. 19, 3.
, [9.5],
, . .
1. , .
2. ,
TRUE, ( ,
).
3. SQL.
, .

9.

383

9.8.

Cochrane R., Pirahesh H., and Mattos N. Integrating Triggers and Declarative
Constraints in SQL Database System // Proc. 22 Int. Conf. on Very Large Data Bases.
Mumbai (Bombay), India. September 1996.
: " ,
, . [ ]".
SQL: 1999.

9.9.

Codd E.F. Domains, Keys, and Referential Integrity in Relational Databases //


InfoDB3. - 1988.-3,1.
, . ,
,
. ,
, . , ,
: " ..., ,
(, , )".
, ? "",
, , "".
(,
. .
[14.21] 14.)

9.10. Date C.J. Referential Integrity // Proc. 7th Intern. Conf. on Very Large Data Bases.
Cannes, France. September 1981.
(Date C.J. Relational Database: Selected Writings. Reading, Mass.:
Addison-Wesley, 1986).
( RESTRICT CASCADE), 9.10 . (VLDB, 1981) , , [ 14.7],
, , ( ,
[9.10]) .
9.11. Date C.J. Referential Integrity and Foreign Keys ( ) // Relational Database
Writings 1985-1989. Reading, Mass.: Addison-Wesley, 1990.

384

II.
,
( ). , , , . , ,
, , ,
(.. ,
).
.
( ) ,
[9.14].

9.12. Date C.J. A Contribution to the Study of Database Integrity // Relational Database
Writings 1985-1989. Reading, Mass.: Addison-Wesley, 1990.
: " [ ]. -, , -, , ,
, , -,
". , , 9.9 .
9.13. Date C.J. Integrity // 11 Date C.J. and Colin J.W. A Guide to DB2 (4th
edition). Reading, Mass.: Addison-Wesley, 1993.
DB2 IBM
( , ,
, ). , [9.13],
DB2 ,
. . ,
R
, , 1 2,
: " R".
,
, , 2 4.
"2" ( "4"), "1" (
"2"), . , , (, , ) "1" ( "2"),
( ). , .

9.

385

DB2 , . , ,
[9.20].
, ( ) DB2
" ". ,

.
(. " " 6.5
6); ,
.
9.14. Date C.J. The Primacy of Primary Keys: An Investigation // Relational Database
Writings 1991-1994. Reading, Mass.: Addison-Wesley, 1995.
, , "
", .. .
9.15. Date C.J. WHAT Not HOW: The Business Rules Approach to Application Develop
ment. Reading, Mass.: Addison-Wesley, 2000.
( ) -. . [9.21] [9.22].
9.16. Date C.J. Constraints and Predicates: A Brief Tutorial ( ) //
http: //www.dbdebunk. com, (May 2001).
.
( )
.
" ,
. ,
, , .
( , , ). (", ")
, (" ") . ,
( 1969 ),
, , , , ,
, ,
. ( ,
, .. ) . ,
; , ,
,
. ,

386

If.
( , )
. , !
,
, . , , ( , ), ,

.

?
?
?
(,
, )?

?
, ,

. , , ,
.
, , , ,
. - , ,
, . ,
, , ! , , NOT p (
), . , q , . .
, , ,
OR q .
, OR q NOT p ,
, q .
q ! , , , ".

9.

387

9.17. Hammer M.M., Sarin S.K. Efficient Monitoring of Database Assertions // Proc. 1978
ACM SIGMOD Int. Conf. on Management of Data. Austin, Texas. May/June
1978.
, ,

, " ".

. , . ,

.
9.18. Horowitz . . A Run-Time Execution Model for Referential Integrity Maintenance //
Proc. 8th IEEE Int. Conf. on Data Engineering. Phoenix, Ariz. February 1992.
, , , ( , ,
[9.11]).
1. (.. ,
).
2. .
3. .
:
)
;
)
,
;
) ,
.
) , , , ) ([9.13], [9.20]),
(Horowitz) ).
, ,
. , , .
,
SQL: 1992, SQL,

388

II.
, , .

9.19. Markowitz V. . Referential Integrity Revisited: An Object-Oriented Perspective // Proc.


16th Int. Conf. on Very Large Data Bases. Brisbane, Australia. August 1990.
" -
" ("Object-Oriented Perspective"), , : "
- ".
. , , , "" (. 14),
, [9.11] (,
).
, (DB2, Sybase Ingres,
1990 ). , DB2, , . Sybase Ingres, (, ), , DB2, ( ,
Ingres " " Sybase).
9.20. Markowitz V. . Safe Referential Integrity Structures in Relational Databases // Proc.
17th Int. Conf. on Very Large Data Bases. Barselona, Spain. September 1991.
, ,
, , , [9.11]
[9.18]. , DB2, Sybase Ingres ( -
1990 ). DB2 , , [9.13], , ,
(.. DB2 ). Sybase Ingres, ,
, ,
( !) .
9.21. Ross R. G. The Business Rule Book: Classifying, Defining, and Modeling Rules (Version
3.0). Boston, Mass.: Database Research Group, 1994.
. [9.22].
9.22. Ross R.G. Business Rule Concepts. Houston, Tex.: Business Rule Solutions Inc.,
1998.
-.

9.

389

, -
,
( , - ,
"", , .). , - , (.. ) ,
, . , -,
(Ross), . [9.21] , [9.22] .
.
(Principles of the Business Rule Approach. Addison-Wesley, 2003).
9.23. Stonebraker M.R., Wong E. Access Control in a Relational Data Base Management
System by Query Modification // Proc. ACM National Conf. San Diego, Calif.
November 1974.
_
University Ingres [8.11] ( .
17), .
DEFINE INTEGRITY,
.
DEFINE INTEGRITY ON <relvar name> IS <bool exp>
, .
DEFINE INTEGRITY ON S IS S.STATUS > 0
,
REPLACE, QUEL.
REPLACE S ( STATUS = S.STATUS - 10 ) WHERE S.CITY = "London"
Ingres REPLACE .
REPLACE S ( STATUS = S.STATUS 10 ) WHERE
S.CITY = "London"
AND
( S.STATUS - 10 ) > 0
, .
,
;
QUEL ,
.

390

II.

.

9.24. Walker A., Salveter S. . Automatic Modification of Transactions to Preserve Data Base
Integrity Without Undoing Updates: Technical Report 81/026. State University of
New York, Stony Brook, N.Y.: Technical Report 81/026. June 1981.

(.. ) . , , , , - .

, ( ).
, .
9.25. Widom J. and Ceri S. (eds.). Active Database Systems: Triggers and Rules for Advanced
Database Processing. San Francisco, Calif: Morgan Kaufmann, 1996.

( ,
, , ). , Starburst, IBM Research (.
[18.21], [18.48], [26.19], [26.23], [26.29] [26.30]), Postgres, , . (. [26.36], [26.40], [26.42]
[26.43]). ,
SQL: 1992, SQL: 1999
( Oracle, Informix
Ingres). .

10

10.1.
10.2.
10.3.
10.4.
10.5.
10.6.
10.7.




( )
SQL

10.1.
3, , ,
( ,
).
Tutorial D.
VAR GOOD_SUPPLIER VIEW
( S WHERE STATUS > 15 ) { S#, STATUS, CITY } ;

( , ) ,

, GOOD_SUPPLIER. ,
,
GOOD_SUPPLIER
, . 10.1 ( ,
, ).
, GOOD_SUPPLIERS (
) .
, ,
, ,
.

392

II.

. 10.1. GOOD_SUPPLIER
S ( )
3 , , GOOD_SUPPLIER,
. , , ( ), , ,
. , , ,
, 1 .
,
GOOD_SUPPLIER . ,
, S,
, GOOD_SUPPLIERS . , ,
, ,
.
GOOD_SUPPLIER.
GOOD_SUPPLIER WHERE CITY 'London'

, . 10.1.

, ,
. 3, (
). , .
.
( ( S WHERE STATUS > 15 ) { "S#, STATUS, CITY } )
WHERE CITY 'London' ;
1

, SQL!
WITH CHECK OPTION 10.6.

10.

393

,
.
( S WHERE STATUS > 15 AND CITY 'London' )
{ S#, STATUS, CITY } ;
.
, (..
) . ( )
, ,
R, ( ,
, , R). , , , ,
.
.
, .
UPDATE GOOD_SUPPLIER WHERE CITY =
'Paris' { STATUS := STATUS + 10
} ;
.
UPDATE S WHERE STATUS > 15 AND CITY =
'Paris' { STATUS := STATUS + 1 0 }
;
INSERT DELETE ..

,
.
1. VAR REDPART VIEW
( WHERE COLOR = COLOR ('Red') ) { ALL BUT COLOR }
RENAME WEIGHT AS WT ;
REDPART (
),
. #, PNAME, WT CITY, , .
2. VAR PQ VIEW
SUMMARIZE SP PER P { P# } ADD SUM ( QTY ) AS TOTQTY ;
PQ
.
3. VAR CITY_PAIR VIEW
( ( S RENAME CITY AS SCITY ) JOIN SP JOIN
( P RENAME CITY AS PCITY ) ) { SCITY, PCITY } ;

394

II.
CITY_PAIR , , SNAME PNAME. ,
CITY_PAIR (,) , , , ,
. , , si 1; S1 1 ; (London, London).
4. VAR HEAVY_REDPART VIEW
REDPART WHERE WT > WEIGHT ( 12.0 ) ;
, .


Tutorial D .
VAR <relvar name> VIEW <relation exp> <candidate key def list> ;

<candidate key def list> ( ,
),
[3.3].
, GOOD_SUPPLIER ,
, , {S#},
S.
( ANSI/SPARC, 2),
"",
(.. ), (..
).
.
"", "". HEAVY_REDPART .
.
DROP VAR <relvar name> ;
<rel var name> . 6
,
, , . , ,
, -
, . , (
), ,
RESTRICT, CASCADE. RESTRICT, , ,

10.

395

, , .
CASCADE , , .
. SQL , DROP, . , DROP
;
(. 10.6).
10.2.
. .

" ".
" , , , ".
CITY_PAIR ( ), " " .
( CITY_PAIR WHERE SCITY = 'London' ) { PCITY }
, , .
( ( ( S RENAME CITY AS SCITY ) JOIN SP JOIN
( P RENAME CITY AS PCITY ) )
WHERE SCITY = 'London' ) { PCITY
}
, (, ,
),
, , . ,
.
.
.
,
, ( ) , . . ,
, ,
( ) . ,
, , ,

396

II.

( ).

.
, , ,
, ,
. ,
, .
.
,
(,
GOOD_SUPPLIER ).
( ,
). ,
,
. 17.
.
,
.


,
( ; . 2). ,
,
. .
. . , .
.
, ,

. .
) .
, . DISCOUNT () .

10.

397

)
. .
-
,
, ( . 6 8.6.1,
8, , "SELECT *" SQL).
.

, , . ,
. . ,
- ( , )
S .
VAR SNC BASE RELATION { S# S#, SNAME NAME, CITY CHAR }
KEY { S# } ;
ill.
VAR ST BASE RELATION { S# S#, STATUS INTEGER
} KEY { S# } ;
, S SNC ST ( , SNC ST, S). , ,
, .
VAR S VIEW
SNC JOIN ST ;
, S, S. , ,
, 2
.
2

! , SQL (
SQL) , , , . , ( )
, ,
, SQL ( , , ),
SQL . . ,
( SQL), [20.1].

398

II.
, S,
, , SNC ST,
. , ,
SP,
, ,
S
(. . 10.14).
. SNC ST, , ,
.
,
(.. ). , , . , , .



. , .
, V, ,
X, .
V , X,
.
, , v
, X,
. V
, .
, , , (.. ),
! S,
SNC ST,
. , :
S , a SNC ST
, ;
SNC ST , a S
, 3.
, .
.
3

. 12.2 12.

10.

399

, ,
. ,
,
, . 10.4.

. ( ) , . , , (-, )
. ,
(
).
, , , (.. 3).
, .. ,
, , .
.
10.3.

. .
, ( 6.4 6),
. , , ,
, .
D (
), V , D, ..
, D,
.
V = X ( D )
, RO V. , RO ,
.
RO ( V )

= RO ( X ( D )

,
X D, .. , V,
RO . (. 10.1).

400

II.

( . . . ) ,
RO ( ( . . . ) ) RO ( ), D. , - , , ,
, . , , , ( , ,
).
, , , .
,
.
-, ( )
.
-, ,
, ,
(, , ).
, ,
,

,
(
).
-, , ,
, ,
SQL (
) ! ,

.
SQL, SQL: 1992. ,
SQL
,
(. . 10.15, ).
10.4.
( )
.
. .
.
,
? . D , V , D (.. ,
X D), ( 10.3).

10.
V = X

401

( D )

, u V. u
, , .
UO

( V )

= UO

( X

( D )


u' D, .
UO

( X

( D )

= X

( UO'

( D )

,
D ( ) .
, ,
. , , [10.4], [10.7][10.10],
[10.12]. , , (Codd)
RM/V2 [6.2]. [10.6], [10.11],
( )
.
. ,
. , ,
.

( ) , .
, FALSE.
( ) .
.
. ,

. ,
.
, , , . , ,
,

402

II.

. , , .
? , , ()
() , . ,
( ),
. (,
: , .)
, . , , , ,
, A INTERSECT , ,
PC (PA) AND (). .
t ,
, .
t , (t)
( "PA(t)" , t ).
, t ,
(t).
, (t) AND (t);
,
( ).
.
,
, . ,
,
[3.3].
(, ).
Tutorial D . .

,
. (,
, .) .

10.

403

1. ,
. ,
. ,
.
VAR V VIEW
S WHERE STATUS > 25 OR CITY = 'Paris' ;
VAR V VIEW
( S WHERE STATUS > 25 ) UNION ( S WHERE CITY = 'Paris' ) ;
, ,
( , ,
). SQL,
SQL,
,
, ( 10.6).
2. ,
,
,
V,
UNION , INTERSECT ,
WHERE TRUE, ,
. , , ,
, ,
v = UNION , , ,

. ,
,
.
, , .
3.
, . ,
, V = A INTERSECT ,
,
, ,

.
B. ( , .
, .
,
, INTERSECT B B INTERSECT .)
4.
, , , ,
, .

404

II.

5. UPDATE
(DELETE
INSERT); .
.

.
, UPDATE DELETEINSERT, DELETEINSERT.
, DELETE
,
UPDATE . , ,
R 10 ,
UPDATE R, ,
R,
10 . ,
DELETE - .
. (
, .)
,
,
( ).
6.
. ,
(INSERT) ,
(DELETE) ( ,
UPDATE ). , ..
(, ,
), INSERT
DELETE . INSERT
-
DELETE! (
. 2),

V = UNION .
( , ,
..). ,

, . , ,
INSERT DELETE
INSERT DELETE , .

10.

405

7.
V ,
, V.
, ,
, ,
. ,
. ,
- ,
. ,
" ", ,
.
8. ,
, .. (
12 13). ,
,
.
.
.
9. ,
,
(, DELETE,
INSERT).
10. INSERT DELETE , , .
. 6, , ,
, , ,
. ,
(, ). , .

; ,
, , .
(, ), . , , , , , , : A UNION ,
A INTERSECT A MINUS , , , (..
).
.
.

406

II.

. , , , ,
, . , , , , . ,
( ) , , , .

UNION .
INSERT.
, , .
,
(, ,
).
, , ,
.
. , , A UNION , A UNION , (PA) OR (). ( ,
, , ,
,
.) ,
, , ( , ).
. , (
, ),
. , , . , ( 3, ), ,
, .
, .
. uv .
VAR UV VIEW
( S WHERE STATUS > 25 ) UNION ( S WHERE CITY = 'Paris' ) ;

10.

407

. 10.2. UV ( )
. 10.2 , .

, UV, 4
(S6, Smith, 50, Rome). s WHERE STATUS >
25, S WHERE CITY = 'Paris'. ,
, s WHERE
STATUS > 25.
( ,
),
,
, .
, uv
( S 7 , Jones, 50, Paris).
S WHERE STATUS > 25 S WHERE CITY = ' Paris'. , ,
. , ,
,

. , INSERT
.
, SA SB. SA , STATUS 25, SB (. 10.3). , uv
SA UNION SB, INSERT
. (S6, Smith, 50,Rome) UV
SA, , -,
. (S7, Jones, 50, Paris) UV
SA SB!
, (
" ").
""
. , ,

4

-
.

408

II.

(.. ) , , , .
(, ) 13.6 13.

. 10.3. SA SB ( )
UNION .
DELETE.
, (, DELETE
,
). ,
.
,
. ,

.
, .
UPDATE. , , ,
. ,
-
( ..), . , . , DELETE ,
. , (-, - ). ,
,
( ,
). , ,
, ,

.

10.

409

, , , , , , , DELETE (
, , , ).
UPDATE, , , ,
. , . 10.3,
(S5, Adams ,30, Athens) UV (S5, Adams, 15, Paris)
SA SB.

A INTERSECT .
- ( ). , , ,
A INTERSECT (PA) AND (PB). .
INSERT. . , (, ,
).
, .
DELETE.
(,
,
). ( )
, .
UPDATE. ,
, .

(,
,
).
, , -,
. ,
,
(,
,

410

II.
).
, .


A MINUS (
(PA) AND NOT (PB)).
INSERT.
. .
DELETE.
.
UPDATE. ,
.

.
.

, V : A WHERE p, . v .
(PA) AND (p)
, S WHERE CITY = 'London'
(PS) AND (CITY = 'London'), PS
.
A WHERE p.
INSERT. .
.
DELETE. .
UPDATE. ,
, .
-
.
.
. LS .
VAR LS VIEW
S WHERE CITY = 'London' ;
. 10.4 .

10.

411

. 10.4. LS ( )
LS (S6, Green, 20, London)
. s
, , LS.
LS ( S 1 , Green, 20, London)
,
S (, , LS). ,
{S#}.
LS (S,Green, 20, Athens)
, CITY = ' London'.
LS ( S 1 , Smith, 20, London)
. S ,
, LS.
LS (S1, Smith, 20, London)
(S6, Green, 20, London) .
( S 1 , Smith, 20, London) (S1, Smith, 20,
London) (S1, Smith, 20, Athens) (
, ).

. ( )
, , X Y . , X Y
, {} . (). , , , : " Y, (, )
". , S
S#, SNAME CITY. (s, , ), ,
t, ( s , n , t , c )
S.
{}.
INSERT. () , ,
, Y (
, ,
.. Y " ").
(, ), , .

412

II.

. ( ) ( 19), ,
,
.
DELETE. ,
,
{X}.
. , X , , {}, . ,
. UPDATE (. ).
UPDATE. () , , ('
) (). ,
, , X,
Y .
, , . (' , ), .
. " ", , 5 " " ( ). ,
UPDATE ( ) Y , ,
INSERT.
. SC .
SC { S#, CITY }
. 10.5 .

. 10.5. SC (, )

10.

413

SC ( S 6 , Athens) .
s
( S 6 , n , t,Athens), t ,
SNAME STATUS, .
SC (S1, Athens) ,
S ( , SC). , {S#}.
SC (s1,London) .
S1 S.
( S 1 , London) SC
( S 1 , Athens) .
S ( S 1 , Smith, 2 0 , London)
( S 1 , Smith, 2 0 , Athens), (S1,n, t,Athens), t
. .
SC (SI, London)
(S2, London) (, ).
,
( ,
, s STATUS CITY).

V .
EXTEND A ADD AS X
, , .
V , .
( ) AND . X = ( )
V, , X (.. ).
.
,
, : -, ,
,
X, ; -,
X
.
, .

414

II.

INSERT. ,
. .
, ,
.
DELETE. , .
,
, .
UPDATE. , , '
, ' .

,
, X.
',
' , .
. VPX .
EXTEND P ADD ( WEIGHT * 454 ) AS GMWT
. 10.6 .

. 10.6. VPX ( )
(7, Cog, Red, 12, Paris, 5448)
(7, Cog, Red, 12, Paris)
.
(7,Cog,Red, 12, Paris, 5449)
(, ).
(P1, Cog, Red, 12, Paris, 5448)
(, ).
1
1 .
1 (Pl,Nut,
Red, 10, Paris, 4540) (P1,Nut,
Red, 12, London) (Pl,Nut, Red, 10, Paris).
2 ( ) , GMWT
WEIGHT, 454 ( ).

10.

415


( ,
) , ( )
( , )
, " ", " "
" ".
, ,
. ,
, , .
, ,
,
, .

, ,
. :
(),

;
(),
e .
, [12.2] ,
, , "
- " (, , ,
, ,
). , .
. ,
, . ,
, . ,
, ,
, . ,
, .
, .
, . . (" ", "
", " ").

416

II.

J = A JOIN . ( 7.4 7) , J, , {, Y}, {Y, Z}


{X, Y, Z}. . PJ J .
( ) AND ( )
j "
" j (.. , j , Z), " "
j (.. , j ,
). ,
, , , , , , . , s SP s# .
(s,n, t,c,p,q) , (s,
n, t , c ) S, (s,p, q)
SP.
J = A

JOIN

INSERT. j PJ. 5 j ,
. j , .
DELETE.
,
.
UPDATE. ,
J.
-
,
, , -
.
,
.
, .
.
.
5
, INSERT , j
- , , , (. ).
, DELETE UPDATE.
.

10.

417

1: " "
, , " "
"( ) ( )". ,
, ,
, . , Y,
, ,
.



S () s#.
,
, SR, S# REST,
s# , REST
. , SR
, S.

, s JOIN SR. ,
SR,
S?
2: " "
" " "(
) ( )". , ,
,
. , Y, , (, ),
.
. ,
" " " ".
. SSP .
S JOIN SP
(, " ".) . 10.7.
SSP (S4,Clark,20,London,,100)
(S4, , 100)
SP ( ).
SSP (S5, Adams , 3 0 , Athens, , 100)
(S5, , 100)
SP (, ).

418

II.

SSP (S6, Green, 20, London, 6, 100)


(S6, Green, 20, London)
S (S6, 6,100) SP ( ).
. ,
SP s. , ,
SP S6,
S6 1.
INSERT, ,
,
, ,
(S6, Green, 2 0 , London) SP, S6.

. 10.7. SSP ( )
SSP (S4,clark, 20, Athens, , 100)
(, ).
SSP (SI, Smith, 20, London, PI, 400)
(, ).
SSP ( S3,Blake, 30, Paris, P2, 200)
(S3, Blake, 30, Paris)
S (S3, 2, 2 00) SP.
SSP (S1, Smith, 20, London, P1, 300)
"" ( ; .
) ( S1, Smith, 2 0 , London)
S ( S l , P l , 3 0 0 ) SP.
. , , .
NO ACTION RESTRICT, .
CASCADE,

10.

419

, SP ( , SSP), S1.
. SSP (S1, Smith, 20,London, P1, 3
00) ( S 1 , Smith, 20, London, P1, 400)
(S1, P1, 300)
SP ( S l , P l , 4 0 0 ) .
SSP (SI, Smith, 20, London, P1, 300)
(S1, Smith, 2 0 , Athens, PI, 400)

(S1, Smith, 20, London)


S ( S 1 , Smith,20,Athens) ( S l , P l , 3 0 0 )
SP (S1, P1, 400).
SSP ( S1, Smith, 20, London, P1, 300)
(S6, Smith, 20, London, P1, 300) "
" ( ; . )
(S1, Smith, 20, London) S
( S 6 , Smith, 20, London) ( S l , P l , 3 0 0 )
SPC ( S 6 , 1, 300).
. , ,
.
.
3: " "
" "
"( ) ( )". ,
, , ,
, .
. , .
S JOIN P
S CITY "
". . 10.8.
( S 7 , Bruce, 15, Oslo, P8,Wheel, White, 25)
(S7, Bruce, 15, Oslo)
S ( 8 , Wheel, White, 25, Oslo)
( ).
(SI, Smith, 20, London, P7, Washer, Red, 5)
(7, Washer, Red, 5,
London) (
(S1, Smith, 20, London, P7,Washer, Red, 5),
, (S4, Clark, 20, London, P7,Washer,Red, 5 ) ) .

420

. 10.8. S CITY
(S6, Green, 20, London, 7, Washer, Red, 5)
(S6, Green, 20, London)
S (7,Washer,Red, 5, London)
( ).
(SI, Smith, 20, London, PI,Nut, Red, 12)
(SI, Smith, 20, London)
S (PI,Nut,Red, 12,London)
( ).
.

. , ,
-, , ,
, . .
. .
. 7.4 7,
(
A JOIN A TIMES ,
).
(A TIMES )
(,
A INTERSECT ).
. (SUMMARIZE)
.

.
. , ,

10.

421

, .
, . . , .
SUMMARIZE SP BY { S# } ADD SUM ( QTY ) AS TOTQTY
, , S1,
. , , (S4, 900), (S4, 800) , , TOTQTY
QTY.
(S5, 0) , (,
).
. ,
, [3.3].
Tclose.
.
10.5. ( )
, ,
(snapshot) [10.1]. , . ,
, , , , , .. , ( , )
, , .
VAR P2SC SNAPSHOT
( ( S JOIN SP ) WHERE P# = P# ('P2') ) { S#,
CITY } REFRESH EVERY DAY ;
, .
1.
( P2SC) ,
(
; . 2).
2. ( ,
EVERY DAY) , ..
,
.
, P2SC , , 24 ( ,
).

422

II

, (
)
, . ,
.
(, ),
, ,
(..
).
,
, , ,
.
.
( , , 21 22). ,
(. 1),
( . 1).
.
VAR <relvar name> SNAPSHOT <relation
exp> <candidate key def list>
REFRESH EVERY <now and then> ;

<now and then>, , , : MONTH
(), WEEK (), HOUR (), MINUTES (n ), MONDAY (),
WEEKDAY ( ) .. ,
, , REFRESH
[ON] EVERY UPDATE.
DROP,
.
DROP VAR <relvar name> ;
<relvar name> .
. , ,
- . RESTRICT CASCADE. .
, . ,
( ) 6 (.
" " 22). , ,
6

( ) " " , , (.. REFRESH ON EVERY UPDATE).

10.

423

, .
. , , , . ( ,
, .) ,
, ,
, . ,
( ) ,
! , .
, ,
.
. , ,

( , ), ,
.
10.6. SQL
,
SQL ( SQL
). , CREATE VIEW, . (
, ,
"F".)
CREATE VIEW <view name> AS <table exp>
[ WITH [ <qualiier> ] CHECK OPTION ] ;

1. <table exp>
.
2. WITH CHECK OPTION, , ,
(INSERT) (UPDATE)
,
. ,
, WITH CHECK OPTION
, ..
. , 10.4,
, .
WITH CHECK
OPTION 7 [10.5].
7

, . , SQL
, WITH CHECK OPTION
SQL.

424

II.

1. CREATE VIEW GOOD_SUPPLIER


AS SELECT S.S#, S.STATUS, S.CITY
FROM
S
WHERE S.STATUS > 15
WITH CHECK OPTION ;
2. CREATE VIEW REDPART
AS SELECT P.P#, P.NAME, P.WEIGHT AS WT, P.CITY
FROM
P
WHERE P.COLOR =
'Red' WITH CHECK OPTION
;
3 . CREATE VIEW PQ
AS SELECT P.P#, ( SELECT SUM (
SP.QTY ) FROM
SP
WHERE SP.P# = P.P# ) AS
TOTQTY FROM P ;
SQL ,
WITH CHECK OPTION .
4. CREATE VIEW CITY_PAIR
AS SELECT DISTINCT S.CITY AS SCITY, P.CITY AS
PCITY FROM S, SP, P WHERE S.S# = SP.S# AND
SP.P# = P.P# ;
SQL , WITH CHECK OPTION .
5. CREATE VIEW HEAVY_REDPART
AS SELECT RP.P#, RP.PNAME, RP.WT, RP.CITY
FROM REDPART AS RP
WHERE RP.WT > 12.0
WITH CHECK OPTION ;
DROP VIEW,
.
DROP VIEW <view name> <behavior> ;
( ) <behavior>,
, RESTRICT CASCADE.
RESTRICT, - (,
), DROP . CASCADE, DROP
DROP ...
CASCADE ,
.

10.3, SQL . , ,
, SQL: 1992.

10.

425


SQL .
-
! , SQL
"", 8.
( ).
<query expression^ QE1,
, <query expression>
juery specification^ QE2, QE1, .
) QE1 QE2 ,
, < join query expression>,
9 UNION DISTINCT, EXCEPT ALL EXCEPT
DISTINCT.
) QE1 ,
(Non Join Query Expression NJQE), UNION
ALL, :
NJQE <query pression>, LO, <guery term>, RO,
L0, -, R0,
-;
NJQE
, , , L0 RO,
, .
) QE1 QE2 ,
, < join query expression>,
INTERSECT.
) QE2 .
: -, , , , -, ,
, , ,
, (updatable
column), , - (leaf generally underlying
table), , (non join query term), ,
, .
8
[10.11]: " SQL (
) ".
9
8, SQL: 1999
DISTINCT ALL UNION,
INTERSECT EXCEPT. , ALL
DISTINCT SELECT. ,
UNION, INTERSECT EXCEPT DISTINCT, SELECT
ALL.

426

II.


, SQL.
, SQL , .
1. , /
.
2. , " " "
" 10 ( " "
"").
3. , UNION ALL INTERSECT
.
4. , 1 3.
, - ,
SQL , , , SQL . , SQL
, , , 11 ( UPDATE DELETE, INSERT, ,
). 1,
. ,
SQL ,
.
1. , ,
, ..
JOIN, UNION, INTERSECT EXCEPT.
2. SELECT
DISTINCT.
3. SELECT (
, "", *)
(,
AS), (. . 5),
10
" " . SQL
,
" ". ( ,
" ",
, ) ,
, , ,
, , SQL
.
1
SQL , ,
.
9 10, "
" 10.4.

10.

4.
5.

6.

7.
8.

427


.
FROM
.
,
, . 18.
. , , (. . 3).
WHERE
, FROM, ,
FROM, . 4.
GROUP BY.
HAVING.

10.7.
, , .
.

, ,
.
.
100% ( , ,
).
100% ( ,
, ).
(, , )
,
.
, .
,
, , , , ,
.
.
.
: .

, , , . (
, , , ) .
, ( ,
). ,
SQL, .

428

II.

10.1. , .
10.2. ,
, , .
10.3. SP,
, SPJ,
, .
10.4. ,
, ( ,
),
si 1.
10.5. , .
VAR HEAVYWEIGHT VIEW
( ( RENAME ( WEIGHT AS WT, COLOR AS COL ) )
WHERE WT > WEIGHT ( 14.0 ) ) { P#, WT, COL } ;
.
) HEAVYWEIGHT WHERE COL = COLOR ('Green')
) ( EXTEND HEAVYWEIGHT ADD ( WT + WEIGHT ( 5.3 ) ) AS WTP )
{ P#, WTP }
B) INSERT HEAVYWEIGHT
RELATION { TUPLE { P# P# ('P99'),
WT WEIGHT ( 12.0 ) ,
COL COLOR ('Purple') } } ;
) DELETE HEAVYWEIGHT WHERE WT < WEIGHT ( 10.0 ) ;
) UPDATE HEAVYWEIGHT WHERE WT = WEIGHT ( 18.0
) { COL := 'White 1 } ;
10.6. , . 10.5
HEAVYWEIGHT .

VAR HEAVYWEIGHT VIEW ( ( ( EXTEND P


ADD ( WEIGHT * 454 ) AS WT )
RENAME COLOR AS COL ) WHERE WT > WEIGHT ( 6356.0 ) )
{ P#, WT, COL } ;
( WT , .) . 10.5 .
10.7. ,
, 10.1.
10.8. ORDER BY (
,
!). , .

10.

429

10.9. 9 ,
( ). ,
.
10.10.
? ?
10.11. , R
, B, , A UNION

R, A INTERSECT
. ?
10.12. B ,
A INTERSECT A JOIN (
" ", ,
,
, ).
, 10.4, ,
?
10.13. , A INTERSECT A MINUS
(A MINUS ) MINUS ( MINUS A).
, 10.4,
, ?
10.14. , 10.4, ,
INSERT DELETE
.
,
, ?
10.15. 10.2 ( )

s
SNC ST. ,
.
?
10.16. SQL
.
) -
, ?
) ? (,
,
SQL: 1999, 10.6.)
10.17. ,
.
.
a) S { S#, SNAME, STATUS, CITY }
SP { S#, P#, QTY }

430

II.

) SSP { S#, SNAME, STATUS, CITY, #,


QTY }' XSS { S#, SNAME, STATUS, CITY
}
. , ,
SSP ,
, , XSS ,
. ( ,
, , .)
. (. 9, ).
- ? , ?
10.18. . 10.1 10.4 SQL.
10.19. , ,
10.4, ,
, ()
, ,
SP (..
S ).
.
10.20. ( !)
,
3.2 3, , .

10.1. Adiba M. Derived Relations: A Unified Mechanism for Views, Snapshots, and
Distributed Data // Proc. 1981 Int. Conf. on Very Large Data Bases. Cannes,
France. September 1981. . : Adiba M.E., Lindsay
B.G. Database Snapshots// IBM Research Report RJ2772. March 1980.
, .
, , ..
.
10.2. Buff H.W. Why Codd f s Rule 6 Must Be Reformulated // ACM SIGMOD.December 1988. 17, 4.
1985 (Codd) , , , " ,
, " [10.3]. 6 , " , ",
. (Buff) ,

10.

10.3.
10.4.

10.5.
10.6.

10.7.

10.8.

431

, ..
( ) . (McGoveran) [10.11],
" ".
(, ),
, . : " ,
, ; , , " [10.11].
. F. Codd: "Is Your DBMS Really Relational?" "Does Your DBMS Run by the
Rules?" Computerworld (October Hand 21, 1985).
Chamberlin D.D., Gray J.N., Traiger I.L. Views, Authorization, and Locking in a
Relational Data Base System // Proc. NCC 44. Anaheim, Calif. Montvale, N.J.:
AFIPS Press.-May 1975.
,
System R (, ,
SQL/DS DB2, SQL ..). . [10.12], University Ingres.
Darwen H. Without Check Option // Date C. J., Darwen H. Relational Database
Writings 1989-1991. Reading, Mass.: Addison-Wesley, 1992.
Date C.J., McGoveran D. "Updating Union, Intersection, and Difference Views"
"Updating Joins and Other Views" // Date J. Relational Database Writings 1991
1994. Reading, Mass.: Addison-Wesley, 1995.

, 10.4. () [ 10.11].
Dayal U., Bernstein P.A. On the Correct Translation of Update Operations on Relational
Views//ACM TODS. September 1982. 7, 3.

( , , ). .
Furtado A.L., Casanova M.A. Updating Relational Views// [18.1].

. , ,
, .
(.. , ). , , ,

432

II.

,
.
() ,
.
, ( 1985 ).
, . 10.9. Goodman N. View Update Is
Practical // InfoDB 5, 2 (Summer 1990).
.
( ): " (Dayal)
(Bernstein) [10.7] , , , . (Buff) [10.2] ,
.
, .
, .
". .
.
10.10. Keller A.M. Algorithms for Translating View Updates to Database Updates for Views
Involving Selections, Projections, and Joins // Proc. 4th ACM SIGACT-SIGMOD
Symposium on Principles of Database Systems. Portland, Ore. March 1985.
, : , , ,
DELETEINSERT
UPDATE. , . , . , DELETE
UPDATE (, , ,
London CITY Paris).
, (Keller),
DELETE v ( V , v = A MINUS ),
INSERT , DELETE . ,
6.
10.11. McGoveran D.O. Accessing and Updating Views and Relations in a Relational Database //
U.S. Patent Application 10/114 609. April 2002.
10.12. Stonebraker M.R. Implementation of Views and Integrity Constraints by Query
Modification // Proc. ACM SIGMOD Intern. Conf. on Management of Data. San
Jose, Calif. May 1975.
. [10.4].

,
.
:
, . ,
,
. ,
.
,
.
, (
) ,
. ,
. ,
. ,
.
)
. , ""

(.. ) ,

,
. ,
2,
.

1
, , .
, ,
.

434

III.
.
, . , , ,
. , .

, ,
, ,
. ( ,
, - ,

.) , "
" . , , (,
). ,

.
, , , ,
, ,
. ,
,

( )
(, ),
.
,
, . ,
,
, .
,
, .

2 . ,
.
,
. ,
,
, , .
,
2

"" , " , " (. Chambers Twentieth Century Dictionary).

III.

435

,
. , 14
, , . , .
, .
)
. , ,
.
.
)
. , , ,
.
,
.
, , , ..
(..
) .
( 2), ,
, ..
, ,
, , ,
.. , ,
, , ,
.
, ,
,
. ,
, .
,
( [14.12], [14.44]).
. 11
, 12 13 ,
. 14
, ,
"" ( ER-) ,
(
).

11

11.1.
11.2.
11.3.
11.4.
11.5.
11.6.
11.7.

11.1.
,
(Hugh Darwen) "
, ".
, , ,
, 12.
,
;
II III.
, (
) " "
. ,
SP
{S#,P#} {QTY}. ,

.

438

III.

s# # 1 QTY.
QTY ( ) S# #.
, . 3.8 (. . 128) SP .
, .
11.2
, , ,
, , . ,
, ,
. , 11.311.6,
. ,
11.7, .
. ,
. ,
, 11.2 11.3.
, , .
.
: functional dependence
functional dependency. ,
dependence , dependency .
,
dependencies ,
dependences.
.
11.2.
,
s#, # QTY CITY,
1

, ,
" " (. 9).
,
.
, , (
, ) , ,
, .

11.

439

. 11.1. SCP
. ,
SCP. . 11.1
.

, , , -, ( ), -,
,
( ). , .
, . r , X Y
r. Y
,
X Y
( "X Y", "X Y")
, r
Y r. , r , Y.
, SCP (. . 11.1)
, SCP S# CITY.
{ S# } { CITY }
, .
{S#,#}{QTY}
{S#,P#}{CITY}
{S#,P#}{CITY,QTY}
{S#,P#}{S#}
{S#,P#}{S#,P#,CITY,QTY}
{S#} {QTY}
{QTY} {S#}
. .

440

III.


, , . , . , . .
S# CITY
, , ..
. , ,
, ,
. ,
SCP
S# CITY
SCP,
. SCP
. , "" (..
SCP),
SCP,
. ,

Tutorial D, 9.
CONSTRAINT S#_CITY_FD
FORALL SCPX FORALL SCPY
( IF SCPX.S# = SCPY.S#
THEN SCPX.CITY = SCPY.CITY END IF ) ;
SCPX SCPY ,
SCP. s# CITY .
. .

( , ,
).
, . R , Y !
R. Y , |

X Y
( " Y", "X Y")
,
R X R

11.

441

Y R. , R, R
X, Y.
, ( ).
,
( ) SCP.
{ S#, #
{ S#, #
{ S#, P#
{ S#, P#
{ S#, P#
{ S# }

}
}
}
}
}

QTY
CITY
{ CITY, QTY }
S#
{ S#, P#, CITY, QTY }
CITY

, , ,
, . 11.1, ""
SCP.
S# QTY
QTY S#
, , () " ", , . 11.1, SCP.
, R, Y R X ( 9.10 9
). ,
, .
# { #, PNAME, COLOR, WEIGHT, CITY }
, R 2, R . , SCP, S# CITY ,

( . 11.1).
.
, , , , ,
, SCP.
2
, ( 10.3),
( 10.5), a R (!).

442

III.

(. ,
SCP.)
.
? , ,
, , . , s ,
( ) S
S . ,

,
s.
.
11.3.
.
,
..
.
, . , SCP, .
{ S#,

# } S#

,
, ( ) .
,
, ,
.
, , .
11.4.
,
. , .
{ S#,

# } { CITY, QTY }

.
{ S#, # }
CITY { S#, P# }
QTY

11.

443

R , ,
. , B C , , ..
, .
, s, s S+ ( ,
, ). ,
S+ S.
(Armstrong) [11.2],
( ).
, . , R. , .
.
1. . ,
.
2. . B, .
3. . B BC, .
(, ). ,
, s
, S, s .
,
(.. ,
S). , S+.
S+, . (
, D R.)
4. . .
5. . , B A C.
6. .

, .

7. . B D, BD.
, (Darwen) [11.7] , .

444

III.

8.

).

B C D, ( - ) BD ( " "
, "-"

, [11.7].
. R , , , D, E, F
.



CD
EF
, ( );
, , B C ,
B C , B C .
. ,
, : , ,
() , D ,
( ),
, F ,
.
, R AD F,
.
1. BC ().
2. C ( . 1 ).
3. AD CD
( . 2 ).
4. CD EF
().
5. AD EF
( . 3 4 ).
6. AD F
( . 5 ).
11.5.
, S+ S
: "
, ". , . ,
, , () z ,
. , , R, z S,

11.
445
R, 3 R, Z, .. Z+ Z S. . 11.2.
. .

. 11.2. Z+ Z S
. , R , , , D,
F .

CD

CF

EF

{, } + {, }
.
1. CLOSURE [ Z, S ]
{, }.
2.
. (
) ,
CLOSURE [ Z, S ]. ,
B C. CLOSURE
[ Z , S] {, , }.
3. ( CF) ,

, , , .
4. ( ) CLOSURE
[ Z , S] ,
{, B, , }.
5. ( CD EF) CLOSURE
[ Z , S] .
3
, :
, .
, ""
. ,
.

446

III.

6. .
, { A , B , C , E , F } , a
.
7. ,
CLOSURE [Z,S]
{,} + = { A , B , C , E , F } .
, Z ( ) R, a S , R, , R
z , , Z Z', Z' Z+
z, S. S+ S
, Z.
: S , Y S, ,
Y + X
s. , , Y S+
S, S+.
. , 9. R
R, (
)
. , R R,

R. , , +

R. ( ,
, ).
11.6.
S1 S2 . , si, S2 (.. S1+ S2+,

11.

447

S2 4 si. ,
, S2,
,
S1.
, S2 S1, S1
S2 (.. S1+=S2+),
S1 S2 . , S1 S2 ,
, S2, , S1, .
5
, .
1. () S
(.. ).
2. () S,
, , ..
S+ (
S - , S).
.
3. S
s S+ (.. s
, S).
. 2 3 , S+ , - .
.
, , , .
# PNAME
# COLOR
# WEIGHT
# CITY
, : ,
, , . ,

(.. ). , .
1. # { PNAME, COLOR }
# WEIGHT
# CITY
4

""
( ).
5
.

448

III.

( .)
2. { #, PNAME } COLOR
# PNAME
# WEIGHT
# CITY
( , PNAME , .. .)
3. # #
# PNAME
# COLOR
# WEIGHT
# CITY
( .)
, ,
. .
s. , , ,
s . f S
f. f
S+, . f, s, ,
S S+; f S.
S S.
. R , , , D
.





D
,
.
1. , ,
.

11.

449

, ,
.
2. D ,
,
. , D,
D. ,
D .
3. , ,
C,
CB, .
4. , B B C,
.
.


D
I,
s, S. , S I ( , I
s+). ,

(. . 11.12).
11.7.
" " (
). R ( R) R
, R
.

;
, ()
().
.
S S+
, S. S
S+.
S+

450

III.

s (
). .
z R S, R, z+ Z S
R, Z
S+. z+ R, Z R ( , , ).
z+ z s ,
, , Y
s+ ( X S+
, Y +).
s1 S2
, , .. S1+=S2+.

. , ,
-, ; -,
; -,
. I
, S, I S.
,
,
. , .
.
.
, , .
,
(..
), .
.

, , . 13
,
(MVD, JD IND); .

11.

451

,
, .

11.1. ,
.
) R .
( ,
), R?
) ,
. , ?
11.2. ,
?
11.3. , ,
.
11.4. , ,
, .
11.5. , .
?
?
11.6. :
) ;
)
.
11.7. ,
SP.
11.8. ,
R{A,B,C,D,E,F,G}.



DE AEF
G
{,}+ . ACF DG?
11.9.
S1 S2.
11.10.
.

452

III.

11.11. , )
, R{, , , D, }.
1.

2.

D AC

11.12.
, R{ , , , D, E, F}.


D
ACD
BE
FA
CF BD
D EF
11.13. TIMETABLE .
D (15)
(16)


L
( d , p , c , t, 1)
, 1 t
(d,p) ( , 10.4). ,
, , , . ? ?
11.14. NADDR NAME ( ),
STREET (), CITY (), STATE () ZIP ( ).
, -,
, -, ,
.
.
?
11.15. ,
?
11.16. R , , , D, E, F, G, , I J,
.
ABD

G
F

11.

453

J
CJ I
G

? ?

11.1,
;
[11.1], [11.3] [11.10],
( ).
11.1. Abiteboul S., Hull R., Vianu V. Foundations of Databases // Reading, Mass.: AddisonWesley, 1995.
11.2. Armstrong W. W. Dependency Structures of Data Base Relationships // Proc. IFIP
Congress. Stockholm, Sweden, 1974.
(..
),
.
11.3. Atzeni P., De Antonellis V. Relational Database Theory // Redwood City, Calif.:
Benjamin/Cummings, 1993.
11.4. Casanova M.A., Fagin R., Papadimitriou C.H. Inclusion Dependencies and Their
Interaction with Functional Dependencies // Proc. 1st ACM SIGACT-SIGMOD
Symposium on Principles of Database Systems. Los Angeles, Calif. March 1982.
(INclusion Dependency IND)
. ,
SP.S# S.S#
( , ) ,
SP.S# ( ) S. S#. , , ,
,
, .
. ,
" ". , .

, ( )
.

454

III.
1. .
2. CD, D.
3. B B C, C.

11.5. Casey R.G., Delobel . Decomposition of a Data Base and the Theory of Boolean
Switching Functions// IBM J. R&D. September 1973. 17, 5.
, ( ) .
, , ,
( ) ,
,

(. 18). , (.. ; 12)

, . ,
, .
, . [ 11.8] , 13.
11.6. Codd E.F. Further Normalization of the Data Base Relational Model // Rustin R.J.
(ed.), Data Base Systems, Courant Computer Science Symposia Series 6. Englewood
Cliffs, N.J.: Prentice-Hall, 1972.
(
IBM,
).
(Further Normalization), , , 12
(

). ,
. 11.1, (., , [11.7]).
11.7. Darwen H. The Role of Functional Dependence in Query Decomposition // Date C.J.,
Darwen H. Relational Database Writings 19891991. Reading, Mass.: AddisonWesley, 1992.

,

455

(
), .
.
, 9 10 " ".
, , .
. SQL: 1999, -,
,
(. 10), -,
, , " " (, SELECT).
.
SELECT S.S#, S.CITY, SUM ( SP.QTY ) AS TQ
FROM S, SP
WHERE S.S# = SP.S#
GROUP BY S.S# ;
SQL: 1992, s. CITY
SELECT, GROUP BY,
SQL: 1999, SQL
, S s# CITY.
11.8. Fagin R. Functional Dependencies in a Relational Database and Propositional Logic //
IBM J.R&D. - November 1977. - 21, 6.
, [11.2] . , , , f
S , ,
f, ,
S.
11.9. Lucchesi C.L., Osborn S.L. Candidate Keys for Relations // J. . and Sys.
Sciences. 1978. 17, 2.
, ,
.
11.10. Maier D. The Theory of Relational Databases // Rockville, Md.: Computer Science
Press, 1983.

12
:
1, 2,
3
12.1.
12.2.
12.3.
12.4.
12.5.
12.6.
12.7.


,

-
,

12.1.

.
S

{ S#, SNAME,
STATUS, CITY }
PRIMARY KEY { S# }

{ P#, PNAME, COLOR,


WEIGHT, CITY } PRIMARY KEY
{ P# }

SP { S#, P#, QTY


PRIMARY KEY {
FOREIGN KEY {
FOREIGN KEY {

}
S#, P# }
S# } REFERENCES S
P# } REFERENCES P

458

III.

. ( ) , . .
. ,
(s, P SP), ,
. , " ", CITY S, COLOR
, QTY SP .. ? ,
, , . , , CITY
S SP. (
, "
" , .)
. 12.1 , ( . 11.1 11).
. , SP, ,
SCP, 11.
. 12.1
. , SCP
S1 ,
; SCP
S2 , , ..
, , ,
, .
, , . ,
1 S1
, . ,
"
" (.. ). ,
, ,
,
.
, 6,
. , ,
.
,
1
( !) ,
. ,
(
S1 ).
: ,
, (.. )
. ,
.

12. : 1, 2,

459

.
, ( )
, 1. , " " " 1"
, , " " (
, ).
, .

. 12.1. SCP

. SCP, . 12.1. . SCP

" " : S#
CITY, s#, P# QTY.

,
, . , ,
. ,
( 2) , 1 , 12.3.
. 12.2 , . (1, 2 ) (Codd) [11.6].
. 12.2, 1, 1 2, 2 . ,
, ,
" " ( , ), , ,

460

III.

, " ", . ,
, .

. 12.2.
[11.6] , , 2, , , . (
, , , .) . , , ..
(, ,
) ( , 2).
, ,
( ).
, , , 12.5, [11.6]
. , () [12.2], ,

, .
, - .
(Fagin) [12.8] ,
(4), , - . [12.9]
, -

12. : 1, 2,

461

(); 5.
. 12.2, 4, 4 5.
, , .
.
, , . 12.2, 5 ""
( ) .
13.

.
13. , .
12.2
() . (, -.) , 12.3,
, . 12.4
, .. " " , , , . 12.5
, 12.6 , . , 12.7 .
, , ,
. , , " ",
" " ,
, . ,
, .
[12.5].
, .
1. , ,
"" (.. ). ,
{ ) , ( . 12.7). , , . ,
.
, ,

462

III.

. 14 ,

.
2. ,
. ,

. , , 14 . ,
, , - .
,
. ,
.
12.2.

,
,
. , ,
, , , .. .
, , . , ,
.

S s#, STATUS CITY ( SNAME ). . 12.3 : .

. 12.3. S

12. : 1, 2,

463

,
.
1. , SST
SC , S3 30
(Paris), S5 30
(Athens). ,
.
2. , , ,
30, ,
. ,
.
, ,
? , ,
,
, ..
SST, SC STC
S. ,
.
. II , "SST S"
"SST , S, ".
, .
, ,
SST SC S. ,
SST SC S ,
, 2. , ""
,
, .. .
, ( )
.
, . R1
R2 R, R. , R1 R2

2
, S
"" ,
, S. {.
.) , .

464

III.

R? . S
.
S#
STATUS S#
CITY
, S
, ,

{S#, STATUS} {S#,CITY}. , , , (Heath) [12.4].
. R{, , } , ,
. R , R {,} {,}.
, s#, STATUS,
CITY, , , S
(S#, STATUS} {S#,CITY} . ,
S
{S#, STATUS} {STATUS,CITY}. ,
3. ,
, .. S# STATUS
( {S#, STATUS}), S# CITY .
, R Rl, R2, ..., Rn , R Rl, R2,
..., Rn.
. , , R1,
R2, ..., Rn. , , . , S ()
{S#}, {S#, STATUS} {S#,CITY} , S
.
,
( ).

3
, "..., ...", " , ..." (. . 12.1,
). 13.2 13.

12. : 1, 2,

465


,
.
1. . 11, ;
, " ". , , SCP, 12.1, .
{ S#, # } CITY
# , .
S# CITY
( , CITY s#.)
, .
, , CITY 4
S#,
{s#, #}.
(
12.3).
2. . R I ( 11).
I ( ). , . 12.4
, , s, SP .
.

, 12.4.
S, SP

4
" " " " " " " ", (
). ,
.

466

III.

, . 12.4
( ) .
5,
- ; . - ,
. ,
,
.
3. . 11, .
, ,
( ). . ,
, S
S# CITY, ,
. .
,
,
.

, -
.
,
,
.

.
, .
12.3. ,
. , -,
, -,
. , ( )
. , 12.5, , .

5
, . I
, , ( "") I
.

12. : 1, 2,

467

,
, ,
. .
. , 1, 2

( ).
, .
{ ).
, (
) :
) ;
) .
()
.
,
.
,
- . ,
.
, ,
( ) , , PNAME (
), COLOR (), WEIGHT () CITY ()
(, , ..) {#} ( ).
,
.
{ ). ,
, , , , .
,
( ), ,
(, , , ),
.

.

468

III.

. 1
,
.
, 1, , , . ,
1 (.. , ), , .
, S SP, , .
FIRST { S#, STATUS, CITY, P#,
QTY } PRIMARY KEY { S#,
P# }
SCP, , 12.1. , , , .
CITY STATUS
( , STATUS CITY,
, , , 20.)
, SNAME . FIRST {S#, #}, , . 12.5.

. 12.5. FIRST
,
"" . ,
, , (, FIRST), , ,
, .
FIRST ,
: ,
STATUS CITY ( ),
, STATUS
CITY, , s# ( ).

12. : 1, 2,

469

, , . 12.6 FIRST.
, , 30
S3 10 , CITY
STATUS. ,
S1 CITY London ,
, London CITY 20
STATUS.
FIRST , . ,
INSERT, DELETE UPDATE. "", S# CITY.
, .
INSERT. FIRST , ,
. ,
. 12.6 S5, , - ,
. ( 10.4 10, , ,
.)

. 12.6. FIRST
DELETE. FIRST , ,
,
, . ,
FIRST S3 s#

470

III.

2 #, ,
S3 . ( , .)
. ,
FIRST ,
, . , FIRST , .
.
, ..
,
( ). ,
: .
UPDATE. ,
FIRST , . , S1
,
FIRST , S1 London
( ),
( , S1, , ).
, , FIRST .
SECOND { S#, STATUS, CITY
} SP
{ S#, P#, QTY }
. 12.7, . 12.8. ,
S5 ( SECOND, SP). SP .
,
,
.
INSERT. , S5
, ,
SECOND, ,
.
DELETE. ,
S3 2.
SP,
, S3 , .

12. : 1, 2,

471

. 12.7. SECOND SP

. 12.8. SECOND SP
UPDATE. ,
SECOND (
{S#}). ,
S#-CITY . si ,
,
SECOND.
. 12.5 12.7, , FIRST SECOND SP , .
. , FIRST CITY , (), , (
STATUS).
.
6.
6

, 2 , .
(, , ).

472

III.

(
, ). ,

.
( SECOND, SP) ( , ,
{S#} {S#, p#}), FIRST
. ,
, ,
, 2.
1 ,
, ,
. SECOND SP 7 FIRST, FIRST SECOND SP S#.
, ,
, . R, .
R { , , , D }
PRIMARY KEY { , }
/* D */
, R1 R2.
R1 { A, D }
PRIMARY KEY { A }
R2 { , , }
PRIMARY KEY { , }
FOREIGN KEY { A } REFERENCES Rl
R
Rl R2 .
. ,
SECOND SP .
SP , .
. SECOND
7
, SECOND
(, S5),
FIRST (. . 11.8). , , .
.

12. : 1, 2,

473

.
- , , . , STATUS
s#, , ( CITY). ,
s# CITY, CITY STATUS. ,
11, , ,
.
.
(
"",
CITY STATUS.)
INSERT. ,
(, ,
50), ,
.
DELETE. SECOND
, ,
,
, . ,
SECOND S5
, 30. (

.)
.
SECOND .
, , .. , .
UPDATE. SECOND
(
). ,
20 30, SECOND
, London 20 (
).
( 20,
30).
( SECOND) .
SC { S#, CITY }
CS { CITY, STATUS }

474

III.

. 12.9, . 12.10. ,
(Rome) CS. , SECOND SC CS CITY.

. 12.9. SC CS

. 12.10. SC CS
, .
. . 12.7 12.9, , STATUS s#.
. , SECOND STATUS
, (.. ), , .
.
.
(
,
).
,

. .
. ,
- .
SC CS , , , {S#} {CITY}.
SECOND . ,

12. : 1, 2,

475

2, ,
. , , ,
.
8, 2 (, , 50).
, ,
. ,
R, .
R { , , }
PRIMARY KEY { A }
/* */
R , R1 R2.
R1 { , }
PRIMARY KEY { }
R2 { , }
PRIMARY KEY { A }
FOREIGN KEY { } REFERENCES Rl
R R1 R2
.
, , . , , , , .
, . ,
, , . , ,
,
, , , , .
, .
12.4.
,
.
SECOND
8
, "SECONDSP"
FIRST, 1, "SC-CS" SECOND,
2.

476

III.

S# CITY CITY STATUS , ,


S# STATUS ( . 12.11
). 12.3 , , SECOND, .

. 12.11. SECOND
SC { S#, CITY }
CS { CITY, STATUS }
" ".
( ).
SC { S#, CITY }
SS { S#, STATUS }
SC , .
, .
, . , -
, ,
.
. , , ,
(. . 12.11), ,
, . ,
9. , (.. ),
SECOND. ,
, SECOND. , , CITY STATUS.
( ,
; . ,
S1 .)
, .
9

, SC CS.

12. : 1, 2,

477

, CITY STATUS ( 9) , . ( ,

.)
,
S# STATUS, ,
: S# STATUS CITY STATUS.
, , , .
,
. , ,
,
, . (Rissanen)
[12.6] , R1 R2 R , :
R
Rl R2;
R1 R2
.
.
, CITY CS SECOND , . , ,
,
CITY STATUS , ,
, S#
.
. SECOND
{S#, STATUS } {CITY , STATUS} ,
. (. .)
[12.6] ,
, ( ). , ,
( ), . , S
,
. SP, , .
, ( ),
.
.

478

III.

i 1. R, Rl, R2, ..., Rn, R.


2. S,
R, S1, S2, ..., Sn, , , R1, R2, ..., Rn.
. 3. Si Ri ( i=l, 2, 3, ..., ).
( ) Si . , S.
,
Rl, R2, ..., Rn,
S1, S2, ..., Sn
S. ,
.
4. S ' S1, S2, ..., Sn.
, S' =S .
,
S S ' (
11.4 11).
5. S+
,

.
, , . ,
[8.13].
,
R (
) D ,
. , S, R. , .
1. D .
2. I S.
3. ,
X I.

12. : 1, 2,

479

4. I X
X Y1,X Y2,...,X Yn.
5. Yl, Y2, ..., Yn z.
6. D D R X z.
7. 46 X.
8. Al, A2, ..., An R (
), (..
D); D
D R 1, 2, ..., An.
9. D
R, D D R
R.
12.5. -
, (
), . , ,
[11.6], .
, , :
1. ( ) , ,
2.
3. (..
).
(Codd) [12.2].
, , 10
( ).
. 13 .
, ,
.

, 11 , ,
, . .

10
"" ,
-, (Heath) 1971 [11.4],
" ".

480

III.

.
- ,
.
, .
{ ). , .
, , .
, , , , ,
.
.
, , "
" .
, .
, ,
, , .
, ( )
, ,
.
, , FIRST SECOND,
, . , ,
SP, SC CS, , . FIRST , S#, CITY {S#, #},
{S#, P#} .
FIRST . SECOND, CITY
. , SP, SC CS ,
.
, (.. )
. , S{S#,
SNAME, STATUS, CITY} {S#} {SNAME} (.. ). (, , ),
STATUS CITY , .. 12.3 CITY STATUS
. , . 12.12.

12. : 1, 2,

481

. 12.12. S
, - : {SNAME}
( CITY> STATUS )
, S .
"" ,
,
. , , .
, . ,
.
. , 9,
.
.
, ,
.
SSP { S#,

SNAME,

P#, QTY }

{S#, P#}
{SNAME, P#}. ,
, s# SNAME, ( {S#}, {SNAME} , ). SSP . 12.13.

. 12.13. SSP ( )
, SSP
, FIRST SECOND (CM. 12.3),
SCP (. 12.1),
, . , , S1, Smith Robinson

482

III.

,
. , SSP ,
,
, . ,
SNAME {S#, #}, .
. ,
[ 11.6], , 12.3.
SSP
, .
SS { S#, SNAME
} SP { S#, P#,
QTY }
.
SS { S#, SNAME }
SP { SNAME, P#, QTY }
, ,
,
.
, " ". , , SSP, . ,
, ( ..).
, SS SP, , . " "
,
SS SP, SSP?
, ,
. , (, ,
) , ,
.
, , ,
. , ,
,
.. , .
, ,
. ,
"
" .
( ,
, , ).

12. : 1, 2,

483

SJT s, J , ,
, , .
(s, j , t) SJT ( )
, s j t. .
.
,
.
. 12.14 SJT.

. 12.14. SJT
?
{S, J} ,
J. , ,
, , J
. ,
SJT , . 12.15.

. 12.15. SJT
, {S, J} {S, }.
, SJT ,
, .
, , (Jones)
, , ,
(Prof . Brown) .
, , .
SJT , .

484

III.

ST { S, }
TJ { , J }
( , . 12.14),
, ,
(, ), ,
.
, . ,
ST TJ
, . ,
ST TJ , (.
12.4). ,
{S,

J}

,
,
J
. ,
ST (Smith)
(Prof . Brown) , ,
(Prof. Green). ,
TJ. , ,
( , ,
) . .
, ,
s JT , , (. 12.4) , . , , ,
( ""
). , ,
,
.
EXAM
S (), J () (). (s, j , )
EXAM , s
j . , .

12. : 1, 2,

485


, .
, . 12.16.

. 12.16.
EXAM
,
{S, J } H { J , P},
,
.
, .
- ,
. {.
.) ,
.
,
, , .
, , 1, 2, . ( , [12.2],
). , , .. ,
,

.
,
, R
D (
).
1. D ,
R.
2. D, ,
3 4.

486

III.

3. X > Y ,
.
4. D :
X Y , , BY.
12.6. ,

6, ,
(. 12.17). , ,
,
.
, ,
( , , ,
), .
, , . 12.17,
. .

1. (s#) 1.
2. (#), S1.
, .
1. ( SPQ WHERE TUPLE { # # ('1') } PQ { # } ) { S# }
2. ( ( SPQ WHERE S# = S# ('S1') ) UNGROUP PQ ) { P# }
, SPQ ,
, . 12.17.
,
,
SP.
.
.

1. 500 5,
S6.
2. 500 5,
S2.
SP
,
. ,
SPQ

11
, ..
(. 6).

12. : 1, 2,

487

( ,
, SP).
1. INSERT SPQ RELATION
{ TUPLE { S# S# ('S61),
PQ RELATION { TUPLE { P# P# ( ' P5 ' ) ,
QTY QTY ( 500 ) } } } } ;
2. UPDATE SPQ WHERE S# = S# ('S2')
{ INSERT PQ RELATION { TUPLE { P# P# { 'P5' ) ,
QTY QTY ( 500 ) } } } ;

. 12.17. SPQ ,

( , ) ,
, , .
, . ,

. , . 12.18
() RVK, .
. RVK!
Tutorial D , .
VAR RVK BASE RELATION
{ RVNAME NAME, CK RELATION { ATTRNAME NAME
} } KEY { RVNAME, CK } ;

488

III.

. . 12.3 ,
, (
)12.

. 12.18. RVK,

12.7.
, .
, , -. , ( , )
, ,
, , ..
,
. ,
( 5), ..
,
( 5). , , , .
12

! , RVK, , (.. CKNAME,


" ").

12. : 1, 2,

489

, ,
. ,
(.. ). , . , ,
,
.
11 , " , ".
, , , , ,
.
. , , (
) .
( ) , (Zaniolo) [12.7].
.
( ). , R, X
R R. R
,
X R .
1. X (.. ).
2. X R.
3.
R.
, ( ,
).
"" ,
-.

12.1. . ?
12.2. ,
. ?

490

III.

12.3. . 12.19 ,
. , , IMS (Information
Management System). .
.
(DEPARTMENT)
(EMPLOYEE), (PROJECT)
(OFFICE).
(JOB)
, .

(SALARY HISTORY), ,
.
(PHONE).

. 12.19. ,

.
: (),
() , .
: (),
, , ,
,
.
: () .
: (), ,
() .
,
. ,

12. : 1, 2,

491

.
12.4. ,
.

:
();
( ,
);
' '
;
;
.

:
:
- ;
- ;
;
( ):
- ;
- .
:
();
-;
;
;
.
. .
. , , .
12.5. , . 12.4
, , .
( ,

.) -
, . 12.4?
?
12.6. { . 11.13.) TIMETABLE
.
D. (1-5),

492

III.
. (16).
. .
. . .
S. .
L. .
( d , p , c , t , s , l )
, ( d , p ) s 1,
t . ,
, , . TIMETABLE .

12.7. ( . 11.14.) NADDR


NAME ( ), STREET, CITY, STATE ZIP.
, , -,
, -, ,
. NADDR , 2?
?
12.8. SPQ ,
, . 12.17. SPQ.

,
11, [11.6].
12.1. Bernstein P.A. Synthesizing Third Normal Form Relations from Functional
Dependencies //ACM TODS. December 1976. 1, 4.
"" "", .. ,
""
( ) "",
.
, ,
.
,
, , .
. [13.20], . ""

12. : 1, 2,

493

.
.
-

, , , . ( ,
.) .
( ) ,
. ,
, (..
) R, S T.
(
R{,}) (
S{B,C}) (
{,})
, , ,
, , , R , , s , ,
, . , . ,
( ). ,
(.. ), .
S T , 1 2.
12.2. Codd E.F. Recent Investigations into Relational Data Base Systems // Proc. IFIP
Congress. Stockholm, Sweden, 1974.
.
, , " ", ,
-.
, ,
( 1974 ).
12.3. Date C.J. A Normalization Problem // Relational Database Writings 1991-1994.
Reading, Mass.: Addison-Wesley, 1995.
, " , ".

494

III.
, : FLIGHT
, DESTINATION , HOUR , DAY
, GATE , PILOT .
{ FLIGHT } DESTINATION
{ FLIGHT } HOUR
{ DAY, FLIGHT } GATE
{ DAY, FLIGHT } PILOT
{ DAY, HOUR, GATE } DESTINATION
{ DAY, HOUR, GATE } FLIGHT
{ DAY, HOUR, GATE } PILOT
{ DAY, HOUR, PILOT } DESTINATION
{ DAY, HOUR, PILOT } FLIGHT
{ DAY, HOUR, PILOT } GATE
, , "" .

12.4. Heath I.J. Unacceptable File Operations in a Relational Database // Proc. 1971 ACM
SIGFIDET Workshop on Data Description, Access, and Control. San Diego, Calif.
November 1971.
, . , 12.2 . ,

.
12.5. Kent W. A Simple Guide to Five Normal Forms in Relational Database Theory //
CACM. - February 1983. - 26, 2.

(, ): , , (
).
12.6. Rissanen J. Independent Components of Relations // ACM TODS. December
1977. - 2, 4.
12.7. Zaniolo C. A New Normal Form for the Design of Relational Database Schemata //
ACM TODS. - September 1982. - 7, 3.
, 12.7
.
, (),
"
", (,
, " ", "
"). ,
[12.1] , , .

13
:

13.1.
13.2.
13.3.
13.4.
13.5.
13.6. ( )
13.7.
13.8.


13.1.

()
(.. , ,
).

(4 5). , 4
(),
. ,
5 ,
().
. 13.2

496

III.

4, 13.3 5; , 5
. , , , 11.
, .
13.4
, . 13.5
. 13.6
(orthogonal design). , 13.7 , 13.8 .
13.2.

( "" hierarchic), , .
, , ( . 13.1).
(COURSE), a
- (TEACHERS) -
(TEXTS) ( . 13.1 ).
, . ,
m
(m > 0n > 0). , , , . ,
, ,
. , ,
.
( 12.6 12) , . (, ,
; ) ,
COURSE, TEACHER TEXT, . 13.2. ,
* , TEACHERS
TEXTS . , (
, {COURSE} ).
. ,
.

13. : 497
. 13.2. ,

. 13.1.

. 13.1

, , :
(, t, ) ( )
, t
. , , , , .

( c , t l , x l ) ( c , t 2 , x 2 ) ,

(, t1, 2) (, t2 , xl) .

, , , , . ,
, ,
,
. ? , , . , ,

(, ), , {COURSE, TEACHER}
{COURSE, TEXT} (. 13.3).

498

III.

. 13.3. ,
, .
13.2
, . 13.3,
, ,
. ( , , .) ,
, ,
CTX, " ".
, ,
. , ,
CTX
"". ,
, , . ,
? .
( , ..
.)
,
. ,
. , ,
( ,
COURSE COURSE). 1 ,
, , , . (
, ,
.) ,
.
"", , , ,
1

, 4, 5
( ).

13. :

499

, , .
(Fagin)
, , 1977
[13.14]. ,
, (
, ). .
COURSE
COURSE

TEACHER
TEXT

, B
, . , COURSE TEACHER.
, ,
, .. COURSE TEACHER,
.
, " "
, t, ( , ) , , , .
, COURSE TEXT, .
.
. R - , ,
R.
,

( " " " "),


, R , , , .
( [13.14]), R{A, , } B
, . , ,
, .

.
COURSE

TEACHER | TEXT

,
,
. ,

500

III.

, , }
, .
, , , .
, , : - , ,
. ( ,
,
.
, .)
, .
. [13.14], .
. ,
R{A, B, }. R
{, B} {, } ,
R B | C.
( ,
[12.4], 12.) , [13.14],
. ( ,
, 12.)
. R
(4) ,
R,
,
R .
. , .
, (
) R K > X (..
). : R 4 ,
R
. , ,
, 4
.
CTX 4,
, , , . , CX, 4. , 4

13. :

501

, . , [13.14] , 4 , ..
4. ,
12.5 12 SJT, (
) .
, (Rissanen),
[12.6], , . , ,
R{A, B, C}, > B B > C, {, B} {, },
{, B} {, }. , B B
.
, ,
, (-). ,
,
,
( ), ,
. ,
{COURSE, TEACHERS}
{COURSE, TEXTS}, TEACHERS TEXTS .
(
, 4) , "", CTX, . , 4 ,
.
13.3.


,

. ,
4. , , , , . ,
"n- , ". ,
, , 1 < m m < .

502

III.

. n- > 2
(Aho), (Beeri) (Ullman) [13.1], = 3
(Nicolas) [13.26].
SPJ , , . 13.4 ( QTY
). ,
, 4. ,
.
1. (SP, PJ JS),
SPJ, .
2. SP PJ #.
3. JS
J# S#.
, SPJ () ,
SPJ. , SPJ 3-.
. , , ,
.
. .
, . 13.4 , ,
, . 3- SPJ (.. ,
),
, .
, , ,
" SPJ SP, PJ
JS", :
( s 1 , p1) SP
(1, j1) PJ,
( j l , s1) JS,
( s 1 , p1, j l ) SPJ.
, , (s1, p1, j1)
SP, PJ JS. ( , , ..
( s 1 , p1, j l ) SPJ, , ,
(s1, p1) SP,
SPJ .) ( s 1 , p1) SP
, ( s 1 , p1, j 2 ) SPJ

13. :

503

j2 ( (p1, j l ) ( j l , s 1 ) ) ,
, SPJ:
(s1, p1, j 2 ) , ( s 2 , p1, j l ) , ( s l , p2, jl) SPJ,
( s 1 , pi, j 1) SP J.
, .. SPJ, (
) . (" s1 p1 p1 j
1, a j 1 c s l , s l , p l j l ").
- >2 ,
(,
).

. 13.4. SPJ,
,

,
SPJ ( . 13.4 ).
3- ( 3-).
3- ?
, ,
SP J :

504

III.
) ;
) ;
) ;

) .

, ( 1, 1.3)
, . ,
1 " ".
, , 3-,
, ,
.
, , 3-
, ,
().
, .
.
. R , , B, ..., Z
. R

*{,

...,

Z}

( " , , ..., Z") , R


, , ..., z .
, SP
{S#, #} SPJ
PJ JS , SPJ
* {SP, J, JS}, 3-.
S.
SN {S#,SNAME} S ST
SC, , S *{SN, ST, SC}.
, SPJ
*{SP, PJ, JS} 3-. ,
? , , SPJ , 3. . 13.5. , 3-.

13. :

505

. 13.5. SPJ
( 13.2) ,
R{A, , } {, } {, } , R .
, .
R{A, , }
*{, } , B | C.
, , ( ) .
.

*{ ,

. ,
, (, , "" ).
, , , ,
,
. ( , ,
13.7.)
, , ,
SPJ, , , ,
. {. , ?) , ( ) ,
, .

506
III.
, !
. .
. R
(5), - (), , R
() R, .
) *{ , , ..., z } R
,
, , ..., z
R.
) *{ , , ..., Z } R
() R ,

, B, ..., Z

R.
SPJ 5. , 3-, , , (
). , SPJ 5,
3-
, {s#, P#, J#}
. , 3- SP, PJ JS 5,
.
, 5
4,
. , [13.15] , , ,
, . ,

5, .. 5 .
, " ". s. , .
*{

{ S#,

SNAME,

STATUS },

{ S#,

CITY }

, S
{S#, SNAME, STATUS} {S#, CITY}.
. ( ,
, , .)
, {S#} ( , [12.4]).

13. :

507

( 12.5 12), S , {SNAME}.


, ,
.
*{ { S#, SNAME }, { S#, STATUS }, { SNAME, CITY } }
, , {S#} {SNAME}, .
, *{,
, ..., Z} ,
, B, ..., Z
. ,
R , 5, , , .
. , (
), (.. , ),
. , , 4,
5, , , ,
. , ,
.
, , , 5
(
- ).
, 5, , , . (, ,
; , ,
.) 5, ,
, ,
. ( .) , s
5. ,
, , - . , .

508

III.

13.4.
( )
, . .
R, 1,
, .
R
(.. ) ,
R,
2.
,
.
, . .
1. 1 ,
,
. 2.
2. 2 ,

. .
3. ,
,
.
.
. 13 : "
, ,
".
4. ,
,
. 4.
.
1-3 ( " "),
13.2.
5. 4 ,
,
(
" ").
5.
2
R - ()
, , . , 13.2.

13. :

509

.
1. (, ).
2. ,
, 4 5 (
[13.15]):
R , , R,
;
R 4 ,
, R,
;
R 5 ,
, R,
.
, 12
, , , . (,
,
.)
3. :
;
;
, "
" ,
;
.
. (
) , . , 10 000 ., , . , ,

( ,
, ).
5
.
,
( )
,
.

510

III.

4. ,
, ,
, .
, ,
NADDR (. . 12.7 12),
, . ,
.
5. 12 ,

, .. ,
, SQL,
, ( )
.
,
(, , )
( )
.
6. , ,
,
.
( [13.9]).
( , 9)
( ) ,
, ,
, .
( ,
5),
,
.
12.5 (
SJT), (..
)
.

,
( " CTXD", . [13.13]).
, (. 14).
13.5.
( ) , 5 . ,

13. :

511

. ,
.
1.
( ,
).
2.
.
3.
-.
, , , , ( ) ,
.
, 3.

SQL, . "" .
. [13.6].

, R Rl, R2, ..., Rn,
Rl, R2, ..., Rn R. Rl, R2, ...,
Rn .
. Rl, R2, Rn
.
R,
i ( i = 1, ..., ) R
Ri Ri. R
Rl, R2, ..., Rn. , , ,
( )
.

3
;
, " ".
, ,
.

512

III.

. 13.6.

4 PSQ, . 13.6. , PSQ 1, 2.



. , ,
, .
,
.
, ? , ,
. ,
( ),
, .

, - ,
. . , .. .
: "
".
.
SUMMARIZE P BY { COLOR } ADD AVG ( WEIGHT ) AS AVWT
, . 13.6,
, , (
,
, ).
4

, , , S5. ,
"" . ,
19, .

13. :

513

SUMMARIZE PSQ { #, COLOR, WEIGHT } BY { COLOR


} ADD AVG ( WEIGHT ) AS AVWT
( , , , .) ,
, " , ",
, , .
, , . ( "" , .. ,
, ,
SQL.) , " ",
, . , ,
. , ,
, ,
.
.
, ,
, .. .
" "
, -,
.
" "

, ,
. ,

,

.
, ,
( ).
13.6. (
)
, , [13.12],
, , ,
. (principle of
orthogonal design). . 13.7, , , ,
.
SA , ,

514

III.

SB , ,
3 0 (.. ).
, , , S3 (
), .

. 13.7. ,
, S3
. , .. SB, SA. SA, ,
S3 . SB
, .. , . , , , , .
. 13.7 :
. , , . , .
{ ).

.
.
1. 10, ( , ). ,
"", "" .
.
(, .)

13. :

515

2. ,
,
(.. ).
3. ,
, -
, , .
. ,
R, .
, , , R
(, PR). , : INSERT t, t PR. , R , , , A UNION . 10, , ,
,
.
, ,
, INSERT.
. ,
, ,
.
, . . 13.8 , .
, {S#, SNAME}, , .
, , ( S 6 , Lopez),
, ,
(S6, Lopez, t) SX (S6, Lopez, )
SY ( t
). , .

. 13.8. ,

516

III.

{ ). B
. , , 1, 2, ..., Am Bl,
B2, ..., , Ai 1, 2, ..., Am
Bj Bl, B2, ...,
.
.
1. , ,
.. ,
:

;

( , ,
, ,
12).
2.
, ,
R, R
(.. R ).

,
.
1. , , ,

. ,
,
( ).
2. , S

. ,
, , ,
,
. ( ,
,
.)
.
3.
, , (
, ).
, ,

13. :

517

, ,
, .
4. ,
, (
). ,
.
ACTIVITIES_2001{ ENTRY#,DESCRIPTION,
AMOUNT, NEW_BAL }
ACTIVITIES_2 002{ ENTRY#,DESCRIPTION,
AMOUNT, NEW_BAL }
ACTIVITIES_2 003{ ENTRY*,DESCRIPTION,
AMOUNT, NEW_BAL }
ACTIVITIES_2004{ ENTRY*,DESCRIPTION,
AMOUNT, NEW_BAL }
ACTIVITIES_2005{ ENTRY*, DESCRIPTION,
AMOUNT, NEW_BAL }
,
, ,
.
5. ,

.
A UNION . .
A INTERSECT . .
A MINUS . .
13.7.
.
, 12
, , , . ,
(
)
. ,
(
). . [13.18] ( 1980- ), [11.1] [11.3]. .
1. - (). [13.16]. , ,
. , R ,

, .

518

III.

, ,
,
. ( 9
, ,
, .)
, ,
.
,
, , ,
() ,
.
, " " ,
. .
[13.16] , ,
, 5 ( , 4 ..),
(3,3) ( 2).

, .
2. "".
s .
, ""
, , 5,

.
? ,
(, LS),
(, PS) ..? ,
,
? ,
? ( , . 8.8
8,
.)
, .
, , () , () . , "-" , ,
() -
5.
5

, [13.15] 5 - ,
, .

13. :

519

, I
[13.32], (3,3). , (3,3) , 4,
4 (3,3). , v
, (3,3)
4 ( 5).
[13.15] [13.23].
[13.12] (
).
3. .
, .
, 23, , , , () , 6. ,
" ",
6 ( , . 1 2) 1 2,
.., 5NF. , ,
6, 5.
23.
13.8.
( 12),
,
, , .
.
R{A, , }
B | , ,
,
, , ,
, .

{, } {, },

( ).
*{,
B, ..., Z} ,
, B, ..., Z . ,

.
4 ,

520

III.

. 5 ( - ) ,
(..
*{, B, ..., Z } , T O , B, ..., Z
). ( )
.
, ( ,
). ,
:
. ,
.
, . , ,
,
. ,
, , , .
. .

13.1. SPJ (
. 13.2 13.4)
, ,
.

Tutorial D, 9.
, ,
.
13.2. , R{A, } ,
(, b) R , b
. ,
R?
?
13.3. ,
.
,
. ,
,
. ,
.

13. :

521

, . , .
13.4. 12.5 12
R
. ,
, 4.
13.5. ( . 13.3.)
, .
,
. ,
,

. ,
. ,
R ,
R , R .
,
.
13.6. ,
sx SY ( . 13.8 13.6).
SX { S#, SNAME, STATUS
} SY { S#, SNAME,
CITY }
,
? .

13.1. Aho A.V., Beeri , Ullman J. D. The Theory of Joins in Relational Databases // ACM
TODS. September 1979. 4, 3.
, , , . ,
(chase),
, ( [13.18]
). , .
,
, .
13.2. Beeri , Fagin R., Howard J.H. A Complete Axiomatization for Functional and
Multivalued Dependencies // Proc. 1977 ACM SIGMOD Intern. Conf. on Management
of Data. Toronto, Canada. August 1977.

522

III.
(Armstrong) [11.2]
. , .
1. . , , ,
B , .
2. . , B.
3. . D, AD .
4. . B B C, C - B.
,
.
5. . B D, D - .
6. . B A C, .
7. . , B C, B - C - B.
,
.
8. . B, B.
9. . B, C D, D ,
, D.
[11.2] 14, 8 9
. , .
10. , - .

13.3. Brosda V., Vossen G. Update and Retrieval Through a Universal Schema Interface //
ACM TODS. - December 1988. - 13, 4.
(. [13.20]) . .
13.4. Carlson C.R., Kaplan R.S. A Generalized Access Path Model and Its Application to a
Relational Data Base System // Proc. 1976 ACM SIGMOD Intern. Conf. on
Management of Data. Washington, D.C. June 1976.
. [13.20].
13.5. Date C.J. Will the Real Fourth Normal Form Please Stand Up? // J. Date and
Hugh Darwen. Relational Database Writings 19891991. Reading, Mass.: AddisonWesley, 1992.
, "
,
(4).

13. :

523

". , , , 4 ...
!
13.6. Date C.J. The Normal Is So... Interesting ( ) // DBP&D. NovemberDecember 1997. - 10, 11-12.
13.5 . , .
, ,
,
, ( 13.4)
.
,
.
,
( )

!
.
: (
)
(" , ",
[4.17]).
13.7. Date C.J. The Final Normal Form! ( ) // DBP&D. January/February
1998.-11, 1-2.
5.
(. 23).
13.8. Date C.J. What's Normal, Anyway? // DBP&D. March 1998. 11, 3.
"" .
13.9. Date C.J. Normalization Is No Panacea // DBP&D. April 1998. 11, 4.
, .
.
13.10. Date C.J. Principles of Normalization // http: //www.BRCommunity.com (Februa
ry 2003); http: / /www. dbdebunk. com (March 2003).
. .
1. , 5,
, 5NF.
2.
.
3. .

524

III.
4. .
5. ( , .)
, 5.

13.11. Date C.J., Fagin R. Simple Conditions for Guaranteeing Higher Normal Forms in
Relational Databases // C. J. Date and Hugh Darwen. Relational Database Writings
19891991. Reading, Mass.: Addison-Wesley, 1992. (
ACM TODS. - September 1992. - 17, 3.)
, R
R (..
), R 5. , , , , 4
5, .
. , :
R , R 4, 5.
13.12. Date . J., McGovern D. A New Database Design Principle // . J. Date. Relational
Database Writings 1991-1994. Reading, Mass.: Addison-Wesley, 1995.
13.13. Delobel C, Parker D.S. Functional and Multivalued Dependencies in a Relational
Database and the Theory of Boolean Switching Functions // Tech. Report No. 142.
Dept. Maths. Appl. et Informatique, Univ. de Grenoble, France. November 1978.
[11.5]
.
13.14. Fagin R. Multivalued Dependencies and a New Normal Form for Relational Databases
//ACM TODS. - September 1977. - 2, 3.
, 4 .
. , . , ,
, DAYS, , TEXT
TEACHER, COURSE.
CTXD .

13. :

525

{COURSE,TEACHER,TEXT} , .
{ COURSE, TEACHER, TEXT } DAYS
, 4,
, .
( TEACHER COURSE
TEXT COURSE). R
,
R "" .
, .
,
, , ( )
. CTXD ( 4,
5), DAYS , COURSE, TEACHER
TEXT, - . ,

.
.
13.15. Fagin R. Normal Forms and Relational Database Operators // Proc. 1979 ACM
SIGMOD Intern. Conf. on Management of Data. Boston, Mass. MayJune 1979.
-
(), 5.
. ,
"" , ..
,
().
13.16. Fagin R. A Normal Form for Relational Databases That Is Based on Domains and Keys //
ACM TODS. - September 1981. - 6, 3.
13.17. Fagin R. Acyclic Database Schemes (of Various Degrees): A Painless Introduction //
IBM Research Report RJ3800. April 1983. (: Proc. CAAP83 8th
Colloquium on Trees in Algebra and Programming: Springer-Verlag Lecture Notes in
Computer Science No. 159 (eds. G. Ausiello and M. Protasi). New York, N.Y.:
Springer-Verlag, 1983.)
13.3 , SPJ, ,
. (

526

III.

) ,
, . ( ,
, , ,
, ,
" ".) , , .
, .
.
:

, .
13.18. Fagin R., Vardi M.Y. The Theory of Data Dependencies A Survey// IBM Research
Report RJ4321. June 1984. (: Mathematics of Information Processing //
Proc. Symposia in Applied Mathematics 34, American Mathematical Society, 1986.)
1980- ( , "" ). ,
.
, -, , -,
, -, .
D
d, D.
, ,
[13.20] [13.17].
13.19. Fagin R., Mendelzon .., Ullman J.D. A Simplified Universal Relation Assumption
and Its Properties // ACM TODS. September 1982. 7, 3.
,
" " [13.20] (, ), , .
13.20. Kent W. Consequences of Assuming a Universal Relation // ACM TODS. December
1981.-6, 4.
. , ,
, ( , ),
. ,
""
(.. ) "" .

13. :

527

? [13.20] ,
.
[13.33], [13.21].
,
, .
( ):
,
, ,
, "
".
STATUS WHERE COLOR = 'Red'
.
1. , -
,
( , ).
, [13.4] ( , ,
,
, " "
).
. , ,
( , , S SP)
; , ,
, , (
, , S ), .
- ,
.
2. , ,

,
.
,
( , ),
,
.
.
STATUS WHERE COLOR COLOR ('Red')
: " , ,
" " , "?
,

528

III.
. ( , : " ".)
" ,
", , , ( , ,
S ).

13.21. Kent W. The Universal Relation Revisited //ACM TODS. - December 1983. - 8, 4.
13.22. Korth H.F. et al. System/U: A Database System Based on the Universal Relation
Assumption//ACM TODS. September 1984. 9, 3.
, DDL,
DML, " ",
.
13.23. Maier D., Ullman J.D. Fragments of Relations // Proc. 1983 SIGMOD Intern. Conf. on
Management of Data. San Jose, Calif. May 1983.
13.24. Maier D., Ullman J.D., Vardi M.Y. On the Foundations of the Universal Relation Model //
ACM TODS. June 1984. 9, 2. (
"The Revenge of the JD" Proc. 2nd ACM SIGFACT-SIGMOD
Symposium on Principles of Database Systems. Atlanta, Ga. March 1983.)
Maier D., Ullman J.D. Maximal Objects and the Semantics of Universal Relation
Databases //ACM TODS. March 1983. 8, 1.
, " " ,
( [13.17]).
, . , .
13.26. Nicolas J.M. Mutual Dependencies and Some Results on Undecomposable Relations //
Proc. 4th Intern. Conf. on Very Large Data Bases. Berlin, Federal German
Republic. September 1978.
,
,
, ( " 3-", 13.3).
, 12.
13.27. Osborn S.L. Towards a Universal Relation Interface // Proc. 5th Intern. Conf. on Very
Large Data Bases. Rio de Janeiro, Brazil. October 1979.

13. :

529

, " " ,
. .
13.28. Parker D.S., Delobel . Algorithmic Applications for a New Result on Multivalued
Dependencies // Proc. 5th Intern. Conf. on Very Large Data Bases. Rio de Janeiro,
Brazil. October 1979.
[13.13]
, .
13.29. Sagiv Y., Delobel , Parker D.S., Fagin R. An Equivalence between Relational Database
Dependencies and a Subclass of Propositional Logic //JACM. June 1981. 28, 3.
[11.8] [13.30].
13.30. Sagiv Y., Fagin R. An Equivalence between Relational Database Dependencies and a
Subclass of Propositional Logic // IBM Research Report RJ2500. March 1979.
[11.8], ,
.
13.31. Sciore E. A Complete Axiomatization of Full Join Dependencies // JACM. April
1982.-29, 2.
[13.2], , .
13.32. Smith J.M. A Normal Form for Abstract Syntax // Proc. 4th Intern. Conf. on Very Large
Data Bases. Berlin, Federal German Republic. September 1978.
13.33. Ullman J.D. On Kent's Consequences of Assuming a Universal Relation // ACM
TODS. - December 1983. - 8, 4.
13.34. Ullman J.D. The U.R. Strikes Back // Proc. 1st ACM SIGFACT-SIGMOD Symposium
on Principles of Database Systems. Los Angeles, Calif. March 1982.

14

14.1.
14.2.
14.3. ""
14.4.ER-
14.5. ER-
14.6. ER-
14.7.

14.1.

1970- .
(.. , )
. ,
.

,
. .
,
1
, (.. )
. , ,
,
1
,
( 9) " ". ,
,
. , ,
,
( [14.22]
[14.24] ). , ,
- [9.21],
[9.22]. 9 "" [14.14].

532

III.

, .
, .
, (
). ,
. , ,
, . "" ,
, , , , . [14.7], ,
( !). ,
"" , , , ,
. ,
, .

, ,
"" ( ).
,
, , , ER-,
. ( ).
, , .
, ( ) .
. (. 1.3 1),
: (
),
.
, , .
ER-,
,
, , . , ER- , .

14.

533


,

, .
,
, , ,
,
( , ,
25 ). , (
) ,
(First Great Blunder).
26.
,
.
. ,
,
""
, . ,
, , .
.
. ,
14.2, , . , 14.3, (Chen) "-" ( ER-; entity/
relationship model ER-model). , 14.4 14.5, . (
, .) , 14.6,
ER-, , 14.7, .
14.2.

.
1. , (), .
, , . ( ,

534

III.

, , , , , .)
, ,
. ,
,
EMPLOYEE ().
,
(,
),
( ) .
,
.
, ,
, ,
.. , .
, ,
.
. , ( , , ,
..) ,
" ", . , ,
, , , .
2. (..
) ,
. (.
- !) ,
(RM/T) [14.7] ,
- -. , - ( "entity-relation")
, - ( "property-relation") ,
- -, , ,
.
3. ,
(, 9, ),
. , RM/T-
, ,
- -
( ,
).
4. , ,
. ,
RM/T- PROPERTY,
- -
, , .. ,
.

14.

535

. 24 ,
,
, ,
.
, .
,
, (,
). ,

2. ,
,
.
,
, .
, , , ,
. 14.1
. ,

,
, . ( ,
, .)
(, )
.
14.1.

, .

536

III.

, , , . 14.1
, , ,
. , ,
, ( ) ,
. (!) ,
, ER-,
, 5. ,
, , ,
().
.
1. , ,
, .
2. ,
, .
( ,
) , (. 26.2 26).
, 1
, , . , 3
, ,
, . ,
( , )
. , ,
14.314.5,
.
, , 14.6 .
14.3. "-"
14.1, "" ( ER-).
"", 1976 [14.6] , (
, , [14.18], [14.45][14.47]).
. ( ,
"-" "" , , . , [14.6],
[14.18], [14.30], [14.37] [14.24] , [14.27] [14.36] .)

14.
537
ER- , . 14.1,
. ,
[14.6] ER- , , ER-. ER- , . 14.1
, [14.6].
(KnowWare, Inc.).
. ( ER-, . 1.6 1.)
. , , , . , ,
.

. 14.1. "" (
)

[14.6] (entity) ", ".


. ,
, .. , .
, . 14.1 DEPENDENT ( ) ,
( ),
EMPLOYEE (). ,
( EMPLOYEE) ,
( DEPENDENT) .
, .
EMPLOYEE .
.
.

538

III.

( ) (property).
. ,
, , .. (. ;
.)
,
( ).
.
. , " "
,
"", "" "".
(.. ,
). ,
.
3 (..
). , . 14.1,
. (SUPPLIER)
, CITY () .
(.. ).
. 14.1, 19.
. ,

. . 14.1.
. ER-
.

[14.6] (relationship) ",


". ,
DEPT_EMP. ,
. , (. 1),
,
, .
, , ,
. ( , .)
R , .
R,
R , .
3

" " 6.4.

14.

539

, , EMPLOYEE (DEPT_EMP)
. , ,
(, ) ,
DEPARTMENT DEPT_EMP .
"-" " ", " "
( " ") " ". (
, , ..
, , ,
.) , , , " "
, , , . " " " "
, , . " " " " ,
" ", , - , ,
" ". , - . ,
; ,
, .

. ER- [14.6]; .
, , [14.46].
,
. ,
( ), ,
PROGRAMMER ()
EMPLOYEE (). (, , EMPLOYEE PROGRAMMER.)
, (, " ",
). ,
PROGRAMMER ,
EMPLOYEE, (,
,
). , .
, ( PROGRAMMER)
( APPLICATION_PROGRAMMER),
(SYSTEM_PROGRAMMER). , ,
APPLICATION_PROGRAMMER SYSTEM_PROGRAMMER

540

III.

PROGRAMMER .. , - -
, . ,
, .. , . 14.2.
.
1.
20, ,
, 5 (.. ).
2. , IMS ( - ,
), ,
. , . 14.2
, (EMPLOYEE)
(PROGRAMMER). ,
EMPLOYEE
PROGRAMMER,
( ,
IMS).

. 14.2.
ER- , ER-.
14.4. ER-
, [14.6] "", ER-.

( ). , ER- ,
, , -
. ER- ,
. 14.1 14.2.

14.

541

. , "", ER ,
, ,
[14.6].

ER- ,
.
(. . 14.1).
:
DEPARTMENT ();
EMPLOYEE ();
SUPPLIER ();
PART ();
PROJECT ().
:
DEPENDENT ().

ER- ,
. ( )
. ,
, , . ,
, .
, .
(. . 14.1).
EMPLOYEE:
# ( ) ;
ENAME ( ) , FIRST (),
Mi () LAST ();
SALARY ().
SUPPLIER :
S# ( ) ;
SNAME ( );
STATUS ( );
CITY (, ).
SUPP _ PART_ PROJ :
QTY ().
PART_STRUCTURE:
QTY ().

542

III.

, . 14.1, .

ER- .
,
, .
.
"1" "", , " ",
" " " ").
.
(. . 14.1).
DEPT_EMP ( " "
DEPARTMENT
EMPLOYEE).

EMP_DEP ( " " EMPLOYEE


DEPENDENT).

PROJ_WORK PROJ_MANAGER (
EMPLOYEE PROJECT,


" ",

" ").

SUPP_PART_PROJ (

" "
SUPPLIER, PART PROJECT).

SUPP _ PART

( " "

SUPPLIER

PART).

PART _ STRUCTURE

( " "

PART

PART).
, PART

" "
"). PART_STRUCTURE
.
PART_STRUCTURE
( IMP, , , "


Y X. Y
Y.
, (is-a relationship)
( Y ("is ") ).
(. . 14.2).
PROGRAMMER
EMPLOYEE.
APPLICATION_PROGRAMMER SYSTEM_PROGRAMMER
PROGRAMMER.

14.

543

14.5. ER

ER- .
4 ,
, , ER-
( , ). ,
, . 14.1, .

. 14.1 .

DEPARTMENT.
EMPLOYEE.
SUPPLIER.
PART.
PROJECT.

.
,
, , DEPT, EMP, s, P J, .
, (DEPT#,
#, s#, # J#), ER- .
, .
( ).
VAR DEPT BASE RELATION
{ DEPT# . . . , ... }
PRIMARY KEY { DEPT#
} ;
.
. , . ,
, , ER- .
" "
" " ( " " ..).

, (, ER-
CREATE TABLE SQL).

544

III.
PROJ_WORK ( ).
SUPP_PART ( ).
SUPP_PART_PROJ ( , ).
PART_STRUCTURE ( - , )

. , ,
. , SUPP_PART SP ( ).

, .
VAR

SP BASE RELATION SP
{ S# . . . , P# . . . , . . .

FOREIGN KEY { S# } REFERENCES


S FOREIGN KEY { P# } REFERENCES
P ;
, (s#
#), ( SUPPLIER PART),
s .
, , .. UPDATE DELETE.
. ( ). ,
, ,
ER- .
, SP.
VAR

SP BASE RELATION SP
{ S# . . . ,
# . . . , . . . }
FOREIGN KEY { S# } REFERENCES S
ON DELETE RESTRICT
ON UPDATE CASCADE
FOREIGN KEY { P# } REFERENCES
P
ON DELETE RESTRICT
ON UPDATE CASCADE ;

? ,
(
SP s# #). ,
(
, )
(
).
, , " " ( [14.11] [14.21]).

14.

545

.
, SP .
PRIMARY KEY { S#,

P# }


PROJ_WORK, PART_STRUCTURE SUPP_PART_PROJ.
" "
" ".
PROJ_MANAGER ( ).
DEPT_EMP ( ).
EMP_DEP ( ).
(DEPENDENT), .
, -
, DEPT_EMP. 5.
, "" (),
"" (DEPT).
VAR EMP BASE RELATION
{ # ..., DEPT# ...,
... } PRIMARY KEY { EMP#
}
FOREIGN KEY ( DEPT# ) REFERENCES
DEPT ON DELETE ... ON UPDATE
... ;
DELETE
,
" " ( ). ,
ER-.
. , " " ( ) ,
" ".
" " [14.8].
UPDATE ,


, , , " ",
. ,
.
5
, , . 14.3, " ",
/' ". IV
[19.19].

545

III.
ON DELETE CASCADE
ON UPDATE CASCADE

, , .
VAR DEPENDENT BASE
RELATION { # ..., ...
}
FOREIGN KEY ( EMP# ) REFERENCES
EMP ON DELETE CASCADE ON
UPDATE CASCADE ;
? " ", , . ,
ER-, ,
.
( [14.11] [14.21]).
, DEPENDENT .
PRIMARY KEY { EMP#, DEP_NAME }
DEP_NAME .

ER-
, , (
12.6 12),
.
( , , , ).
. ,
!

. 14.1 ,
, . 14.2. EMPLOYEE
PROGRAMMER. ,
6 (.. LANG ).
6
, , , EMPLOYEE
PROGRAMMER - "" "".
, , , ER-
Y X, , Y
"" X, .
[14.13].

14.

547

EMPLOYEE ,
, (.. , ).
PROGRAMMER ,
PGMR, ,
, , ,
,
( LANG).
VAR PGMR BASE RELATION { EMP#
..., LANG ... } PRIMARY KEY {
EMP# } ... ;
, PGMR
, . ,

( , ).
VAR PGMR BASE RELATION {
# ..., LANG ... }
PRIMARY KEY { EMP# }
FOREIGN KEY { EMP# } REFERENCES EMP
ON DELETE CASCADE ON UPDATE
CASCADE ;
, , EMP_PGMR,
.
VAR EMP_PGMR VIEW
JOIN PGMR ;
, "( )
". , .
, .
.

, (,
).
PGMR
, .
EMP_PGMR
.
1 ,
.
-
EM7P_PGMR.
( )
, ,

548

III.
- , EMP_PGMR.
, ,
, -
EMP_PGMR.
, ,
PGMR.
, ,

PGMR EMP_PGMR.
,
,
PGMR.

, . 14.2 (APPLICATION_PROGRAMMER SYSTEM_PROGRAMMER).


14.6. ER-
ER-.
[14.9],
.
, .
ER-
ER- .
, , ,
,
.
14.2, ""
.
1. .
2. .
3. ().
4. .
, ( ), "" , ER-. , ,
" ".
ER- - .
, ,
( [6.1], 1969 ), , .

14.

549

" , ...
... ... ...
, [ , ] ,
".
, . ( !), , .
, .
, ER- (,
, ).
, . ( ,

; .)
, , , , , 1. ,
, 2 3,
,
4.
,
ER-; , .
. , ,
ER-
, (
) ER-.
ER-
, ER-
, , (.. , , ). , ER-
7, , 14.3
14.5, (
7
, ER-
(, , ) -. [14.32]: " ,
-, -".
,
(. [9.21], [9.22] [14.22][14.24]).

550

III.

). [14.6]
, ER- , ,
(, , , ).
.
ER-, ..
,
{, ..), .
ER- .
(, [14.6]
,
, , ,
.)
ER- (
) ,
. , ER-
, ( )
.
, , ""
,
ER- ,
,
.

, . , ER- , - .
, , ,
, , , 14.2,
. ,
.
, ,
. : "
1975 ?".
, ,
. : "
?".
,
(..
-).
(..
).

14.

551


ER- [14.22].
"
[ ].
".
, , .. , ? , ,
. ( ; . [14.23] .)

ER-,
. ; ,
,
. , " ",
,
8. , , . ,
ER- ?
14.7.
.
, ,
, .
1. .
2. .
3. ().
4. .

, , .
. ,
8
, , . , , " , , ".

552

HI.


, .
,
"".
. , ,
"-", ER-.
,
ER- [14.6] ,
, : ER-, ER. 14.4, ER-,
,
, - .
ER- .
,
, RM/T-, [14.7].
ER- ,
.
( ER- )
, 12 13.
. ,
,
, .. (,
, ).
, ,
. , , , ..
. , ( ) . ,
.
1. ER- ( )9
"" ,
, ..
2.
"" "".
,

, , 12 13.
9

, ,
,
, 9.

14.

553

, ( )
. , ,
(
).
,
.
. , , ,
. , " ".
,
[14.2]. , , ,
, , (
ER-), (
ER-), ..

14.1. ?
14.2. "
" , ER-
14.3. ER-:


14.4. , ER- "


" (.. ,
). :
) Tutorial D;
) SQL.
14.5. :
) " ",
;
) " ",
;
) " ", ;
) , , .

554

III.

14.6. ER- . 9.7


9.
14.7. ER- ,
, . 12.3 12.
.
14.8. ER- . 12.4
12.
" .
14.9. ER- , ,
. 13.3 13.
.
14.10. ER-
. 13.5 13.
.


, . , , ER ,
. , ,
. , , .
() ,
, .. (
- [9.21], [9.22], [9.15].) , , ISO
[2.3] [2.4].
14.1. Abrial J.R. Data Semantics // J. W. KJimbie and K. L. Koffeman (eds.). Data Base
Management. Amsterdam, Netherlands: North-Holland; New York, N.Y.: Elsevier
Science, 1974.
.
( , ):
" : , , ".
14.2. Bernstein P. A. The Repository: A Modern Vision // DBP&D. December 1996. 9,
12.
, . , , ,

14.

555

. :
" , ,
, , Web-,
, - ". .
14.3. Blaha M., Premerlani W. Object-Oriented Modeling and Design for Database
Applications. Upper Saddle River, N.J.: Prentice-Hall, 1998.
Object Modeling
Technique (OMT). , ER-
( ER-), , . .
[14.37].
14.4. Booch G. Object-Oriented Design with Applications. Redwood City, Calif.: Benjamin/
Cummings. 1991.
. [14.37].
14.5. Booch G., Rumbaugh J., Jacobson I. The Unified Modeling Language User Guide //
Reading, Mass.: Addison-Wesley, 1999.
. [14.37].
. ( ): The Unified Modeling Language Reference Manual (Rumbaugh, Jacobson, Booch) The Unified Software Development Process (Jacobson, Booch,
Rumbaugh). AddisonWesley 1999 .
14.6. Chen P. P.-S. The Entity-Relationship Model - Toward a Unified View of Data // ACM
TODS. March 1976. 1, 1. (: . Stonebraker (ed.) Readings in
Database Systems. San Mateo, Calif.: Morgan Kaufmann, 1988.)
ER- ER-.
, ,
,
, , . (
ER ,
, . ,
,
.) .
14.3 , ",
", " ".
: " ?".
, ", ", ,

556

III.

"" -, "".
, , "
"? .
(
""). ,
,
(
), .
,
, ,
( " " ).
" ", .
, SPD {S#, P#,DATE, QTY},

. ,
, .
(, ,
)
{S#, #, DATE},
, .
14.7. Codd E.F. Extending the Database Relational Model to Capture More Meaning // ACM
TODS. - December 1979. - 4, 4.
"" RM/T-.
RM/T- ER-. , RM/T- ( ). -,
RM/T-
, ER-. -, RM/T-
( ).
RM/T- .
-, ( "") - -
10,
. -
, -
.
-, ; ,
( RM/T " ") Y
. RM/T-
,
.
10

- -.

14.

557

,
.
-, RM/T- (-
- , ..)
.
RM/T- ER- (,
, , ), . 14.1. , ,
, ,
. ,
: , .
. , .
, " ".
, ,
, (. ).
. , "
" .
.
, .
. , " " (
" , " ..) .
, .
, .
( ) .
, (-, )
,
. " ",
.
. RM/T-
, .
. Y
X, , , X: ,
.
ER- ( ).
ER-, ,
( " ").
, RM/T
( [14.21]),
(. 23)
( [14.40], [14.41]).

558

III.

14.8. Date C.J. A Note on One-to-One Relationships // Relational Database Writings: 19851989. Reading, Mass.: Addison-Wesley, 1990.
" ",
, .
14.9. Date C.J. Entity/Relationship Modeling and the Relational Model // C. J. Date and
Hugh Darwen. Relational Database Writings: 1989-1991. Reading, Mass.: AddisonWesley, 1992.
14.10. Date C.J. Don't Encode Information into Primary Keys! // C. J. Date and Hugh Darwen.
Relational Database Writings: 1989-1991. Reading, Mass.: Addison-Wesley, 1992.
,
" ".
[14.11], .
14.11. Date C.J. Composite Keys // . J. Date and Hugh Darwen. Relational Database Writings
1989-1991. Reading, Mass.: Addison-Wesley, 1992.
: "
[] ...
". , ,
[14.21] .
14.12. Date C.J. A Database Design Dilemma?//http: //www. dpbd. com (January 1999).
(, "")
EMPLOYEE (..
), EMPLOYEE.
( [3.3])
.
14.13. Date C.J. Subtables and Supertables // [3.3].
,
,
- , - . , SQL (.
26), . [14.13] .
14.14. Date C.J. Twelve Rules for Business Rules // http: //www.versata.com (May 1,
2000).
( ),
"" -.
14.15. Date C.J. Models, Models, Everywhere, Nor Any Time to Think // http: //www.
dbdebunk. com (November 2000).
, , ( ).
,
, , (
!) , .

14.

559

14.16. Date C.J. Basic Concepts in UML: A Request for Clarification // http://www.
dbdebunk. com (December 2000/January 2001).
, , (Unified Modeling Language UML). (Object Constraint Language OCL). I
" OCL" [14.49], II - " UML" [14.5].
14.17. Dey D., Storey V.C., Barron T.M. Improving Database Design Through the Analysis of
Relationships // ACM TODS. December 1999. 24, 4.
14.18. Elmasri R., Navathe S.B. Fundamentals of Database Systems (3rd edition). Redwood
City, Calif.: Benjamin/Cummings, 2000.
ER- .
14.19. Embley D.W. Object Database Development: Concepts and Principles. Reading,
Mass.: Addison-Wesley, 1998.
OSM-
(Object-oriented Systems Model). OSM-
ORM- [14.22][14.24].
14.20. Fleming .., Von Halle . Handbook of Relational Database Design. Reading,
Mass.: Addison-Wesley, 1989.

DB2
IBM DBC/1012 Teradata ( NCR). , , ,
" " ,
, " " , , ,
!
14.21. Hall P., Owlett J., Todd S.J.P. Relations and Entities // G. M. Nijssen (ed.). Modelling
in Data Base Management Systems. Amsterdam, Netherlands: North-Holland; New
York, N.Y.: Elsevier Science, 1975.
,
( RM/T [14.7]). , .
.
(
), , .
, ,
,
.

560

III.
, ,
, .
, ,
( ) .
, , , ( ) , " " ( ), ,
, "
" . ( , , . ,
,
.) ,
, , (,
,
). , ,
( ), .. , , .
, , .

14.22. Halpin T. Information Modeling and Relational Databases: From Conceptual Analysis to
Logical Design. San Francisco, Calif.: Morgan Kaufmann, 2001.
ORM- (. ).
ORM- ER, , ORM UML, .
. , Conceptual Schema and
Relational Database Design (2- ), Prentice
Hall of Australia Pty., Ltd., 1995.
14.23. Halpin T. Business Roles and Object-Role Modeling // DBP&D. - October 1996. - 9,
10.
- (Object-Role Modeling
ORM) [14.22]. , "[ ]
ER-, , ORM ".
(. NIAM- [14.34].) ORM ,
(

14.

561

)
(, , ),
. .
.

.
el 2, (..
2 el) .

.
,
-. ,
ORM- ,
- .
, (
"- "). ,
,
, VI ,
. , ..
.
. ,
( ) , (Holl),
(Owlett) (Todd) [ 14.21].
, ORM- .
, , ORM-
, , RM- (
. [14.24]).
ER- SQL, ()
ORM.
ORM- -
(.. -,
)
. ,
,
ER-.
,
, , ORM-.
ORM- ,

. ORM-
. ,

562

III.
ER- SQL ORM,
ORM ER
SQL. , SQL
SQL;
.
, ORM-, ER-,
" ". (
[14.24] , -
ORM- .
.)
, ORM-, ,
( ,
, , , , ,
). ,
. . [14.24].

14.24. Halpin . Conceptual Queries // Data Base Newsletter. March-April 1998. 26, 2.
: "
, SQL QBE,
. ConQuer , ... [ ]
-".
,
ConQuer, : " ,
, , ".
+ - + -


, ,
SQL , SQL
.
SELECT
DISTINCT
X1.EMPt,
X1.BRANCH FROM EMPLOYEE AS X1,
DRIVES AS X2 WHERE
X1.EMP# =
X2.EMP# ;
,
. SQL ,
, SQL .
SELECT DISTINCT Xl.EMP#, X3.BRANCH#
FROM
EMPLOYEE AS X1, DRIVES AS X2, WORKS_FOR AS X3
WHERE Xl.EMP# = X2.EMP# AND Xl.EMP# = X3.EMP# ;
ConQuer .

14.

563

, ConQuer .
ANSI/SPARC. 2, , ,
!
, SQL . , , SQL. SQL
. RM- SQL,
ConQuer SQL
(, ).
,
ConQuer. , ( ), " , - ,
" ( ). , " ConQuer...
", .
^1
+- 1
+- 1
+- 2,
+- 1
+- 2 <> 1
: " ,
, , , ". SQL!
, ConQuer - : " ORM- -,
[ER-], [ ]. ,
ConQuer
".
14.25. Hammer M.M., McLeod D. J. The Semantic Data Model: A Modelling Mechanism for
Database Applications // Proc. 1978 ACM SIGMOD Int. Conf. on Management of
Data. Austin, Texas. May/June 1978.
(Semantic Data Model SDM)
. ER, ( )

564

III.
( ) .
[14.26] [14.29].

14.26. Hammer M., McLeod D. Database Description with SDM: A Semantic Database
Model //ACM TODS. - September 1981. - 6, 3.
. [14.25].
14.27. Hull R., King R. Semantic Database Modeling: Survey, Applications, and Research
Issues // ACM . Surv. - September 1987. - 19, 3.
1980 .
. . [14.36].
14.28. Jacobson I., Christerson M., Jonsson P., Overgaard G. Object-Oriented Software
Engineering ( ). Reading. Mass.: Addison-Wesley, 1994.
Object-Oriented Software Engineering (OOSE). , - [14.3], OOSE ( , ) ER- ( -, OOSE-
ER-). : " ,
/ , . , ". ,

, . ,
, , ,
, "", .. , , .
, , -
" " , ( . 25).
. [14.5], [14.16] [14.37].
14.29. Jagannathan D. et al. SIM: A Database System Based on the Semantic Data Model //
Proc. 1988 ACM SIGMOD Int. Conf. on Management of Data. Chicago, 111. June
1988.
, , , [14.25].
14.30. Keuffel W. Battle of the Modeling Techniques: A Look at the Three Most Popular Mo
deling Notations for Distilling the Essence of Data // DBMS. August 1996. 9, 9.

14.

565

" " ER-,


NIAM (Natural-language Information Analysis Method ) [14.34] SOM (Semantic Object Modeling
). , ER- "" ,
. , , , (.. ) "
, ". NIAM-
. , , " ", ,
, "
NIAM- " (!).
SOM-, " ER-... - []
, ".
ER- , (..
), "" (.. ) . ( ER-
, .)
14.31. Mannila H., Raiha K.-J. The Design of Relational Databases // Reading, Mass.:
Addison-Wesley, 1992.
, "
". , , , ER, .
( ) ,
.
.
.
.
.
.
ER- .
.
.

Design By Example ( ).
14.32. Moriarty . Enterprise View ( ) // DBP&D. August
1997. - 10, 8.

Usoft (www.usoft.com), -

566

III.
, SQL, ( ).

14.33. Nijssen G.M., Duke D.J., Twine S.M. The Entity-Relationship Data Model Considered
Harmful // Proc. 6th Symposium on Empirical Foundations of Information and Software
Sciences. Atlanta, Ga., 1988.
" ER- ?"
,
.

(. 26).
(. [14.13],
26).

(. 10).
. ,
( ).
[14.33] ,
. , ER- .

, .
,

.

,
("[]
, ,
. [] ,
[] , ,
, [ , ]
,
, !").
, ER-
.
ER- : "
... []
, , ,
( ) ,
, [ ]
, ,

14.

567

.." [2.3]. , , ER- " " CODASYL.


" ER [ ] ,
?"
ER.
NIAM [14.34]. , ,
NIAM ,
ER-.
14.34. Olle T.W., Sol H.G., Verrijn-Stuart A.A. (eds.). Information Systems Design Methodo
logies: A Comparative Review. Amsterdam, Netherlands: North-Holland; New York,
N.Y.: Elsevier Science, 1982.
IFIP Working Group 8.1, 13
.
NIAM [14.33]. , ,
NIAM.
, NIAM.
14.35. Papazoglou M.P. Unraveling the Semantics of Conceptual Schemas // CACM.
September 1995. - 38, 9.
,
, .. , (
), , , . : "
?".
14.36. Peckham J., Maryanski F. Semantic Data Models // ACM . Surv. September,
1988.-20, 3.
(. [14.27]).
14.37. Reed P. Unified Modeling Language Takes Shape // DBMS. - July 1998. 11, 8.
UML (Unified Modeling Language) ,
( , , , ).
SQL.
. , UML, ,
, , OMG (Object Management
Group) ( ). ,
, , , .

568

III.
, UML
( ER-),
. ( [14.37] " -"
! , , "".
: "UML ,

, , ". : "
, ,
".
,
, , , . [25.25].)
UML
(Booch method) [14.4], - [14.3]
OOSE- [14.28]. . [14.5] [14.16].

14.38. Schmid H. A., Swenson J. R. On the Semantics of the Relational Data Base Model //
Proc. 1975 ACM SIGMOD Int. Conf. on Management of Data. San Jose, Calif. May 1975.
" ", ER- [14.6],
(, ,
, , , ).
14.39. Sowa J.F. Conceptual Structures: Information Processing in Mind and Machine.
Reading, Mass.: Addison-Wesley, 1984.
,
. . ( , 1990
" " .) ER- ( ) , ,
.
(, , ), . ( (Frege) 1879 ,
, ER- "
1879 "!) . , " ".

14.

569

, . ( ), , ER- .
14.40. Smith J.M., Smith D.C.P. Database Abstractions: Aggregation // CACM. June
1977. - 20, 6.
. [14.41].
14.41. Smith J.M., Smith D.C.P. Database Abstractions: Aggregation and Generalization //
ACM TODS. - June 1977. - 2, 2.
, [14.40] [14.41], RM/T- [14.7],
.
14.42. Storey V.C. Understanding Semantic Relationships // The, VLDB Journal. October
1993. - 2, 4.
: "
, , . , , , .

".
14.43. Sundgren . The Infological Approach to Data Bases // J. W. Klimbie and K. L. Koffeman
(eds.). Data Base Management. Amsterdam, Netherlands: North-Holland; New York,
N.Y.: Elsevier Science, 1974.
- (infological)
,
.
14.44. Tasker D. Fourth Generation Data: A Guide to Data Analysis for New and Old
Systems. Sydney, Australia: Prentice-Hall of Australia Pty., Ltd., 1989.
,
( ,
). :
, . .
, (,
) .
. (,

.)
. " ", , , "" . , .

570

III.

14.45. Teorey T.J., Fry J.P. Design of Database Structures. Englewood Cliffs, N.J.:
Prentice-Hall, 1982.
,
: , , (.. , ),
.
14.46. Teorey T.J., Yang D., Fry J.P. A Logical Design Methodology for Relational Databases
Using the Extended Entity-Relationship Model // ACM . Surv. June 1986.
18, 2.
" ER-"
, ( 19) ,
.
14.47. Teorey T.J. Database Modeling and Design: The Entity-Relationship Approach (3-
) // San Mateo, Calif.: Morgan Kaufmann, 1998.
ER-
"" ER- [14.46] .
14.48. Wand Y., Storey V.C., Weber R. An Ontological Analysis of the Relationship Construct in
Conceptual Modeling // ACM TODS. December 1999. 24, 4.
14.49. Warmer J., Kleppe A. The Object Constraint Language: Precise Modeling with UML.
Reading, Mass.: Addison-Wesley, 1999.
. [14.16].

,
: .
,
.

,
,
,

,
, .. . ,
.

,

.
("")

- ,

,

.
15 , 16 .

15

15.1.
15.2.
15.3.
15.4.
15.5.
15.6.
15.7.
15.8.
15.9.





( )
sql

15.1.
,
.
.
,
,
16 (
, 15.4).
, ,
, ..
, , ,
, ,
(
). ,
,
. (
. ,
, , ,

574

.) , , , , , , - .
, , ( , ) , : - . ( , ,

.)
, ,
. ,
( , [15.12]).
. 15.2 15.3
(.. -
). 15.4
( , ). 15.5
( -
, , , - ). 15.6
, 15.7 . 15.8 SQL. , 15.9 .
, : ,
"" (, ) .
"" (, ) ; , , . ,
, .
15.2.
;
BEGIN TRANSACTION COMMIT ROLLBACK. . 15.1
, 100 .
123 456. ,
, , . ,
,
, ; , ,
100 . ""

15.

575

. , ,
. , ,
,

; , .

. 15.1. ()
, , ,
, ,
.
, . , , , ,
, ,
. ,
1,
.. ,
, ,
. , , ,
, ,
. ,
(.. ,
). ,
, ,
.

, ,
, , ,
, , .
, , 1 5 . 4 1 5 . 3 .

576

IV.

, ( ), (
-),
COMMIT ROLLBACK, .
COMMIT () . ,
, (
) , ,
, , .. .
ROLLBACK ( )
. , - ,

, ..
.
, COMMIT ,
,
. - , ,
- , ROLLBACK
.
, . 15.1, , .
ROLLBACK.

ROLLBACK . (
),
.
ROLLBACK ,
-
(
COMMIT ROLLBACK).
. (
) ,
, , . ,
" ",
COMMIT, "
" . ,
, .
[15.12].
. ,
. ,
( ) ,
, ,

15.

577

( ) ,
. ,
,
.
. .
( ) (
) . ,

, .
, ,
,
( ).
. ,
( ) .
,

, ,

(, ,
, ). ,
,
. , 9 10,
,
(, - ,
,
).
.
, COMMIT ROLLBACK
, . ,
, ,
. 15.2.
. ,
, BEGIN TRANSACTION
,
- . ,
. ,
.
. ,
, . ,
9 ( ),
- .
, ,
,
. ( ),
.

578

IV.
; , ! , , . 15.1, , 123
456 .
,
(, ), ,
. ,
9, . , , , ( ), , , ,
, . ,
, ,
D1 D2 D1 , D2
2. ,
( 9, , ).

. 15.2. ,

. 5 ( , [3.3]),
, (.. ).
, UPDATE, . 15.1,
(
).
2
,
D1. , "
, ",
D2 D1. ,
,
.

15.

579

UPDATE ACC 123 { BALANCE := BALANCE - $100


} , UPDATE ACC 456 { BALANCE := BALANCE +
$100 } ;
,
BEGIN
TRANSACTION, COMMIT ROLLBACK ( ,
). , 5, (
). . (,
, ,
. 16.10.)
15.3.
BEGIN TRANSACTION COMMIT ROLLBACK. COMMIT
(
syncpoint, ). () , , ,
( ) . , ROLLBACK
,
BEGIN TRANSACTION, .. .
.
, ,
BEGIN TRANSACTION . ,
.

. . , 15.1, , .
.
1. 15.2, , , , ..
, . , (.. ). , 3 ( ).
3

, ,
. ( , [15.15],
.)

580

2. . ,
(,
SQL, 4). .
.
. ,
( , ) ; SQL 1999 .
, 15.8.
. . 2 ,
ROLLBACK, COMMIT ( , , ). . 1 ,
, .
, , . ,
,
,
. ,
COMMIT, , ( 4 , , ). ,
;
, ,
. ( ,
COMMIT.
write-ahead
log rule.)
,
. , , .
. , .
. ,
, .

. ,
, -
, .
4

,
( ) , ,
.

15.

581

COMMIT . , , , - .
( ) . -,
, ,
,
COMMIT. , ,
,
( ,
). -, ( ) COMMIT ; , 100
, , 100
, .
(steal/no-force), , ,
.
.
, , , COMMIT ,
. , ,
, .
, ,
,
.
, ,
,
COMMIT, .
COMMIT
, COMMIT,
5.

COMMIT
COMMIT, (), , .
(group commit) , ;
, .

582

IV.

ACID
[15.14], ,
, ( !)
: (atomicity), 6 (correctness), (isolation) (durability). ACID ( ).
. ( "
").
.
;
.
. . ,
, ,
, ,
,
. ,
:
,

.
. , , .
15.4.
,

, ,
. , , , . ,
15.2 15.3. , ,
. ,
.
, .
(, )
,
. .

6
( [15.14]) "" (correctness) "" (consistency), ,
.

15.

583

(, ),
- , , , ,
. .
, 15.5 .

() ( , ).
, .
(.. ).
, , , ( 15.3) ,
,
.
: ,
, ? ,

(, ).
, -, , , -,
. , , .
, , . 15.3,
(
).

tf.
tf tc.
1 tc.
2 tc
tc, tf.
tc,
tf.
4 tc
tf.
, 5 tc,
tf.
, 5 , 2 4 . ,
1 , tc
. ,

584

IV.

. 1S.3.
, (.. )
tf, (, ).

... ,
2-5.
1. ; UNDO () REDO (
).
2. UNDO ,
, a c REDO .
3.
.
4. BEGIN TRANSACTION
,
UNDO.
5. COMMIT,
,
UNDO REDO.
6. UNDO REDO
, , 5,
2 4.
,
UNDO, , cnca REDO.
.
. , .
,

15.

585

, , .
( ), .
ARIES
, 7. , ,
( )
( ).
,
.
, ARIES [15.20], ,
,
. ARIES
.
1. . REDO () UNDO ().
2. . , ,
,
.
3. . ,
.
, " "
, ,
.
ARIES [15.21]
( ). , ARIES ,
, , ( ), ,
, .
ARIES "Algorithms for Recovery and Isolation
Exploiting Semantics" ( ).

7
, , ! , ,
. ,
,
.
.

586

IV.

15.5.
.

. .
15.4, ,
.
( ) ( )
( , ) ,
( ).
, , , ,
( ).
, / ( /). .
, . ,
.
.
15.6.
. .
/ , .
,
,
8. , , , IBM, IMS,
DB2 ( ).
, ,
IMS, DB2, . . , , IMS , DB2 ,
. , ( " ").
, , ,
COMMIT IMS ROLLBACK DB2. ,
8
, ,
21.

15.

587

, . "", , COMMIT ( ROLLBACK). , .


, (.. IMS
DB2 ) , . ,
, .
.
.
, , ..
COMMIT, ROLLBACK. COMMIT .
1. .
.
, (..
)

(.. ).
, ,
,
,
. ,
, " ".

" ".
2. . ,
.

, .
,
.
, .
-
, ,
, .
, ,
; .
, 1 2

.
, - , . , ,
, .

588

IV.

, , , , , .
,
, ( 21),
,
.
,
, ( ,
, ). ,
(Data Communications Manager), DC (. 2),
. ,
, ,
.
, [15.12].
15.7. ( )
,
.
. , ,
( ), . ,
,
, Ingres ( , ) System R. , SQL 1999 .
,
COMMIT; , , ,
COMMIT . 15.8.
15.8. SQL
SQL ( ,
)
, . , , SQL
( CALL RETURN). , 4, SQL BEGIN
TRANSACTION, COMMIT ROLLBACK, , , START
TRANSACTION, COMMIT WORK ROLLBACK WORK.
START TRANSACTION.

15.

589

START TRANSACTION <option commalist> ;


<option commalist>, , , ( ,
, ).
READ ONLY READ
WRITE. ,
READ WRITE ( , READ
UNCOMMITTED, READ ONLY).
READ WRITE,
READ UNCOMMITTED.
ISOLATION LEVEL <isolation>,
<isolation> READ UNCOMMITTED , READ
COMMITTED , REPEATABLE READ SERIALIZABLE .
16.
COMMIT ROLLBACK .
COMMIT [ WORK ] [ AND [ NO ] CHAIN ]
; ROLLBACK [ WORK ] [ AND [ NO ]
CHAIN ] ;
WORK . AND
CHAIN START TRANSACTION
COMMIT ( <option commalist>, START TRANSACTION); AND NO CHAIN
. CLOSE ( ), , WITH HOLD (
COMMIT).
. 4, WITH HOLD . , WITH HOLD,
COMMIT,
, FETCH .
,
OPEN.
, SQL .
, ( ).
SAVEPOINT <savepoint name> ;
,
.
ROLLBACK TO oavepoint name> ;
, , , ROLLBACK
.

590

IV.

RELEASE <savepoint name> ;


.
15.9.
. ,
( , ;
16). ACID, ,
( ),
.
,
( ).
,
.
BEGIN TRANSACTION
COMMIT ( ) ROLLBACK (
). COMMIT ( ). ROLLBACK
( ).
,
ROLLBACK ( ).
() ()
. ,
COMMIT ( ).
, ,
-, , , , -, , , , .
ACID .

( /).
, ,
, .
.
, ( )
,
. / .
, ( )
(,
), ,
( - ), , . , -, ,

15.

591

" , ", -, , (
) , (
).

, SQL. ,
START TRANSACTION SQL, .
, . , . ,
( ). , SQL
SQL , . SQL, , COMMIT SQL (
ROLLBACK, ). COMMIT SQL ( COMMIT
ROLLBACK) . ,

( 16). ,
, ( 16).

15.1.
( ..), ..
(
..). , .
15.2. , .
, .
15.3. .
?
15.4. ?
) MI.
)
COMMIT.
15.5.
.

592

IV.

15.6. , SQL
,

. , DELETE
CASCADE (.. ).
.
SQL, SQL.

15.1. Bernstein P.A. Transaction Processing Monitors // . November 1990. 33,
11.
, -
.
.
: "- , ... , ,
, , , ,
, , -.
-".
15.2. Bernstein P.A., Hadzilacos V., Goodman N. Concurrency Control and Recovery in
Database Systems. Reading, Mass.: Addison-Wesley, 1987.
(
), , ,
.
15.3. Bilris A. et al. ASSET: A System for Supporting Extended Transactions // Proc. 1994
ACM SIGMOD Int. Conf. on Management of Data, Minneapolis, Minn. May 1994.
,
, ( , ), [15.16].

. , , "
[ ] - ".
ASSET .
( COMMIT,
), " , ".
, , ASSET

. 15.

593

" , ,
, ".
15.4. Bjork L.A. Recovery Scenario for a DB/DC System // Proc. ACM National Conference.
Atlanta, Ga. August 1973.
(Davies) [15.7] , , .
15.5. Cms R.A. Data Recovery in IBM DATABASE 2 // IBM Sys. J. - 1984. - 23, 2.
, DB2 (
, ), , , DB2
,
.
, ,
, (
, 16).
15.6. Date C.i. Distributed Database: A Closer Look // C.J. Date and Hugh Darwen.
Relational Database Writings 1989-1991. Reading, Mass.: Addison-Wesley, 1992.
15.6 ,
. ,
1,
(.. ), 2. , 1 ,
, 2
( 21).
. . ,
( ),
(
), ,
.
.
,
. ,
21 [21.13].
15.7. Davies ., Jr. Recovery Semantics for a DB/DC System // Proc. ACM National
Conf. Atlanta, Ga. August 1973.
. [15.8].
15.8. Davies ., Jr. Recovery Data Processing Spheres of Control // IBM Sys. J. 1978.
17, 2.

594

IV.
(Spheres of Control)
, .
, ,
. , , .

15.9. Garcia-Molina H., Salem . Sagas // Proc. 1987 ACM SIGMOD Intern. Conf. on
Management of Data. San Francisco, Calif. May 1987.
,
, , , , (- ). (,
, ), , -, , -, ,
(, ..) , (
16). ,

, , .
. (saga)
( ), ,
, [15.7],
( , , ). ,
" 100 . "
" 100 . ". COMMIT ,
. , !
15.10. Gray J. Notes on Data Base Operating System // R. Bayer, R. M. Graham, and
G. Seegmuller (eds.). Operating Systems: An Advanced Course (Springer-Verlag Lecture
Notes in Computer Science 60). New York, N.Y.: Springer-Verlag, 1978.
: IBM Research Report RJ 2188. February 1978.
(, , )
.
. , , [15.12],
.

15.

595

15.11. Gray J. The Transaction Concept: Virtues and Limitations // Proc. 7th Intern. Conf. on
Very Large Data Bases. Cannes, France. 1981.
, ,
.
15.12. Gray J., Reuter A. Transaction Processing: Concepts and Techniques. San Mateo,
Calif: Morgan Kaufmann, 1993.
- , , , . ,
. "... "; "
"; " , ...
"; " ". ,
, , . .
15.13. Gray J. et al. The Recovery Manager of the System R Data Manager // ACM .
Surv. June 1981. 13, 2.
[15.13], [15.19]
System R ( , ).
[15.13] , [15.19] ,
.
Harder ., Reuter A. Principles of Transaction-Oriented Database Recovery // ACM
. Surv. December 1983. 15, 4.
ACID.
,
,
.
, ""
(, )
.

596

IV.

15.15. Harder ., Rothermel . Concepts for Transaction Recovery in Nested Transactions //


Proc. 1987 ACM SIGMOD Int. Conf. on Management of Data. San Francisco,
Calif. - May 1987.
, (
..). ,
,
ACID, ,
, .
16.10.
15.16. Korth H.F. The Double Life of the Transaction Abstraction: Fundamental Principle and
Evolving System Concept (invited talk) // Proc. 21st Int. Conf. On Very Large Data
Bases. Zurich, Switzerland. September 1995.
,
, .
15.17. Korth H.F., Levy E., Silberschatz A. A Formal Approach to Recovery by Compensating
Transactions // Proc. 16th Intern. Conf. on Very Large Data Bases. Brisbane,
Australia. 1990.

, [ 15.9]
( ) .
15.18. Lomet D., Turtle M.R. Redo Recovery after System Crashes // Proc. 21st Int. Conf. On
Very Large Data Bases. Zurich, Switzerland. September 1995.

(.. ). "[]
, ...
[ ] ".
, .
15.19. Lorie R. A. Physical Integrity in a Large Segmented Database //ACM TODS. March
1977.-2, 1.
[15.13], System R. (, (integrity)
, 9.) .
, ,
- . ""

15.

597

. , , .
, .
, , , ,
DB2 [15.5], SQL/DS [4.14].
15.20. Mohan , Haderle D., Lindsay ., Pirahesh H., Schwartz P. ARIES: A Transaction
Recovery Method Supporting Fine-Granularity Locking and Partial Rollbacks Using
Write-Ahead Logging//ACM TODS. - March 1992. - 17, 1.
, ARIES. ARIES " "
, , , DB2. : " [ ] : , ;
; , ; ,
, / ; (
..); , /
; , /; ,
; , (, ,
..); ,
( ) ,
/
.. [ARIES] ".
ARIES , :
ARIES/CSA ( "/"), ARIES/IM ( ), ARIES/KVL ( Key Value Locking)
, , ARIES/NT ( ) .. . [15.21].
15.21. Mohan . Repeating History Beyond ARIES // Proc. 25th Int. Conf. on Very Large Data
Bases, Edinburgh, Scotland. September 1999.

16

16.1.
16.2.
16.3.
16.4.
16.5.
16.6.
16.7.
16.8.
16.9.
16.10.
16.11.
16.12.




, ID
SQL

16.1.
, ,
,
. , ,
, ,
,
. ( ,
,
16.2.) .
.

600

IV.

, 16.2 , ,
.
16.3
, . (
,
.
.)
16.4 ,
, 16.2.
, ,
.
16.5.
16.6 ,

.
16.7 ,
.
16.8 16.9

.
16.10
ACID .
16.11 SQL.
, 16.12 .
. -,
, ,
,
( ,
, , , " " [16.6]). , , , ,
,
. .
16.2.
, . ,
, . , , , 15, , , , -
. ,

16.

601

, ,
( ),

, . .
.
.
.
.

, . 16.1. ,
, :
t tl, t
t2, t3 (
, tl), t4 ( , t2, , tl). t4 , , ,
.

. 16.1. , t4
. .

,
(, , ) ,
, . ,
, ,

602

IV.

, ,
( ). . 16.2 16.3.

. 16.2. , A
t2

. 16.3. ,
t2 t3
(. 16.2)
( ) t2.
t3 . , , t ,
t2, , tl.
. , ,
- ; , - . ( ,
.)
(. 16.3) .

t2, t3,
t3 t , tl, ..
.

16.

603


. 16.4, , ,
(ACCount ). ,
10 3 1. , , , 110, ; ,
1. , . :
, ,
3.
. , ,
.
.
'
. .

. ,
, ; ,
(,
, BEGIN TRANSACTION COMMIT
ROLLBACK). , , R () w (). , , , B , ,
t. , .
RR. ,
t. ,
.
RW. t,
t.
, ( . 16.4)
, ,
RW.
. , t, ,
1

(.. ),
, , , ,
.

604

IV.

, ; ( ) , RW.
WR. t, t. , ( . 16.2,
, ) ; , ,
WR.
. , , (dirty read).

. 16.4. ,
WW. t, t . , ( . 16.1,
. 16.3) ; , , WW.

16.

605

. , ,
(dirty write).
16.3.
16.1, , 16.2,
,
. , , ( ,
), - ( ),
( ). , ,
, , " ",
, , . ,
, .
, .
1. , ,
: ( X exclusive)
( S shared), ,
.
. X S , ,
. , , X S ; 16.9. ,
, ,
, , ;
16.9.
2. (X),
t
.
3. (S) t,
:
X t
;
S t
( ,
S ).

(. 16.5). : t ,
t, (

606

IV.

, ), ,
t,
( "
"). "N" ( ), a "Y" ( ). , .

. 16.5.
' X S
,
,
X S , , 16.2.
1. , ,
S .
2. , ,
X . ,
S , ,
(RETRIEVE UPDATE),
, , ,
S X.
. , ,

S ,
X (
S X) . , , , (INSERT) (DELETE),
(UPDATE) , INSERT DELETE. .
3.
- , ,
, . ,
,
, .
. " , ",

16.

607

, ,
.
, , ( livelock,
starvation). ,
("
"). 4. X
(COMMIT ROLLBACK). S
( ,
16.8).
.
16.6. , ,
.
16.4.

, , 16.2.
.

. 16.6 . 16.1. ,

. UPDATE
t3 ,
X t, S, , .

. 16.6. , t4

608

IV.

t4. ,
- . , ! , , . ,
16.5.

. 16.7 16.8, , . 16.2
16.3. , , , .

. 16.7. ,
t2

. 16.8. ,
t2

16.

609

t2 (RETRIEVE
. 16.7 UPDATE . 16.8) ,
t, X, , .
, ( COMMIT, ROLLBACK).
. ( , , , , ,
). , , .

. 16.9 . 16.4. , .
UPDATE t6 ,
X 1,
S, ,
. , RETRIEVE t7 ,
S 3, X, ,
. ( ) , . , 16.5.
16.5.
, ( , ) . , , ,
,
. . . 16.10 ;
rl 2 ,
(. 16.9), "LOCK . . . EXCLUSIVE" ,
X, .
,
,
, ,

610

IV.

2. . 16.10 , , (
, ), , . , System R,
, , , [16.9].

. 16.9. , t7

, , .
(Wait-For Graph). , , , " " (. . 16.4). ,
, (..
, ), ""
2


" " (deadly embrace).

16.

611

,
.
. ; -
,
, .

. 16.10.
, , ,
, .
, , , , . "deadlock
victim" ( ); . ,

. , ,
.

,
,
, ,
( ).
. , "-" "-", [16.19], .
.

612

TV.

(
).
,
,
.
"-" (Wait-Die).
, , ;
. , .
"" (Wound-Wait).
, , ; ,
. , .
,
.
, (
) , ,
, . , "-"
,
, , "" ,
, .
,
. , ,
. ,
(
),
. ( ) ,
.
16.6.

, . ; ,
, 3. ( , ) , (..
3
(conflict serializability) (view serializability).

"" . , , [16.21].

16.

613

). ,
, .

,
.
,


.
.
1. , ; ,

, 15.
2. , ,
,
( ,
, ).
3.
,
,
(..
, ).
" "!
,
,

(. . 16.3), ,
(..
),
.
, 16.2 (. 16.1-16.4),
, ,

. , " ,
" " , " .
, , 16.4, ,
, .
. 16.7 16.8 " , ". . 16.6 16.9 , , ,
(, , -

614

IV.

). , " ,
".
. ,
, , . , ,
. , , ( ). ,
, . , , .
, ,
, , ,
. ,
, , . , , " 1 ", , " " ( ). ,
10. ", "
= 22, " , "
= 21.
, , " , " " , ", .
( )
(Eswaran) . [16.6]. ,
, ,
4.
,
.
, , :
(,
), ;

- .
, , ,
: ( ) ( ).

4
;
.

16.

615

.
ROLLBACK, (
16.7 16.8). ,
, 16.3.

, ,
. , I ,
1, 2, . . ., . I ,
S,
1, 2, . . ., , I S. s I.
, Ti j 1,
2, . . ., . , Ti Tj S. I
, Ti Tj.
, ,
, , ,
, ; , , .
( , , . . . , z
, , . . ., z,
, , ,
(.. ),
.) ,
,
, .
, ,
(.. ),
, , , ,
. ,
,
, , ,
; , ( COMMIT), . , ; , ,
, , , (

).
COMMIT

616

IV.

16.7.
, ,
, /
, . , , .
, 16.2, , .
, (
16.2) , ,
, . . 16.11, . 16.2 ( ,
, ).
:
ROLLBACK , , ,
. , . , , , .

. 16.11.
, [15.2].
- ,
.
, (
, )
, .
,
. , ,
,
.

16.

617

. 16.12,
. 16.11 ( ,
,
t ). . 16.11, , ROLLBACK
, ,
, .
, , . , ,
; , ,
, , ,
. , ,
, , .

. 16.12. ,
,
[15.2].
- , .

.
5. , , , ,
, , .
5

,
S , ,
.

618

IV.

16.8.
,
, ACID. ,
, , , ,
.
, , , , ,
.
"" ( , ,
, ).
,
. , ,
, ,
- ! , ,
, . , ,
, ,
.
, [16.10],
SQL DB2 . ,
, (
), ,
( ). , DB2,
. (Repeatable Read RR);
, . , ,
(Cursor Stability CS) :
6 t

t,
, " t
,
6
,
( 4), " ".
, DB2 1 t "" (update U), S (. [4.21]).

16.

619

X,
.
, t . t ( ,
!),

. , (RR)
( X)
.
.
1. ,
CS; ,
. , , ,
RR ,

. , ,
RR CS; ,
CS, (
)
. , CS
, RR ( ,
, ).
2. , ,
CS .
, : "
,
,

".
3. ,
, , ,
,
,
(
LOCK). , DB2
LOCK TABLE, ,
, ,
, DB2
. (, , SQL
,
16.11.)
, , RR

620

IV.

DB2. , SQL , ,
( 16.11).

, ,
, .
( ,
).
, ,
, . ,
100 .
,
(100 .).
, ,
, 200 .
, ,
, 100 . ,

( , ).
,
,
, (,
,
, ).
, 125 .
100 .!
, - , : , , . (, " , ", " , ").
,
. ,
, , ; , ,
, , " " (. [16.6]
[16.13])7. ,
7

,
, - , .

16.

621

( , , ,
, ).
, [15.12], , , ,
, . , , ,
, ,
. , ( ) X .
[15.12].
16.9.
, , , . , ,
,
, , ,
, ( ) . [16.10],
[16.11]. , , , , , , .
, X ,
X ; ,
-
.
, X
R.
, - R; ,
. ? , , R , -
- , , , - R. ,
, (, , , ) ,
.
, - .

622

IV.

, , X S
, .
, [16.10], [16.11],
, ,
, :
(Intent Shared IS) , (Intent Exclusive IX)
(Shared Intent Exclusive SIX)
. , . (,
R; X S.)
(IS).
S R ,
.
(IX). , IS, ,
R X
.
(S).
,
R (
BR).
(SIX).
S IX; ,
,
R,
R X .
(X).
- R (
R ).
, 16.3 (. 16.13).

. 16.13. ,

16.

623

.
1. S
, IS
( ) ,
.
2. X
, IX
( ) ,
.
( , . . [16.10].)
, , ,
. ,
. 16.14. , L2 (..
), L1 , "N" () L1
"N" L2 (.
. 16.13). , ,
, ,
( , , ). ,
S, IX .

. 16.14.
, ,
,
. , , ,
IS , .
, , -,
IX. , ,
LOCK ,

624

IV.

S, X SIX , .
, DB2 ( S X,
SIX).
, .
.
, , ,
S
S IS, ,
S. , [16.9].
16.10. ,
ACID
15,
ACID . ,
, .
, ACID , , , (atomicitycorrectness-isolation-durability). .
. "
".
( consistency).

,
.
. , ,
,
.
.
,
.
, ACID ,

? , , .

, , , 9, ,
(.. ),

16.

625

.
, .
1. ,
( ).
- ,
, ,
. ,
;
(
[9.16] 9). (
"i" isolation) ,
,
,
, .

,
, ,
.
2. , ,
( , )
. ,
,
, (
). ,

F,
F,
( ,
)8. , "I"
, .
3. ,
,
( ,
).
( . 9) ,

!
,
, ,
.

8
, , ; ,
, .

626

IV.

4. ,
, .
. .
, ,
.
18.
, ,
. , " si 1 ". S1 , , , 1
.
, , .
BEGIN TRANSACTION
;
UPDATE S WHERE S#
= S# ('S1') { CITY := 'Paris' } ;
UPDATE P WHERE P#
= P# ('P1') { CITY :=
'Paris' } ;
COMMIT ;
COMMIT, UPDATE . , , , UPDATE, " S1 1
?" UPDATE, TO
.
, ,
(.. ) , . , INSERT, DELETE UPDATE
.

.
UPDATE S WHERE S# = S# ('S1') { CITY := 'Paris'
} , UPDATE P WHERE P# = P# ('P1') { CITY :=
'Paris' } ;

UPDATE (.., , "
"). , ,

UPDATE, "
UPDATE" .
,
,
(.. , ).

16.

627

ACID . , C-I-D-A (Correctness


Integrity-Durability-Atomicity).

( 15) , . ,
. , (Gray)
(Reuter) [15.12].
. .
, .
. .
, , . , [ !].
,
( !) .
, ACID (consistency),
9,
(correctness), , - (. . 2
" "). , , , , . , , ,
, .

. , " ",
. , , ,
, ,
( ) .
, "
9
, ,
, , ,
- . , ,
,
.

628

", , , .
( )
( ).
,
( ).
, , . , (
), ,
.

. , ,
. , ,
. , .
: , .
BEGIN TRANSACTION ( ) ;
BEGIN TRANSACTION(
) ;
t ; COMMIT (
) ;
ROLLBACK ( ) ;
ROLLBACK ,
( ).
; ,
ROLLBACK t,
. ,
, , ,
, ,
.
, , (Davies) [15.8],
,
. [15.15] ,
: ,
. , , COMMIT, , , , , . ,
COMMIT ,
, .

16.

629

COMMIT ,
, COMMIT (
).
. ,
.
,
(
). ,
, , . , .
BEGIN TRANSACTION
(.., BEGIN TRANSACTION ,
, ).
COMMIT ,
( , ,
).
ROLLBACK ,
( ,
..,
, ).
, , ,

( , ,
)10. , 100%.

, . ,
( ).
. : ,
,
, ; ,
. , , ,
, 11.

10
[15.15] ,
, , , ,
,
. .
11
, , , ,
, SQL.

630

IV.


.
? ,
.
? .
? .3
? ,
, "
".
. , ( ), ,
.
, , .
, , ! ,
, ,
25 . , , , , , ,
.
, , , .
16.11. SQL
SQL - ;
12.
, ,
(, , ) . , , , 1,
2 ( ),
1.
. ,
READ COMMITTED , REPEATABLE READ
SERIALIZABLE (. ). ,
12
,
, , .

16.
631
READ UNCOMMITTED, , , -, , , -,
READ ONLY ( READ WRITE, ).
, SQL
START TRANSACTION ( 15).
13
SERIALIZABLE,
REPEATABLE
READ,
READ
COMMITTED READ UNCOMMITTED.
SERIALIZABLE; ,
,
SERIALIZABLE > REPEATABLE READ >
READ COMMITTED > READ UNCOMMITTED.
SERIALIZABLE
( ),
.
,
.
: ,
( 16.2, 16.8),
, '4.
. 16.1 ( "Y" ,
, a"N" ).
16.1. SQL

, REPEATABLE READ, SQL, (Repeatable Read RR),


DB2, . , RR
DB2 SERIALIZABLE .
16.12.
. , - , :
,
13

SERIALIZABLE , ,
, .
TWO PHASE, , ( )
.
14

. [16.2] [16.14].

632

TV.


. - ,
, ..
.
. : ( S) ( X).
S ,
S , X . X , .
.
, S , X , .
.
.
,
, . , , ,
. , , , , .
-
( ).
,
.
, .
, .. ( , DB2, SQL
READ COMMITTED).

. ,
,
,
, , (
, ).
, S X
. LOCK
( ) ,

16.

633

, , ( SQL
).

ACID , ,
, . ,
,
SQL. SQL
, ( SERIALIZABLE ,
REPEATABLE READ, READ COMMITTED, READ UNCOMMITTED),

.

16.1. .
16.2. :
) ; !
) .
, RW, WR WW.
16.3. Tl, T2 , :
1 1 ;
2 ;
, 1
( ).
) , Tl, T2 .
,
.
) , Tl, T2
.

, - ?
) - , () , ?

634

IV.
) - , , ,
?

16.4.
1, 2, ..., 12 , , ..., .
tO ......
tl (Tl) : RETRIEVE A
; t2 (T2) : RETRIEVE
;
... (Tl) : RETRIEVE ;
... (T4) : RETRIEVE D ;
... (T5) : RETRIEVE A ;
... (T2) : RETRIEVE E ;
... (T2) : UPDATE E ;
... (T3) : RETRIEVE F ;
... (T2) : RETRIEVE F ;
... (T5) : UPDATE A ;
... (Tl) : COMMIT ;
... (T6) : RETRIEVE A ;
... (T5) : ROLLBACK ;
... (T6) : RETRIEVE ;
... (T6) : UPDATE ;
... (T7) : RETRIEVE G ;
... (T8) : RETRIEVE H ;
... (T9) : RETRIEVE G ;
... (T9) : UPDATE G ;
... (T8) : RETRIEVE E ;
... (T7) : COMMIT ;
... (T9) : RETRIEVE H ;
... (T3) : RETRIEVE G ;
... (T10) : RETRIEVE A ;
... (T9) : UPDATE H ;
... (T6) : COMMIT ;
...
(T1l) : RETRIEVE ;
... (T12) : RETRIEVE D ;
... (T12) : RETRIEVE ;
... (T2) : UPDATE F ;
... (T1l) : UPDATE ;
... (T12) : RETRIEVE A ;
... (T10) : UPDATE A ;
... (T12) : UPDATE D ;
... (T4) : RETRIEVE G ;
t3 6 ......
, RETRIEVE i ( i)
( ) S i, UPDATE i ( i) ( ) i
X. ,
. ( , " "), t3 6.
?

16.

635

16.5. , . 16.116.4. ,
(CS),
(RR)?
. CS RR DB2, 16.8.
16.6. : X, S, IX,
IS SIX.
16.7.
.
16.8. ,
.
16.9. SQL :
, .
, 16.2?
16.10.
,
[16.1].

[15.2], [15.10] [15.12]
15.
16.1. Bayer R., Heller M., Reiser A. Parallelism and Recovery in Database Systems // ACM
TODS. - June 1980. - 5, 2.
15, (, )
, , . ,

, . .
1.
, .
2.
,
, .

(. [16.8], [16.12], [16.15] [16.20]), ,
(multi-version locking);

636

IV.
(multi-version read)
. ,
, ..
. ,
.
( ).
.
, ,
.

.
(. 21), , , ( ).
, .
,
,

. -
( , )
.
,
,
,
(
).
, ,
15 ( , ,
,
).
, , ,
" " .

16.2. Berenson H. et al. A Critique of ANSI SQL Isolation Levels // Proc. 1995 ACM
SIGMOD Int. Conf. on Management of Data. San Jose, Calif. May 1995.
15
, WW , , . , , , [16.3].

16.

637

"ANSI SQL" (. 16.11). "[] ,


". , ,
(. 16.2).
, ,
.
( ).
" SERIALIZABLE
". ,
SERIALIZABLE,
, , ,
.
" , ...
". ,

. ,
.
", ,
[ READ
UNCOMMITTED] , ". '! ?
. [16.14].
16.3. Bernstein P.A., Goodman N. Timestamp-Based Algorithms for Concurrency Control in
Distributed Database Systems // Proc. 6th Int. Conf. on Very Large Data Bases.
Montreal, Canada. October 1980.
, , . , ,
, ( ). .
1. ,
.
2. ,
.
. ,
.

638

( , [ 16.16]).
,
(
- ).
. ,
.
, , (
,
). ,
! ,
- ,
; , ( ) - . , [15.12] ,
[16.16], , , .
. , ,
[16.22] ; , ,
( ,
).
16.4. Blasgen M.W., Gray J.N., Mitoma M., Price T.G. The Convoy Phenomenon // ACM
Operating Systems Review. April 1979. 13, 2.
(convoy)
.

.
.
, , , .
.
, , .. , , - ,
, .
,
.

16.

639

. - ,
, ,
, ,
.
.
, ( ) , ,
. , .
(lock thrashing)
,
- . ,
,
, " - ".
16.5. Blott S., Korth H.F. An Almost-Serial Protocol for Transaction Execution in MainMemory Database Systems // Proc. 28th Int. Conf. on Very Large Data Bases, Hong
Kong. August 2002.
, .
16.6. Eswaran K.P., Gray J.N., Lorie R.A., Traiger I.L. The Notions of Consistency and
Predicate Locks in a Data Base System // CACM. November 1976. 19, 11.
.
16.7. Franaszek P., Robinson J.T. Limitations on Concurrency in Transaction Processing //
ACM TODS. - March 1985. - 10, 1.
. [16.16].
16.8. Franaszek P., Robinson J.T., Thomasian A. Concurrency Control for High Contention
Environments //ACM TODS. - June 1992. - 17, 2.
, , , , ( ). .
" [ ] ,
".
, , " ".
16.9. Gray J.N. Experience with the System R Lock Manager // IBM San Jose Research
Laboratory internal memo, 1980.

640

IV.

, ,
. ,
, .
10%
, , 1%
.
,

.
(RR)
, ,
(CS).

.
(97%)
U, DB2, System R.
. , U
S, U , , X. [4.21].)
16.10. Gray J.N., Lorie R.A., Putzolu G.R. Granularity of Locks in a Large Shared Data Base//
Proc. 1st Int. Conf. on Very Large Data Bases. Framingham, Mass. September
1975.
.
16.8, (granularity) . , , ,
(, ,
).
.
, . -,
,
, . -,
.
,

. , , , ,
# .
, , . ,

' 16.

641

, , .

.
X
X.
S SIX S.
S IS
, IS (
) .
X, IX
SIX , IX (
) .

, ,
.
, ,
, ,
. , IX ,
, ,
.
16.11. Gray J.N., Lorie R.A., Putzolu G.R., Traiger I.L. Granularity of Locks and Degrees of
Consistency in a Shared Data Base // Proc. IFIP TC-2 Working Conf. on Modeling in
Data Base Management Systems (ed. G. M. Nijssen). Amsterdam, Netherlands:
North-Holland/New York, N.Y.: Elsevier Science, 1976.
( degrees of consistency)16.
16.12. Harder ., Rothermel . Concurrency Control Issues in Nested Transactions // The
VLDB Journal. January 1993. 2, 1.
" " 15, .
.
16.13. Jordan J.R., Banerjee J., Batman R.B. Precision Locks // Proc. 1981 ACM SIGMOD
Int. Conf. on Management of Data. Ann Arbor, Mich. April/May 1981.
16
. . , , , "" ,
, . , ,
" ", ,
( "").

642

IV.

, ( ), . (. 16.8, [16.6]).
. -, ,

. -, ,
. , , ,
, (
).
16.14. Kempster ., Stirling , Thanisch P. Diluting ACID // ACM SIGMOD Record.
December 1999. - 28, 4.
"", " ACID"
( ACID , )!
, , ( , "
, ").
SQL [16.2],
,

. ( )
[16.2].
16.15. Korth H.F., Speegle G. Formal Aspects of Concurrency Control in Long-Duration
Transaction Systems Using the NT/PV Model // ACM TODS. - September 1994.. - 19,
3.
(., , [15.3], [15.9], [15.16] [15.17]),
, ,
, , ,
.
NT/PV (Nested Transactions with Predicates and Views ),
. , ; " ". ,
" , ".
16.16. Kung H.T., Robinson J.T. On Optimistic Methods for Concurrency Control // ACM
TODS. -June 1981. -6, 2.
,
( ) , ,
,

16.

643

. , ( ) ,
. . . ,
.
,
- .
[16.7] ,
(.. ), . ,

. ( [15.12], , ,
""
, .. , . ,
, [16.17].)
16.17. O'Neil P.E. The Escrow Transactional Method // ACM TODS. December 1986.
11, 4.,
. ,
, ,
,
(
). ,
.. ,
. ,
,
. TC 10 . .,
10 .,
. . .
, ,
. ( ,
.)
, , ..
, .
(,
" , , ").
,

644

TV.

-, ( ,
COMMIT ,
ROLLBACK, ).
,
. , , IMS Fast Path
IBM. ,
[16.16].
, ,
.
16.18. Papadimitriou . The Theory of Database Concurrency Control. Rockville, Md.:
Computer Science Press, 1986.
, .
16.19. Rosencrantz D.J., Stearns R.E., Lewis II P.M. System Level Concurrency Control for
Distributed Database Systems //ACM TODS. June 1978. 3, 2.
16.20. Salem K., Garcia-Molina H., Shands J. Altruistic Locking // ACM TODS. March
1994._ 19, l.
, , ( - ), ,
.
, .
, , , ,
. , (
, , , )
, , .
16.21. Silberschatz A., Korth H.F., Sudarshan S. Database System Concepts (4th ed.). New
York, N.Y.: McGraw-Hill, 2002.
'
( ).
16.22. Thomas R.H. A Majority Consensus Approach to Concurrency Control for Multiple
Copy Databases//ACM TODS. June 1979. 4, 2.
. [16.3].
16.23. Thomasian A.Concurrency Control: Methods, Performance, and Analysis // ACM
. Surv. March 1998. 30, 1.

.

II ,
, .
, , II ,
. ,

, (
III IV ).
, .

( 17).
( 18).
( 19).
( 20).
( 21).
( 22).
( 23).
( 24).


, , ( ,
) .

17

17.1.
17.2
17.3.
17.4.
17.5.
17.6.
17.7.




:
SQL

17.1.

( , ),
. (security)
,
,
'. , .

.


(!).
, ,
,
, ,
, , .
1
9, , ,
, .

648

V.

, , ,
,
,
. ( )
. - . , 9.
. , , , ,
, ( Internet, ).
.
, (,
, ,
).
(,
).
(, ,
, ,
).
(,

).
(,
,
).
(,

,
).
, (,
).
,
.
(discretionary) (mandatory), . (
) , ,
.
.

17.

649


( , )
. , , ,
. (, U1
, ,
U2 ,
.)
.
, ,
,
.
, .

. ( U1 ,
,
, , , U2,
, .)
, 17.2,
17.3.
, ( ),

.
, , , , . , .

(.. ,
)
( ).
,

. (
,
.)
, .
,
,
, ..
.
( , ),
( , , ). ,
,
. (.. ,
, ) ,

650

V.

. ,
,
:
, , , ,
.. " , " [17.6].
, ,
, . ,
( ),
, , . ,

. [17.11], . : "
". ,
, ,
(, , ),
, , .
17.2.
, , , ,
. ,
. , .
, .
, , , .
, ,
(.. - , ).
2, .
AUTHORITY SA3
GRANT RETRIEVE { S#, SNAME, CITY }, DELETE
ON S
TO Jim, Fred, Mary ;
2
Tutorial D [3.3]
, "
" Tutorial D.

17.

651

, .
1. ( SA3, "suppliers authority three"
3).
.
2. , GRANT.
3. ON ,
.
4. (, ),

, .
.
AUTHORITY <authority name>
GRANT <privilege commalist>
ON <relvar name>
TO <user ID commalist> ;
. , <authority name>, <relvar name> <user ID commalist>,
. , ALL
.
<privilege>
.
RETRIEVE [
{ <attribute name commalist> } ]
INSERT [ {
<attribute name commalist> } ]
DELETE
UPDATE [ {
<attribute name commalist> } ]
ALL
RETRIEVE (, ), INSERT (, ), DELETE () UPDATE (, ) (, ; , RETRIEVE , ,
,
). RETRIEVE <attribute name commalist>,
. INSERT UPDATE . ALL RETRIEVE ( ), INSERT
( c ), DELETE UPDATE ( ).
. . , ,
, ,
(,

652

V.

, ).
.
, ,
? (, ). ,
.
,
.
(.. ).
, ( ,
,
).
, , .
DROP AUTHORITY <authority name> ;
, , .
;
.
1. AUTHORITY EX1
GRANT RETRIEVE ( #, PNAME, WEIGHT )
ON P
TO Jacques, Anne, Charley ;
Jacques, Anne Charley
.
, ,
.
2. AUTHORITY EX2
GRANT RETRIEVE, DELETE, UPDATE (SNAME, STATUS)
ON LS
TO Dan, Misha ;
LS ( ; . . 10.4 10). Dan
Misha S. ,
. , Dan Misha
(DELETE) ( LS),
(INSERT) , (UPDATE)
s# CITY.

17.

653

3. VAR SSPPO VIEW


(S JOIN SP JOIN (P WHERE CITY = 'Oslo') { P# } )
{ ALL BUT P#, QTY } ;
AUTHORITY EX3
GRANT RETRIEVE
ON SSPPO TO
Lars ;
, :
Lars , , , .
4. VAR SSQ VIEW
SUMMARIZE SP PER S { S# } ADD SUM (QTY) AS SQ ;
AUTHORITY EX4
GRANT RETRIEVE
ON SSQ TO Fidel
;
Fidel
, .
, Fidel
.
5. AUTHORITY EX5
GRANT RETRIEVE, UPDATE
(STATUS)
ON S
WHEN DAY () IN ('',
'Tue', 'Wed', 'Thu', 'Fri')
AND NOW () > TIME
'09:00:00'
AND NOW () < TIME
'17:00:00''
TO
ACCOUNTING ;
AUTHORITY
WHEN, . , -
( , ),
DAY() NOW .
5 ,
ACCOUNTING ( )
. ,
(
).
,
- .
TODAY ().
USER (). , .
TERMINAL (). , .

654

V.


"". , ( , ) ,
. , , Nancy ,
, ,
, ( ).
: , , ,
. , , !

, University Ingres,
QUEL.
, ,
QLJEL
,
. ,
, .
.
DEFINE PERMIT RETRIEVE ON P TO U
WHERE P.CITY = "London"
( DEFINE PERMIT .) ,
QUEL.
RETRIEVE ( .#, P.WEIGHT )
WHERE
P.COLOR = "Red"
(PERMIT),
,
.
RETRIEVE ( .#, P.WEIGHT )
WHERE
P.COLOR = "Red" AND
P.CITY = "London"
,
. , .. ,
, . ,
(,
, ,
).

17.

655

,
[10.12], ( Ingres) [9.23]. , ,
( , ). ,
, ,
, . , , , ,

(. 17.6, ).
, .
, U .

RETRIEVE , . : "
". (, ,
: " ".)
, : "
, ".
DEFINE PERMIT .
DEFINE PERMIT operation name commalist>
ON <relvar name> [ ( <attribute name commalist> )
] TO <user ID>
[ AT <terminal ID commalist> ]
[ FROM <time> TO <time> ]
[ ON <day> TO <day> }
[ WHERE <bool exp> ]
, DEFINE
PERMIT AUTHORITY,
, WHERE ( AT, FROM ON
WHEN). .
DEFINE PERMIT RETRIEVE, APPEND,
REPLACE ON S ( S#, CITY ) TO
Joe AT TTA4
FROM 9:00 TO 17:00
ON Sat TO Sun
WHERE S.STATUS < 50
AND S.S# = SP.P#
AND SP.P# = P.P#
AND P.COLOR = "Red"

656 . V.
. (APPEND) (REPLACE) QUEL
(INSERT) (UPDATE), .

, . ,
.
(audit trail), , . ,
, , , .
, , , .
, , , , . (.
15), . , , (, , !).
:
( );
, ;
, ;
;
, ,
;
( );
( ).
, , ,
.
17.3.
, , , , .
, 17.1, , (classification level) ( , " ", "", " " ..),
(clearance level) , . , (,

17.

657

" " > "" > " " ..)-


,
(Bell) - (LaPadula) [17.3].
1. i j ,
j
{ simple security property).
2. i j ,
j ( star
property).
, . , ,
: " , i,
,
i". , , , ,
"", , .
. (INSERT),
, i
j ,
. ,
! ( , - ... , - .)
1990- . , , .
. , "" (Orange Book)
[17.21] "" (Lavender Book) [17.22]. ""
(Trusted
Computing Base ), ""
.
"" ""
,
. , , , D. , D
, , D, .. , D
, ,
. , .
. , 1 2 ( 1
, 2),
, ,

658

V.

( , , 17.2). , .
1,
, ..
.
2,
,
, .
.
1, 2 ( 1 ,
).
.
1,
( ,

"", " " ..).
.
2,
. ,
.
, ,
(. 17.4)
,
(.
[17.14]).
,
,
.
. , ,
, ,

(!).

1. ,
2.
. , , [17.15], [17.18], [17.23] (. , " "). , (trusted system) [17.19], [17.21], [17.22].

,
S. ,
, , .

17.
659
. 17.1. S ()
, ,
. 17.1. ( 4 LEVEL " ",
3 "", 2 " ".)

, U2 3 ("")
2 (" "), . S
-!

S1, S2, S3 S5.
U2 S1 S3. ,

S4.
,
. ("
").
S WHERE CITY = 'London'
.
S WHERE CITY = 'London' AND LEVEL <
. ,
S4, INSERT
.
INSERT INTO S RELATION { TUPLE { S#
S# ( 'S4' ),
SNAME NAME ( 'Baker' ),
STATUS 25,
CITY
'Rome' } } ;
INSERT, U3
S4. , .
INSERT INTO S RELATION { TUPLE { S #
S#('S4'),
SNAME NAME (
'Baker' )> STATUS 25,
CITY
'Rome', LEVEL
3 } } ;
,
{S#},
{S#,LEVEL}.

660

V.
. , , .
.
. ,
- , (polyinstantiation). INSERT
S4
U4 U3, . ,
, U2, .
(UPDATE) (DELETE)
( , , ).
. , ! .
17.4.
( ) ,
(,
..), .
, "
?", " ?"
.
, , . [17.8], " ,

. ".
, , ,
, (. 22)
.
. ,
, STATS, . 17.2.
,
(.. ). ,
,
Alf. ,
, Alf . 3.
3

Tutorial D . , 1 COUNT ( )
() EXTEND TABLE_DEE ADD COUNT( X ) AS
RESULT1.

17.
1. WITH ( STATS WHERE SEX = 'M' AND .
OCCUPATION = 'Programmer'
AS X : COUNT ( X )

661

: 1.
2. WITH ( STATS WHERE SEX = 'M' AND
OCCUPATION = 'Programmer' ) AS X
: SUM ( X, SALARY )
: 50 000.

. 17.2. STATS ( )
, ,
. , , , .
,

. , ,
- (
). ,
,
3-6.
3. COUNT

( STATS )

: 12.
4. WITH ( STATS WHERE NOT ( SEX = 'M' AND
OCCUPATION = 'Programmer' ) )
AS X : COUNT ( X )
: 11; 12 - 11 = 1.
5. SUM ( STATS, SALARY )
: 728 000.
6. WITH ( STATS WHERE NOT ( SEX = 'M' AND
OCCUPATION = 'Programmer' ) ) AS X
: SUM ( X, SALARY )
: 678 000; 728 000 - 678 000 = 50 000.

662

V.

, , , ,
b < < - .
. 17.2. b = 2,
, 2 < < 8. ,
.
SEX = 'M' AND OCCUPATION = 'Programmer'
.
7. WITH ( STATS WHERE SEX = 'M' ) AS
X :
COUNT ( X )
: 4.
8. WITH ( STATS WHERE SEX = 'M' AND NOT
( OCCUPATION. = 'Programmer' ) ) AS X :
COUNT ( X )
: 3.
7 8 ,
-, , Alf (
, Alf ). .
9. WITH ( STATS WHERE SEX = 'M' ) AS
X :
SUM ( X, SALARY )
: 328 000.
10. WITH ( STATS WHERE SEX = 'M' AND NOT
( OCCUPATION = 'Programmer' ) ) AS X
: SUM ( X, SALARY )
: 278 000; 328 000 - 278 000 = 50 000.
SEX = ' M ' AND OCCUPATION = ' Programmer'
(individual tracker) Alf [17.8],
Alf.
, BE, I, BE 1 AND BE2, 1 AND NOT BE2
I ( ,
1 1 AND NOT BE2, ..
, b < < - b).
, BE , 1, , 1 AND NOT BE2, . 17.3.
{ X : BE }

{ : 1 AND BE2 }
{ : 1 } MINUS { X : 1 AND NOT BE2 }

17.

663

. 17.3. 1 AND NOT 2


[17.8] ,
(
).
(general tracker) ,
, .. ,
. ( ,
, .)
,
2b < < - 2b
( b , /4,
). ,
, BE,
. ( ,
BE b.
, b - b, .) ,
,
NOT .
. , b = 2;
4 < < 6. , u , Alf , .. BE , .
SEX = 'M' AND OCCUPATION = 'Programmer'
, Alf.
: ,
, BE Alf ( 24),
, Alf
( 5-7).
1. .
.
AUDITS = 0
2. NOT , .

664

V.

WITH ( STATS WHERE AUDITS = 0 ) AS


X : COUNT ( X )
: 5.
WITH ( STATS WHERE NOT ( AUDITS = 0 ) ) AS
X : COUNT ( X )
: 5; 5 + 5 = 10. ,
.
3.
, BE, BE OR OR NOT T.
WITH ( STATS WHERE ( SEX = 'M' AND
OCCUPATION = 'Programmer' OR AUDITS =
0 ) AS X : COUNT ( X )
: 6.
WITH ( STATS WHERE ( SEX = 'M' AND
OCCUPATION = 'Programmer' OR NOT (
AUDITS = 0 ) ) AS X : COUNT ( X )
: 5; 6 + 5 = 11.
4. ,
, BE, ( 3 2), ..
BE Alf.
5 6 , 2 3,
[ COUNT SUM.
5. NOT T .
WITH ( STATS WHERE AUDITS = 0 ) AS X
: SUM ( X, SALARY )
: 438 000.
WITH ( STATS WHERE NOT ( AUDITS = 0 ) ) AS
X : SUM ( X, SALARY )
: 290 000; 438 000 + 290 000 = 728 000.
6. Al f
, BE OR OR NOT T.
WITH ( STATS WHERE ( SEX = 'M' AND
OCCUPATION = 'Programmer' OR AUDITS =
0 ) AS X : SUM ( X, SALARY )
: 488 000.

17.

665

WITH ( STATS WHERE ( SEX = 'M' AND


. ,.,_.
OCCUPATION = 'Programmer' OR NOT (
AUDITS = 0 ) ) AS X : SUM ( X, SALARY )
: 290 000; 488 000 + 290 000 = 778 000.
7. Alf,
( 5) , 6. : 50
000.
. 17.4.
{ X : BE } ( { X : BE OR T } UNION { X : BE OR NOT T } )
MINUS { X : T OR NOT T }

. 17.4.
(.. ), ( BE OR T ) ( BE OR NOT T )
. , BE q, , < b < q < 2b,
, ( BE OR NOT T )
, - .
. [17.8] ,
.
( 5) 3 .
. , , , . ,
[17.8]. ,
, , [17.8],
, .
, .
?
, , - . , (data swapping), ..
, ,
. (, ),

666

V.

, ( ) .
, .
. , , , [17.8], , "
.

.
, ".
17.5.
,
, . ,
, , ..
.
, ..
.

. () .
.
,
,
. ,
, , . , , , .
. .
AS KINGFISHERS CATCH FIRE
( , .) , ,
.
ELIOT
7 .
1. , .
AS+KI NGFIS HERS+ CATCH +FIRE
( "+".)
2. 00-26, 00, 01,..., Z 26.
.
0119001109 1407060919 0805181900 0301200308 0006091805

17.

667

3. . 2 ,
.
0512091520
4. ,
, ,
,
27.

5. . 4 .
FDIZB SSOXL MQ+GT HMBRA ERRFY
,
. (.
.) , ,
. ,
, . ,
, , ,
. ( , ..
.) ,
,
, , ,
.

:
, ,
.
,
, .
, , ,
. Data Encryption Standard (DES), IBM 1977 [17.20].
, 64
64- (
56 8 , 264, 256
). ,
, 16 ,
,

668

V.

. i-
, Ki, i. [17.20].
,
, Ki .
, DES ,
(56-) . 2000 Advanced Encryption Standard (AES),
(Rijndael) [17.5],
128, 192 256 . 128- , ;
[26.34], "- ,
, DES ,
149 . , 128- AES" ( ). [17.5].

, DES
; AES , , , ,
" ", - .
, , , .
, ,
. ( : , ). ,
, , , ,
.
(Diffie)
(Hellman) [17.9], , (Rivest), (Shamir)
(Adleman) [17.17]. , RSA (
), .
1. ,
.
2. (..
, ) .
[17.12] , , 130
, 7 ,
( ) ,

17.

669

, 63 , 40 4 (1 = 1 000 000 000 000 000).


RSA .
1. q,
= * .
2. ,
(.. ) (-1) *
(-1). . .
, ,
, .
3. d,
(-1) * (-1), .. ,
:
d * = 1 modulo ( - 1 ) * ( - 1 )
d , [17.17].
4. r , d.
5. (
r)
:
= e modulo r
6.
, :
= d modulo r
[17.17] , ..
d .
, , d r ( q )
. ,
(.. , d).
, .
. = 3, = 5; r = 15, (-1) * (-1) = 8.
= 11 ( ). d .
4
, RSA . [17.12] 1977 , 1990 (Lenstra) (Manasse)
155 [17.24]; ,
, ,
1 273 . 155
: 2!|2+1 ( , 512 = 2'). . [17.14],
( !) RSA.

670

V.

d * 11 = 1 modulo 8
d = 3. ,
13; :
= e modulo r = 13n modulo 15
= 1 792 160 394 037 modulo 15
= 7

:
- d modulo r
= 73 modulo 15
=3 43 modulo
15 . = 13
d ,
, , , (..
). ,
. ( ),
.
, , ,
DCA DCB. ,
DCA, DCB, .
,
. () ,
DCA, a

, .
= ( DCA ( ) )
DCB, , .
( DCB ( ) )
= ( DCB (

( DCA ( ) ) ) )
= ( DCA (
)
) /* DCB
*/
=
/* DCA
*/
, ,
,
,
DCA, . , .

17.

671

17.6. SQL
SQL . SQL. ,
.
, ,
,
.
SQL .


SQL 24 17.2.
2. CREATE VIEW LS AS
SELECT S.S#, S.SNAME, S.STATUS, S.CITY
FROM
S
WHERE S, CITY = 'London' ;
, .
GRANT.
GRANT SELECT, DELETE, UPDATE ( SNAME, STATUS )
ON
LS
TO
Dan, Misha ;
, , GRANT, CREATE AUTHORITY,
SQL . ( , , , 9.) '
3. CREATE VIEW SSPPO AS
SELECT S.S#, S.SNAME, S.STATUS,
S.CITY FROM
S WHERE EXISTS
( SELECT * FROM SP
WHERE EXISTS
( SELECT * FROM P
WHERE S.S# = SP.S# AND
SP.P#
=
P.P#
AND
P.CITY = 'Oslo' ) ) ;

GRANT.
GRANT SELECT ON SSPPO TO Lars ;
4. CREATE VIEW SSQ AS
SELECT S.S#,
SQ FROM

S ;

( SELECT SUM (SP.QTY)


FROM SP
WHERE SP.S# = S.S# ) AS

672

V.

GRANT.
GRANT SELECT ON SSQ TO Fidel ;

5 17.2 -
. SQL -
(CURRENT_USER, CURRENT_DATE, CURRENT_TIME ..), ,
, -
. ( DAY (),
5.)
.
CREATE VIEW S_NINE_TO_FIVE AS
SELECT S.S#, S.NAME, S.STATUS,
S.CITY FROM
S
WHERE CURRENT_TIME > TIME
'09:00:00' AND
CURRENT_TIME <
TIME '17:00:00'
GRANT .
GRANT SELECT, UPDATE ( STATUS )
ON
S_NINE_TO_FIVE TO
ACCOUNTING ;
, S_NINE_TO_FIVE
, , , . {. ,
.) , ,
CURRENT_USER, (, , )
. , . , , ,
( )
,
S_NINE_TO_FIVE, .
, ,

("" ,
). , (
) ,
, . ,
. , , .
,
(,
) .

17.

673

GRANT REVOKE
SQL
, . , . ( ) GRANT,
( ).
, . , (SELECT), (INSERT), (DELETE),
(UPDATE) (REFERENCES) ,
(TRIGGER)5. .
, , .. .
GRANT.
GRANT <privilege
commalist> ON
<object>
TO <user ID
commalist> [ WITH
GRANT OPTION ] ;

1. <privilege>
USAGE (), UNDER ( ), SELECT (),
INSERT (), DELETE (), UPDATE (), REFERENCES
(), TRIGGER ( ) EXECUTE ().
SELECT, INSERT, UPDATE REFERENCES
.
. ALL PRIVILEGES,
, (. [4.20]).
USAGE , ,
.
UNDER , -, ,
,
, , -, ,
(., , 20 26).
SELECT, INSERT, DELETE UPDATE
.
REFERENCES ,
(
5

(UNDER) , ,
SQL .

674

V.
, ).
TRIGGER
.
EXECUTE SQL
.

2. < objec t> TYPE


<type name>, TABLE <table name> (
EXECUTE) ,
<specific routine designator>,
.
. ,
TABLE SQL,
( )
, .
3.
<user ID commalist>
PUBLIC, , .
. SQL ;
ACCOUNTING,
.
, , . ,
, , ,
. , SQL
(. 17.1).
4. WITH GRANT OPTION, , ,

; , ,
, , ,
(). , ,
GRANT, WITH GRANT
OPTION , .
, . REVOKE .
REVOKE [ GRANT OPTION FOR ] <privilege commalist>
ON <object>
FROM <user ID
comma.list> <behavior>
;
GRANT OPTION FOR , , .

17.

675

<privilege commalist>, <object> <user ID commalist>


GRANT. <behavior>
RESTRICT ( ) CASCADE (
) ( ).
.
1. REVOKE SELECT ON S FROM Jacques, Anne, Charley RESTRICT ;
2. REVOKE SELECT, DELETE, UPDATE ( SNAME, STATUS )
ON LS FROM Dan, Misha CASCADE ;
3. REVOKE SELECT ON SSPPO FROM Lars RESTRICT ;
4. REVOKE SELECT ON SSQ FROM Fidel RESTRICT ;
RESTRICT CASCADE. ,
, .
, ?
, REVOKE .
, (orphaned),
,
. RESTRICT CASCADE .
RESTRICT ,
. CASCADE
, .
, , ,
.
17.7.
.
. ,
, , . ,
.
,
( ), .
,
.
, (RETRIEVE, INSERT ..), (.. , ) .
, ,
- .
.

676

V.


.
Ingres QUEL.
, , . , ,
"" ""
, .
. ,

. ,

. (
, 22.)
,
Data Encryption Standard (DES) Advanced Encryption Standard (AES),
. ,
RSA ,
. ,
.
SQL. , GRANT REVOKE , ( ).
, , , ,
, ,
. , DB2 . , DB2 ,
, .
DB2 (, ), .
, .

17.1. STATS ,
17.4.
STATS { NAME, SEX, CHILDREN, OCCUPATION, SALARY, TAX,
AUDITS } KEY { NAME }
, 17.2, :

17.

17.2.

17.3.

17.4.
17.5.

677

) Ford (RETRIEVE)
;
) Smith (INSERT) (DELETE)
;
) (RETRIEVE) ()
;
) Nash (RETRIEVE)
(UPDATE) SALARY TAX (
);
) Todd (RETRIEVE) USERID,
SALARY TAX ( );
) Ward (RETRIEVE),
Todd, (UPDATE) SALARY
TAX ( );
) Pope () ( RETRIEVE,
INSERT, DELETE UPDATE),
;
) Jones (DELETE)
, , .. ,
10 ;
) King (RETRIEVE)
.
AUTHORITY
,
, ,
..?
. 17.2 ,
, Hal ,
.
, ,
. (
17.4), ,
2 8.
. 17.3,
.
,
, AS
KINGFISHERS CATCH FIRE,
.
F N W A
L J V
J F
X

678

V.

W N

I P S U
S V D
17.6. R S A =
= 17 = 3.

7, g = 5

17.7.

, ,
?
17.8. . 17.1 SQL.
17.9. SQL ,
.

17.1. Agrawal R., Kiernan J., Srikant R., Xu Y. Hippocratic Databases // Proc. 28th Int. Conf.
on Very Large Data Bases, Hong Kong. August 2002.
: "[] , ,
,
... ... ... ".
17.2. Agrawal R., Kiernan J. Watermarking Relational Databases // Proc. 28th Int. Conf. on
Very Large Data Bases, Hong Kong. August 2002.
, ( , ).
17.3. Bell D.E., La Padula L.J. Secure Computer Systems: Mathematical Foundations and
Model // MITRE Technical Report M74-244. - May 1974.
17.4. Bouganim L., Pucheral P. Chip-Secured Data Access: Confidential Data on Untrusted
Servers // Proc. 28th Int. Conf. on Very Large Data Bases, Hong Kong. August 2002.
: "[ ]
,
,
.
- ".
,
, .
17.5. Daemen J., Rijnen V. The Block Cipher Rijndael // J.-J. Quisquater and B. Schneier
(eds.). Smart Card Research and Applications (Springer-Verlag Lecture Notes in
Computer Science 1820). New York, NY: Springer-Verlag, 2000.
17.6. Daly J. Fingerprinting a Computer Security Code // Computerworld. July 27, 1992.
17.7. Denning D.E. Cryptography and Data Security. Reading, Mass.: Addison-Wesley,
1983.
17.8. Denning D.E., Denning P.J. Data Security // ACM . Surv. September 1979. 11, 3.

17.

679

, , ( ), (
).
17.9. Dine W., Hellman M.E. New Directions in Cryptography // IEEE Transactions on
Information Theory. November 1976. IT-22.
17.10. Fagin R. On an Authorization Mechanism //ACM TODS. September 1978. 3, 3.
[17.13] , , , [17.13]. .
17.11. Gagliardi R., Lapis , Lindsay . A Flexible and Efficient Database Authorization
Facility//IBM Research Report RJ6826. May 11, 1989.
17.12. Gardner M. A New Kind of Cipher That Would Take Millions of Years 'to Break //
Scientific American. August 1977. 237, 2.
, , ( , ), [17.14], [17.24].
17.13. Griffiths P.P., Wade B.W. An Authorization Mechanism for a Relational Data Base
System //ACM TODS. - September 1976. - 1, 3.
(GRANT) (REVOKE) ,
System R. SQL, ( )
.
Hawkes N. Breaking into the Internet // London Times. March 18, 1996.

RSA
: "
, , ".
17.15. Jajodia S., Sandhu R. Toward a Multilevel Secure Relational Data Model // Proc. 1991
ACM SIGMOD Int. Conf. on Management of Data. - Denver, Col. - June 1991.
17.3, , . , , . , .
17.16. Lempel A. Cryptology in Transition //ACM . Surv. December 1979. 11, 4
(Special Issue on Cryptology).
.

680

V.

17.17. Rivest R.L., Shamir A., Adleman L. A Method for Obtaining Digital Signatures and
Public Key Cryptosystems // CACM. - February 1978. - 21, 3.
17.18. Smith K., Winslett M. Entity Modeling in the MLS Relational Model // Proc. 18th Int.
Conf. on Very Large Data Bases. Vancouver, Canada. August 1992.
MLS (Multilevel
Secure MLS) [17.15].
(BELIEVED BY)
,
. ,
, . . [17.23].
17.19. Thuraisingham . Current Status of R&D in Trusted Database Management Systems//
ACM SIGMOD Record. - September 1992. - 21, 3.

( 1990- ).
17.20. U.S. Department of Commerce/National Bureau of Standards. Data Encryption
Standard. Federal Information Processing Standards Publication 46. January 15,
1977.

(Data Encryption Standard DES). / (.
17.5) , . . .
17.21. U.S. Department of Defense. Trusted Computer System Evaluation Criteria
("" ). Document DoD 5200-28-STD, DoD National Computer
Security Center. December 1985.
17.22. U.S. National Computer Security Center. Trusted Database Management System
Interpretation ("" ). Document NCSC-TG-201, Version 1.
April 1991.
17.23. Winslett M., Smith K., Qian X. Formal Query Languages for Secure Relational Databases //
ACM TODS. - December 1994. - 19, 4.
[17.18].
17.24. Wolf R. How Safe Is Computer Data? A Lot of Factors Govern the Answer // San Jose
Mercury News. July 5, 1990.

18

18.1.
18.2.
18.3.
18.4.
18.5.
18.6.
18.7.
18.8.






" "

18.1.
,
. ,

.
,
.
, ,
,
"" (
"" ,
, ).
( ) ,
.
,
. ,
,
.

682 V.
,
(..
, ,
). . , , .
. .
1. ,
. ,
(
..), :
;
;

;
..
( ,
, 18.5.)
. .
2.
(, ),
,
. ,
, .

.
, , , ,
.
3. , "
", .
,
-
( , ).
4. ,
.
,
, .

, (.. ) .

.

18.

683

, . , 18.2, 18.3 . 18.4


( ).
18.5 .
18.6 , . 18.7
, (
.),
18.5 . ,
18.8 .
.
. , ,
(), , . ,
, , .
, ,
,
. . ( ,
, [18.30]. . .)
18.2.
( 7.6
7), ,
. : " 2". :
( ( SP JOIN S ) WHERE P# = # ('2') ) { SNAME }
, 100 10 000
, 50 2. , s SP
,
. ,
(.. ),
, .
1. SP S ( S#).
10 000
10 000 100 (
10 000).
, 10 000 . (, () ).

684

V.

2. 1
2. 10 000
, 50
, , ,
.
3. SNAME , 2.
(
50 ,
).

, , .
1. sp
2. 10 000
, 50 , , ,
.
2. 1 S (
s#). 100
( , 2,
2
). 50 (
).
3. SNAME , 2 (
3 ).
( 50 ) .
1 030 000 , 10 100 -. , , ,
100 . , , , !
. , , , .
,
( , ,
)
( ). ,
SP #. , 1 , 10 000 50,
7 000 .
, - S. S#
2 100 50,

18.

685

10 000 . ,
,
. , ,
.
, , . , , . .
, , . , .
18.3.
,
. 18.1.

. 18.1.

686
1.
2.
3.
4.

V.
.
.
.

.

.
1.

, . (,
) .
. (..
, )
.
: " ?". , , ,
,
. ,
, , , .
, . ,
. 18.2 ,
18.2 (" 2").

. 18.2. "
2"
, , : . ,
. 18.2, ,

18.

687

(
). , . , , . 18.2, 1:
( { SP JOIN S ) WHERE P# = # ('2') ) { SNAME }
2.
,
. ,
( )
( , ) . ,
" 2" SQL 2, ,
= = AND q q AND p.
, .

(. ).
, , , .
.
.
. Q ()
( , ql q2 , ).
Q Q
,
q Q .
, q.
, q, . , , , Q.
.
1 , , , .
.
1

SQL
.
2
, SQL (. . 8.12
8, [4.18]). (, )
.
"" SQL (
), .

688

V.
( A JOIN ) WHERE ,

,
( A WHERE , ) JOIN
7.6 7. ,
, 18.2, , . , 18.4.
3.
() , , , .
, , , .. , 1 2 .
, 3, .
.
, ; .
, , , , , .
( , ,
) . , :
; , ;
.. , 18.7 (. [18.7], [18.12]).
,
(.. , ).
-, .
4 (. ). [18.7][18.12]
(. 18.7).
, ( , ..)
3
, ! , " " (, ..), .

18.

689

, , - .
(. [18.33]).
. , [18.33]
3 4, 3. , , ; 3 4.
4.


, (.. )
. , . ,
(, ). , , , ,
.
(, ) ,
, . [18.53].
,
{ ) .
, . , , .
.
, ( ), .
, ,
( , ),

. ,
,
. [18.2], [18.3]

.
18.4.
( ) ,
2 . ,
,
.

690

V.

, , - , . ,
,
( ; . ": ").
. ( . , "
v", V
S# CITY.) , ,
,
, ,
, .

,
.
1.
(
AND
). ,
( A WHERE pi ) WHERE p2
:
A WHERE pi AND p2
,
, .
2.
, . ,
( { 11 } ) { 12 }
:
{ 12 }
1112 .
, , , 12, acll.
3.
. ,
( { acl }

) WHERE p

:
( A WHERE )

{ acl }

18.

691

,
, , . , ,
,
.

, , ,
18.2 ( , ),
, . , f
, B :
f ( A O B ) f ( A ) O f ( B )
, SQRT (
) ,
A B :
SQRT ( * ) SQRT ( ) * SQRT ( )
, ,
. , SQRT
, +
B.
, . ,
, ( ) 4, AND
. ,
18.2, (
),
. ,
. , , , , ,
.
, . -, ( , );
4

" " " -"


7.4 7.

692

V.
( A UNION ) { acl } { ac1 } UNION { acl }
( A INTERSECT ) { acl } { acl } INTERSECT { acl }

A B .
-, ,
, ,
:
( A JOIN ) { acl } ( { acl1 } ) JOIN ( { 12 } )
acll acl, , 12 acl,
.

, ,
.


. ,
, :

, ,
.
, , . , , ,
, , . , , ,
(. 18.7). .
, ,
, :
( ) ( )
, , .
, , . , , , , , ,
, . .

.
, :

18.

693

'
, . , , .
.
A UNION ( A INTERSECT )
A INTERSECT ( A UNION )

. , ,
. . ,
"*" "+",
* + *
:
* ( + )

, .
,
. , .
, "*" "+", . , 5 ,
, :
A

6 (

B O C

) (

) O (

( 5 "*",
"+".)

( ),
. , ,
> AND > 3
,
> AND > 3 AND > 3
.
, ">" .
, ,
( )

694

V.

"", " > ". . ,


( ).
. ,
DB2 ( ),
Ingres.
. , OR
AND,
> OR

( = D AND < F )

:
( > OR = D ) AND

( > OR < F )

: " ,
()". :
Cl AND C2 AND ... AND Cn
Cl, 2, ..., ( ), AND.
, , . , ,
. AND
( A AND BAND ),
, ,
( ). ,
, .
, [18.56][18.58]. , , ,
.
, , , ,
, , ,
">", , AND OR, , "+" ..

.
( SP JOIN S ) { # }
" ". SP
S.
SP
S. , SP #. ,

18.

695

!
.
SP { # }
,
() . ,
, . , .
SP
S ( ), ,
. , , , .
, , , [18.25], , ,
. , , ,
, , , , .
, , , . , , .
, , , . .
,
,
.
!
.
,
.
. ,
. , ,
( , ,
).
[18.13], [18.26][18.28] [18.25].

696

V.



, . , , , , , ,
, .
,
" "
(. 18.6). ,
, ..
18.5.
3 4 (
) ,
( , , 18.7). ( )
, , DB2 Ingres. 5, DB2.
:
;
, ;
, .
:
;
;
;
( ),
,
.
. :
, , (..
,
);
,
;
5

DB2 Ingres SQL, . . , , ,


.

18.

697

;
.
. (.. ) - , . ,
RUNSTATS, ,
. ( ), Ingres (.
), OPTIMIZEDB.
, Ingres.
. Ingres
.
.
:
;
;
.
:
;
, ;
.
18.6. "
"
, 18.4, , " ". , ,
, , , [18.56]
[18.58]. , . Ingres
[18.34], [18.35].
, , 6,
.
, .
6

, QUEL INGRES
.

698

V.

,
.

( ).

, .
, ,
,
.
( [18.34]). : "
, 25
200 ". QUEL,
, Q0.
Q0: RETRIEVE ( S.SNAME) WHERE S.CITY
AND
S.S#
=
AND
SP.QTY
>
AND
SP.P#
=
AND
P.COLOR =
AND
P.WEIGHT <

= 'London'
SP.S#
200
P.P#
'Red'
25

s, P SP, .
,
25 . ( ), .
Dl: RETRIEVE INTO P'

(P.P#) WHERE .COLOR = 'Red'


AND
P.WEIGHT < 25

, ( ),
. D1 # ( SP. # = . #), # - (. 8) . ,
,
25 . D1,
' . ( INTO , ' #.
RETRIEVE.) ,
Q0 '.
Q1 ( ).

18.

699

Ql: RETRIEVE (S.SNAME) WHERE S.CITY =


'London'
AND
S.S#
= SP.S#
AND
SP.QTY > 200
AND
SP.P# = P1.P#
Q1, , SP. D2,
Q1 Q2, .
D2: RETRIEVE INTO SP' (SP.S#, SP.P#) WHERE SP.QTY > 200
Q2: RETRIEVE (S.SNAME) WHERE S.CITY = 'London'
AND
S.S#
=
SP'.S# AND
SP'.P#
= P'.P#
S.
D3: RETRIEVE INTO S'

(S.S#, S.SNAME) WHERE S.CITY = 'London'

Q3: RETRIEVE (S'.SNAME) WHERE S'.S# = SP'.S#


AND
SP'.P# = P'.P#
, , S' '.
D4: RETRIEVE INTO SP''

(SP'.S#) WHERE SP'.P# = P'.P#

Q4: RETRIEVE (S'.SNAME) WHERE S'.S# = SP''.S#


Q0 , Dl, D2 D3 ( ),
, D4 Q4 ( ).

, . 18.3.

. 18.3. Q0
, .
Dl, D2 D3 , SP S ( , , , SP S), ,
', SP' S ',
.s

700

V.

D4,
' SP1
SP' '.
, Q4,
S SP",
.
, Dl, D2 D3
( ). D3 D4
, D1 D2. D4 Q4 ,
( ,
, " ",
. 18.7).
Q4. , , ,
SP' ' . s# : {SI, S2, S4 }.
SP' ' . s#. Q4 ,
.
RETRIEVE (S'.SNAME) WHERE
S'.S# =1 ' S I '
OR
S .S# = ' S 2 '
OR
S'- S # = ' S 4 '
[18.34]
. ; [18.34]
( Ingres ,
).
.
[18.34] . Ingres
[18.11]. , ,
, , ,
(, ). [18.35] (, ), ,
Ingres . ,
.
1. ,
.
2. ,
, .

18.

701

3. , , ,
, ( Ingres).
18.7.
, . "",
. , 18.3
.
. , . . .
,
, .
, ,
.
1. PER ("PER TABLE_DEE").
2. PER, , .
. ,
, , ,
,
, . , .
SUMMARIZE SP ADD AVG ( QTY ) AS AQ
QTY (
, ), SP. , SUM
COUNT AVG ( COUNT ).
MIN, ,
( ) (
MIN) (-, , ).
, , 2.
.
SUMMARIZE SP PER P { # } ADD SUM ( QTY ) AS TOTQTY
,
( ), , . ,
.

702

1.
2.
3.
4.
5.
6.

V.
,
,
.
.
( " ").
.
-.
.
.
1-5.

. 18.418.8
(
).
. , R S ,
, (,
). , R s .
R[ 1 ], R [ 2 ] , ...,
R[m] S [ l ] , S [ 2 ] , ..., s [ n ], . ,
R [ i ] S [ j ] ,
R [ i ] * S [ j ] . , R
, S (
, ).

( " ")
.
(.. R S, . 18.4).
.
, , .

. 18.4.
,
.
.
-,
(, ).

18. 703
, , m + (n * m)
. ? , ? ( ,
.)
, " "
(, "
")
, , R S,
.
" ".
dCR R,
, a dCS ,
S. , (..
,
), R n/dCS
S ,
R. ,
(.. )
( * n) /dCS. , ,
S,
( * m)/dCR. , dCS * dCR, .. R , s, . .
, 18.2,
- , . , R S
, , pR pS (..
m/pR n/ps , ). , ,
. 18.4, (m/pR) + (m*n) /pS .
, R S ( S
, a R ), (n/pS) +
(n*m) /pR.
, m = 100, = 10 000, pR = 1 pS = 10.
100 1001 001 000
, .
. (
).
, ,
. , S
, - . , (Bitton) . [18.6], ,
( -) ,

704

V.

, -
- (. ).
, [18.35].

, S
X (. 18.5). , X
R S. R s . R S
, S
, (m/pR) + (mn/dCS).
S ,
(m/pR) +
(mn/dCS) /pS. , ( =
100, = 10 000, pR = 1, pS = 10), , dCS = 100, 10 100 1100, .
, "" [18.7].

. 18.5.
,
X. , S R ,
. , , m* .
3 . ( , ,
,
.)

18.

705

-
- , , S. S - (. 18.6).
, , .

, R S
, . , ,
, ( ,
, " ",
" "). , ,
(. 18.7). , (m/pR) + (n/pS).

. 18.6. c -
.

, , ..
,
, [18.7].
,
-

. (,
.) ,
, - [18.8].

706

V.

. 18.7. ( " ")

,
(. 18.8). - S S.C.
( , ,
) , .
R R. .
R - -
S, ,
R . C S.C, , ,
( ) .
,
R S ,
, .

. 18.8.
-, ,
, .

18.

707

18.8.
, , .
, . , . , ( 10000:1).
.
(
,

).

.

.
,
.
, ,
( ,
, ).
. .
, .. , , .

, DB2 Ingres. , " ", , Ingres. , ,
" ", .
,
, .
: ,
, -, (
) .
.
, , , , ,
, , (
). , ,

708

V.

, , (..
). , , ,
, (. [6.6]), (. 19) SQL (. [19.6] [19.10]).
,
; , ,
.
, , , ,
.
( ). .
( 3 4
).
.

.
.
.

18.1. ,
, .
?
a1) S JOIN ( ( JOIN J ) WHERE CITY = 'London' ).
a2) ( P WHERE CITY = 'London' ) JOIN ( J JOIN S ) .
1) ( S MINUS ( ( S JOIN SPJ ) WHERE P# = P# ('P2') )
{ S#, SNAME, STATUS, CITY } ) { S#, CITY } .
2) S { S#, CITY } MINUS
( S { S#, CITY } JOIN
( SPJ WHERE P# = P# CP21) ) ) { S#, CITY }.
l) ( S { CITY } MINUS P { CITY } ) MINUS J { CITY }.
2) ( S { CITY } MINUS J { CITY } )
MINUS ( P { CITY } MINUS J { CITY } ) .
1) ( J { CITY } INTERSECT P { CITY } ) UNION S { CITY }.
2) J { CITY ) INTERSECT ( S { CITY } UNION P { CITY } ) .
1) ( ( SPJ WHERE S# = S# ('S1') ) UNION ( SPJ WHERE P# = P# ('P1') ) )
INTERSECT ( ( SPJ WHERE J# = J# ('J1') )
UNION ( SPJ. WHERE S# = S# ('S1') ) ) .

18.

709

2) ( SPJ WHERE S# = S# ('S1 1 ) ) UNION


( ( SPJ WHERE P# = P# ('P1') )
INTERSECT ( SPJ WHERE J# = J# ('J1')
) ).
el) ( S WHERE CITY = 'London' ) UNION ( S WHERE STATUS >
10 ). el) S WHERE CITY = 'London' AND STATUS > 10.
1)( S { S# } INTERSECT ( SPJ WHERE J# = J# ('J1') ) {
S# } ) UNION ( S WHERE CITY = 'London' ) { S# }.
2)S { S# } INTERSECT ( ( SPJ WHERE J# = J# ('J1') ) { S# }
UNION ( S WHERE CITY = 'London' ) { S# } ).
31) ( SPJ WHERE J# = J# ('Jl') ) { S# }
MINUS ( SPJ WHERE P# = P# ('P1') ) { S# }.
32) ( ( SPJ WHERE J# = J# ('J1') )
MINUS ( SPJ WHERE P# = P# {'P1') ) ) { S# }.
1) S JOIN ( P { CITY } MINUS J { CITY } ) .
2) ( S JOIN P { CITY } ) MINUS ( S JOIN J { CITY } ).

18.2. , ,
, .
18.3. , ,
, .
18.4. , :
) ;
) .
18.5. .
18.6. .
) ,
, .
)
, ,
.
) . "
18.7. 18.4 ,
EXTEND SUMMARIZE.
18.8. -
?
18.9. ,
AND, OR NOT.
AND, .. ,
AND AND .

710

V.

18.10. , , EXISTS
FORALL. 8 ( 8.2) , FORALL EXISTS.
18.11. , ( 9).
(' London'),
('Paris'), ('Rome'), ('Athens'), ( ' O s l o ' ) ,
(' Stockholm'), ('Madrid') ('Amsterdam').
.
.

.

.
,
.
.^
19.
2.
50 .
,
.
(
), .
:
) , 2;
) , , ;
) ,
, ;
) , Tto

;
) ,
;
) ,
, ;

18.

711

) , ,
, ,
;
)
.

(
).
18.12. .
? - ?
18.13. . ,
" 2",

(, SQL).
,
. , ,
,
.
. ,
.
. , . , , ,
.
, !
18.14. .
?
- ?
, ?
? (

)?
18.15. 18.5 , ,
DB2,
. ,
, ,
"!
18.16.
(hint). , DB2
OPTIMIZE FOR n ROWS SQL ,
(i.e.
FETCH ).

, , ,

712

V.
FETCH . , ,
? .

18.17.
( 18.7
).
, ,
(..
).
, .
18.18. .

.
. .
[18.1][ 18.6]
[18.7][18.14]
, .
[18.15][ 18.32] ,
18.4. , [18.25][18.28]
.
[ 18.33][ 18.43] , System R, DB2
Ingres,
SQL.
[ 18.44][18.62] , ,
, .. , [ 18.55][18.58]
.
. , (., , 21 21).
18.1. Kim W., Reiner D.S., Batory D.S. (eds.). Query Processing In Database Systems. New
York, N.Y.: Springer-Verlag, 1985.
, (
).
(Jarke), (Koch) (Schmidt), [18.2], . , : ,
, ( [10.8]
), ( CAD/), [18.47],
.

18.

713

18.2. Jarke M., Koch J. Query Optimization in Database Systems // ACM m. Surv.
June 1984. - 16, 2.
. , 18.3 ,
, .
: , .
.
( ). , 1984
, 1984 .
, (.. , ) , .
18.3. Graefe G. Query Evaluation Techniques for Large Databases // ACM m. Surv.
June 1993.-25, 2.
( [18.2]),
. :
"
...
... ,
,
,
". .
18.4. Palermo F.P. A Data Base Search Problem // J.T. Todd (ed.), Information Systems:
COINS IV. - New York, NY: Plenum Press, 1974.
( ). ,
(. 8), ,
.
.
.
,
, ,
.
, ,
, ,
( ).

714

V.
, ,
, .

.
, , , ,
(, S. s# = SP. s#), ,

( ,
7), , -,
, (indirect join),
, ,
.
,
, ,

.
.

18.5. Poess M., Floyd . New TPC Benchmarks for Decision Support and Web Commerce //
ACM SIGMOD. December 2000. Record 29, No. 4.
(Transaction
Processing Council). ,
, . - ( ) OLTP.
- TPC-R ; , , (-) (TPC-R). TPC-W ,
. ,
, http: / /www. tpc . org.
18.6. Bitton D., DeWitt D.J., Turbyfill C. Benchmarking Database Systems: A Systematic
Approach // Proc. 9th Int. Conf. on Very Large Data Bases. Florence, Italy.
October-November 1983.
, " " (
).
, .
(, ,
). , .

18.

715

18.7. Blasgen M.W., Eswaran K.P. Storage and Access in Relational Databases// IBM Sys. J.
1977.-16, 4.
,
, ,
, -.
System R [18.33].
18.8. Merrett .. Why Sort/Merge Gives the Best Implementation of the Natural Join //
ACM SIGMOD Record. - January 1983. - 13, 2.
, - .
, :
) ,
,
( , , 18.7,
,
, );
) (
) , , ,
.
, , . ,
(, , ),
- , . [ 18.9][ 18.11] , - .
18.9. Sacco G.M. Fragmentation: A Technique for Efficient Query Processing // ACM
TODS. - June 1986. - 11, 2.
, " " . ,
() .
,
. ,
-, , , - ()
. ,
, .
18.10. Shapiro L.D. Join Processing in Database Systems with Large Main Memories // ACM
TODS. - September 1986. - 11, 3.
. "
, ".

716

V.
(.. ), . , , , .

18.11. Negri M., Pelagatti G. Distributive Join: A New Algorithm for Joining Relations // ACM
TODS.-December 1991.- 16, 4.
, "
", "... , ...
... , ,
". PI, P2, ..., (
[18.9], , ), :
M A X ( P [ i ] ) < MIN(P [i + 1] ) i ( I , 2, ..., n-1). ,
.
18.12. Graefe , Cole R.L. Fast Algorithms for Universal Quantification in Large Databases //
ACM TODS. - June 1995. - 20, 2.
(FORALL) SQL ,
, . "
, ,
". ,
" ,
" ( ). ,
, FORALL , " SQL".
18.13. Simmen D., Shekita E., Malkemus T. Fundamental Techniques for Order Optimization
// Proc. 1996 ACM SIGMOD Int. Conf. on Management of Data. Montreal,
Canada. June 1996.
.
[11.7] DB2.
18.14. Manku G.S., Rajagopalan S., Lindsay B.G. Approximate Medians and Other Quantities
in One Pass and with Limited Memory // Proc. 1998 ACM SIGMOD Int. Conf. on
Management of Data. Seattle, Wash. June 1998.
18.15. Galindo-Legaria C.A., Joshi M.M. Orthogonal Optimization of Subqueries and
Aggregation // Proc. 2001 ACM SIGMOD Int. Conf. on Management of Data, Santa
Barbara, Calif. May 2001.

18.

719

18.16. Smith J.M., Yen-Tang Chang P. Optimizing the Performance of a Relational Algebra
Database Interface // CACM. October 1975. 18, 10.
, SQUIRAL (Smart
Query Interface for a Relational Algebra). .
,

, , 18.4.


.
,
.
.
[18.17] , , ,
.
. Hall P.A.V. Optimization of a Single Relational Expression in a Relational Data Base
System // IBM J. R&D. - May 1976. - 20, 3.
, PRTV [7.9],
, SQUIRAL [18.16], .
PRTV ,
, . ,

(. 7,
7.5). , " " (
) .
SQUIRAL, . ( ).

, .
.
.
, ,
.
.

,
.

718

V.

18.18. Jarke M, Koch J. Range Nesting: A Fast Method to Evaluate Quantified Queries // Proc.
1983 ACM SIGMOD Int. Conf. on Management of Data. San Jose, Calif. May 1983.
,
( )
. .
( ,
8.) ,
, .

( , FORALL).
, ,
.
18.19. Chaudhuri S., Shim . Including Group-By in Query Optimization // Proc. 20th Int.
Conf. on Very Large Data Bases. Santiago, Chile. September 1994."
18.20. Makinouchi A., Tezuka M., Kitakami H., Adachi S. The Optimization Strategy for Query
Evaluation in RDB/V1 // Proc. 7th Int. Conf. on Very Large Data Bases Cannes,
France. September 1981/
RDB/V1 AIM/RDB
Fujitsu. ,
. , Ingres System R.
MIN .
.
, S CITY. s CITY.
S.CITY
, , HIGH LOW. , ,
.
LOW < P.CITY AND P.CITY < HIGH
18.21. Pirahesh H., Hellerstein J.M., Hasan W. Extensible Rule Based Query Rewrite
Optimization in Starburst // Proc. 1992 ACM SIGMOD Int. Conf. on Management of
Data. San Diego, Calif. June 1992.
18.1,
(query rewrite). ,
, ( , 1992 ).

Starburst IBM [18.48], [26.19], [26.23], [26.29] [26.30]. (
extensible).

18.

719

18.22. Mumick I.S., Finkelstein S.J., Pirahesh H., Ramakrishnan R. Magic is Relevant // Proc.
1990 ACM SIGMOD Int. Conf. on Management Data. Atlantic City, N.J. May
1990.
"magic" ("" " ")
, ( , ),
Datalog ( 24). ; ,
(, ,
).
, ( , 18.6) ,
, .
, ( ).
{ EX.ENAME }
WHERE EX.JOB = 'Clerk' AND
EX.SAL > AVG ( EY WHERE EY.DEPT# = EX.DEPT#, SAL )
(" ('Clerk'),
".) (.. , ), , ,
, ,
, . , .
WITH { EX.DEPT#,
AVG ( EY WHERE EY.DEPT# =
EX.DEPT#, SAL ) AS ASAL } AS T1 :
{ EMP.ENAME } WHERE EMP.JOB = 'Clerk' AND
'..
EXISTS Tl ( EMP.DEPT# = T1. t>EPT#
AND EMP.SALARY > T1.ASAL
)
,
, , .
"" ,

, , .
/* : ,
*/
/*
*/
WITH ( { EMP.ENAME, EMP.DEPT*, EMP.SAL }
WHERE EMP.JOB = 'Clerk' ) AS Tl : /*
: , */

720

V.
/*
WITH { T1.DEPT# } AS T2 :
/* : ,
*/
/*
*/
WITH ( { T2.DEPT#,
AVG ( EMP WHERE
EMP.DEPT# = T2.DEPT#, SAL ) AS ASAL } ) AS T3 :
/* */
{ Tl.ENAME } WHERE EXISTS T3 ( T1.DEPT# = T3.DEPT# AND
T1.SAL > T3.ASAL )
"" , .
(. [18.23], [18.24], 24,
"" .)

18.23. Mumick I.S., Pirahesh H. Implementation of Magic in Starburst // Proc. 1994 ACM
SIGMOD Int. Conf. on Management of Data. Minneapolis, Minn. May 1994.
18.24. Mumick I.S., Finkelstein S.J., Pirahesh H., Ramakrishnan R. Magic Conditions//ACM
TODS. - March 1996. - 21, 1.
18.25. King J.J. QUIST: A System for Semantic Query Optimization in Relational Databases //
Proc. 7th Int. Conf. on Very Large Data Bases. Cannes, France. September 1981.
(. 18.4).
QUIST (QUery Improvement through Semantic Transformation ), .
18.26. Shenoy ST., Ozsoyoglu Z.M. A System for Semantic Query Optimization // Proc. 1987
ACM SIGMOD Int. Conf. on Management of Data. San Francisco, Calif
May/June 1987.
(King) [18.25], , , , -, .
: .

. ,
,
.
18.27. Siegel M., Sciore E., Salveter S. A Method for Automatic Rule Derivation to Support
Semantic Query Optimization // ACM TODS. December 1992. 17, 4.
, 18.4, .
, , .

18.

721

,
(.. )?

. , , ,
, ,
.
?

( )
, , ,
.
. AGE < 50 ( 50 ),
(
50 ),
50 .
, .
18.28. Chakravarthy U.S., Grant J., Minker J. Logic-Based Approach to Semantic Query
Optimization // ACM TODS. June 1990. 15, 2.
: "
...
.
,
. ( , ], , , ".
18.29. Cheng Q. et al. Implementation of Two Semantic Query Optimization Techniques in
DB2 Universal Database // Proc. 25th Int. Conf. on Very Large Data Bases, Edinburgh,
Scotland. September 1999.
18.30. Aho A.V., Sagiv Y., Ullman J.D. Efficient Optimization of a Class of Relational
Expressions // ACM TODS. - December 1979. - 4, 4.
, ,
,
( ), . SPJ- ( .
"selection", "projection", "join" , , ). SPJ-
, <bool > WHERE
, AND EXISTS. , (tableau),
SPJ-.
, , ,

722

V.
, , () . . , " (f 1) () , (b2)".

, , ( - , ,
), ( )
. (, ). , b
, a f . f.

(. 18.3), , . ( Query-By-Example (QBE),
, QBE.) , ,
.
( ) SPJ-, , ( ). (
, .)

.
,
, , , , (. 13).
, , V, S () SP () s#, .
v { # }

.

18.
( SP JOIN S )

723

{ # }

, 18.4,
, (.. ).
SP {

, ,
,
,
.
18.31. Sagiv Y., Yannakakis M. Equivalences Among Relational Expressions with the Union and
Difference Operators // JACM. October 1980. 27, 4.
[18.30] ,
, .
18.32. Levy A.Y., Mumick I.S., Sagiv Y. Query Optimization by Predicate Move-Around //
Proc. 20th Int. Conf. on Very Large Data Bases. Santiago, Chile September 1994.
18.33. Selinger P.G. et al. Access Path Selection in a Relational Database System // Proc. 1979
ACM SIGMOD Int. Conf. on Management of Data. Boston, Mass. May/June
1979.
,
System R. System R
SQL, SELECT-FROM-WHERE ( ).
. System R , ,
.
, ( , ) ,
, (.
18.3).
.
, , .., ,
. [18.37][ 18.43]
.
, , , ( ).
1. , () , ( ) ,
() .

724

V.
2. , ,
, , ()
, , -, , 1, -, .
. , (, ), ,
.
, .
, , , (A JOIN )
JOIN A JOIN
. ,
A JOIN ,
.
A JOIN . (
3, 3.2. . [18.16] [18.58].)
. 520 .
. (, System R
,
. , ,
, .)
, " " IBM System 370 Model 158. "
".

18.34. Wong E., Youssefi . Decomposition A Strategy for Query Processing // ACM
TODS. - September 1976. - 1, 3.
18.35. Youssefi K., Wong E. Query Processing in a Relational Database Management System //
Proc. 5th Int. Conf. on Very Large Data Bases. Rio De Janeiro, Brazil. September
1979.
18.36. Rowe L.A., Stonebraker M. The Commercial Ingres Epilogue // [8.10].
Commercial Ingres ,
University Ingres. Commercial Ingres University Ingres.
1. University , .. ,
, , , ,
, ..
Commercial
.

18.

725

2. University (,
) ,
18.6. Commercial
, , , , 18.7.
3. Commercial
University.
4. University (. . 1).
Commercial . ,
, ,
(
).
5. Commercial ,
"
, ,
-, ISAM,
- " (. 18.7).
18.37. Kim W. On Optimizing an SQL-Like Nested Query // ACM TODS. September
1982.-7, 3.
. [18.41].
18.38. Kiessling W. On Semantic Reefs and Efficient Processing of Correlation Queries with
Aggregates // Proc. 1 lth Int. Conf. on Very Large Data Bases. Stockholm, Sweden.
August 1985.
. [18.41].
18.39. Ganski R.A., Wong H.K.T. Optimization of Nested SQL Queries Revisited // Proc. 1987
ACM SIGMOD Int. Conf. on Management of Data. San Francisko, Calif. May
1987.
. [18.41].
18.40. von Biiltzingsloewen G. Translating and Optimizing SQL Queries Having Aggregates //
Proc. 13th Int. Conf. on Very Large Data Bases. Brighton, England. September
1987.
. [18.41].
18.41. Muralikrishna M. Improved Unnesting Algorithms for Join Aggregate SQL Queries //
Proc. 18th Int. Conf. on Very Large Data Bases. Vancouver, Canada. August 1992.
SQL , .. SELECT-FROMWHERE, (. 8).
.
SQL (" 2"),
, Q1.
SELECT S.SNAME
FROM S

726

V.
WHERE S.S# IN
( SELECT SP.S# FROM SP WHERE
SP.P# = P# ('P2') ) ;
System R [18.33] .
, .
S ,
. (
).
Q2.
SELECT S.SNAME
FROM S, SP
WHERE S.S# = SP.S#
AND SP.P# = P# ('P2') ;
, ,
System R .
, S SP ,
, . ,
,
, , , Q1, , Q2, . [ 18.37][18.43].
(Kim) [ 18.37] , .

. ,
,
( ).
(Kiessling) [18.38] , , SELECT (
) COUNT (
, COUNT ). " "
, , SQL,
. , ,
( ",
").
(Ganski) (Wong) [18.39] , .
( 19) .

18.

727

( , ,
.)
, . , ,
. ( " "), EXISTS
SQL (. 19).
[18.40]
( , ,
, SQL ).
( ) (
,
). SQL
, . , .
1. SQL ,
, SQL,
[18.37][ 18.39].
. UNION
"=ALL" ">ALL" (. ),
(. 19) ,
SQL ( ).
2.
.
, , ( )

[6.6].
, [18.41] , [18.37], ,
, [18.39]. [18.41] .
.
18.42. Baekgaard L., Mark L. Incremental Computation of Nested Relational Query
Expressions //ACM TODS. June 1995. - 20, 2.
,
SQL, .

.

728

V.

"
... []
MINUS.

MINUS". , .
18.43. Rao J., Ross K.A. Using Invariants: A New Strategy for Correlated Queries // Proc. 1998
ACM SIGMOD Int. Conf. on Management of Data. Seattle, Wash. June 1998.
,
SQL.
18.44. Warren D.H.D. Efficient Processing of Interactive Relational Database Queries
Expressed in Logic // Proc. 7th Int. Conf. on Very Large Data Bases. Cannes,
France. September 1981.
,
. , , Prolog. , , System R,
. , ,
QUEL SQL, , ( Prolog),
, :
, ;
, ;
,
.
, . , ,
- (. 18.3).
18.45. Ioannidis Y.E., Wong E. Query Optimization by Simulated Annealing // Proc. 1987
ACM SIGMOD Int. Conf. on Management of Data. San Francisco, Calif. May
1987.
, ,
. , , (
) . ,
(. 22).
, (..
) [18.47] .
. , .

18.

729


.
, , , , ,
. , ,
. (
simulated annealing, ,
, ,
) ,
.
18.46. Swami A., Gupta A. Optimization of Large Join Queries // Proc. 1988 ACM SIGMOD
Int. Conf. on Management of Data. Chicago, 111. June 1988.

, ( , 24), .
, : (perturbation walk), , ,
(simulated annealing) [18.45] ( ""
, ,
). , , ,
.
18.47. Sellis .. Multiple-Query Optimization //ACM TODS. - March 1988. - 13, 1.
,
.

, , .
,
.
. : " ?" .
75 . .?
60 . .
5 ?
45 . .
3 ?
,
,
.

730

V.
,
() , .

18.48. Lohman G.M. Grammar-Like Functional Rules for Representing Query Optimization
Alternatives // Proc. 1988 ACM SIGMOD Int. Conf. on Management of Data. Chicago, 111. - June 1988.
. , , , ,
, . . ( 26), ,
, , .

.
. ,
,
.
(
Starburst . [18.21], [26.19], [26.23], [26.29] ,
[26.30]),
, . ,
STAR (STrategy Alternative Rules ),
(LOwLEvel Plan OPerator LOLEPOP),
, , ..
LOLEPOP . , LOLEPOP
-, ..
, :
(STAR) , ; .
, ,
, ; , .
18.49. Nakano R. Translation with Optimization from Relational Calculus to Relational Algebra
Having Aggregate Functions//ACM TODS. December 1990. 15, 4.
8 ( 8.4), , ,

,
. , ..

18.

731

. ,
" ...
". , .
18.50. Whang K-Y., Krishnamurthy R. Query Optimization in a Memory-Resident Domain
Relational Calculus Database System //ACM TODS. March 1990. 15, 1.
(
, )
.
.
18.51. Freytag J.C., Goodman N. On the Translation of Relational Queries into Iterative
Programs//ACM TODS. - March 1989. - 14, 1.

, Pascal. , , ,
() .
18.52. ., Lohman G.M. Measuring the Complexity of Join Enumeration in Query
Optimization // Proc. 16th Int. Conf. on Very Large Data Bases. Brisbane, Australia.
August 1990.
,
N (N > 2) .
. , , ..
, , A JOIN JOIN JOIN D, ( ( D JOIN ) JOIN ) JOIN ,
( A JOIN D ) JOIN ( JOIN ). , , . ,
,
.

IBM Starburst ( [18.21], [18.48], [26.19], [26.23],
[26.29] [26.30]. ,
,
,
.
18.53. Vance ., Maier D. Rapid Bushy Join-Order Optimization with cartesian Products //
Proc. 1996 ACM S1GMOD Int. Conf. on Management of Data. Montreal, Canada.
June 1996.

732

V.

[18.52], ( ) , . ,
; " , ", (
. 22).
,

.
18.54. Ioannidis Y.E., Ng R.T., Shim ., Sellis .. Parametric Query Optimization // Proc.
18th Int. Conf. on Very Large Data Bases. Vancouver, Canada. August 1992.
.
EMP WHERE SALARY > <salary>
<salary> () .
, SALARY . .
<salary> 10. . ,
( ,
).
<salary> 1 . . ,
( ,
- ).
, .
(
,
) , . ,
. , . ,
. "
, ".
18.55. Kabra N., DeWitt D.J. Efficient Mid-Query Re-Optimization of Sub-Optimal Query
Execution Plans // Proc. 1998 ACM SIGMOD Int. Conf. on Management of Data. Seattle, Wash. June 1998.
18.56. Gray J. Parallel Database Systems 101 // Proc. 1995 ACM SIGMOD Int. Conf. on
Management of Data. San Jose, Calif. May 1995.

18.

733

,
. ,
, ,
(
). ,

. ,
:
;
.
.
,
.
,
, ,
.
.
.
.
,
.
.
,
.
, ,
(
).
, , ..
N
N , (scalability), ..

.
(data partitioning), .. r

.
(range partitioning). r
1, 2, ....
s r ( r
s,
). i i.

s.

734

V.
- (hash partitioning). t r h ( t ) , h -.

-,
r.
(round-robin partitioning). r , i-
,
i . r.
( ),
( )
( ). [18.3], [18.57] [18.58]
. ,
(. 18.7) .

18.57. Bitton D., Boral H., DeWitt D.J., Wilkinson . Parallel Algorithms for the Execution of
Relational Database Operations//ACM TODS. September 1983. 8, 3.
, , , .
, ,
. .
18.58. Hasan W., Motwani R. Optimization Algorithms for Exploiting the ParallelismCommunication Tradeoff in Pipelined Parallelism // Proc. 20th Int. Conf. on Very Large
Data Bases. Santiago, Chile. September 1994.
18.59. Kossmann D., Stocker K. Iterative Dynamic Programming: A New Class of Optimization
Algorithms//ACM TODS. - March 2000. - 25, 1.
18.60. Godfrey P., Gryz J., Zuzarte C. Exploiting Constraint-Like Data Characterizations in
Query Optimization // Proc. 2001 ACM SIGMOD Int. Conf. on Management of Data,
Santa Barbara, Calif. May 2001.
18.61. Deutsch A., Poppa L., Tannen V. Physical Data Independence, Constraints, and
Optimization with Universal Plans // Proc. 25th Int. Conf. on Very Large Data Bases,
Edinburgh, Scotland. September 1999.
18.62. Stillger M., Lohman G., Markl V., Kandil M. LEO DB2's LEarning Optimizer//
Proc. 27th Int. Conf. on Very Large Data Bases, Rome, Italy. September 2001.

19

19.1.
19.2.
19.3.
19.4.
19.5.
19.6.
19.7.
19.8.




( )

SQL

19.1.

. , , ,
" ", "
", " " ..

.
(, , SQL, , ) (NULL) . , , , 7,
, , "
". : )
, ; ) , ; )
.
. ,
WEIGHT ,
7. , , , -
, WEIGHT
.
, .
, WEIGHT "
" " NULL".

736

V.

. , , ,
WEIGHT NULL,
,
WEIGHT. " "
" NULL" , "
(NULL)" , .
, ,
- ( NULL), true
() false () unknown ( ).

NULL " ". ,
, > ,
( , ).
, , (NULL)
, , , ,
(NULL), = unknown, true.
, .. =B unknown. ,
, , , : true
(), false () unknown ( ).
,
, , (NULL)
, . , ,
WEIGHT, , ; , , . " , " ! ,
6. , ,
, ,
, .
. [11.10], " - ,
".
, , .

1
,
. ,
( ,
).

19.

737

. 19.2
,
. ( ,
.) 19.3 ,
. 19.4 . , 19.5, .
19.6 . 19.7
SQL, .
, 19.8 .
. ,
,
.
, " ", " ", "
", " " .. [19.5]2. , [6.2]
, :
" ", " ".
-,
.
(, [19.5]).
,
. , ,
UNK ( "unknown" "").
19.2.

.
( )
(.. UNK) .

, ,
UNK, unknown,
true false.
2

,
" " . , ' Joe'
" ", , ,
, . ( ,
'Joe' " "
, ,
" ". ,
.)

738

V.

. unknown,
, , .
AND, OR NOT
( : t true, ffalse, ).

, = 3, = 4 UNK. ( ).
> AND > :
false
> OR > :
< OR < : true
NOT ( A = ) :
, , AND, OR
NOT [19.11]. MAYBE
() [19.5]. .

MAYBE,
: "
50 . ., ( )
18 1971 ". MAYBE
3.
EMP WHERE MAYBE ( JOB = 'Programmer' AND
DOB < DATE ('1971-1-18')
AND SALARY < 50000.00 )
( , JOB, DOB SALARY
CHAR, DATE RATIONAL, .) MAYBE
.
WHERE
( JOB = 'Programmer'
OR IS_UNK ( JOB ) )
AND
( DOB < DATE ('1971-1-18')
OR IS_UNK ( DOB ) )
(
SALARY < 50000.00
OR IS_UNK ( SALARY ) )
AND NOT ( JOB = 'Programmer'
AND
DOB < DATE ('1971-1-18') AND
SALARY < 50000.00 )
3
, , ,
Tutorial D UNK . , ,
.

19.

739

IS_UNK,
true, UNK, false .
(, , IS_DNK
, .
,
,
.)
,
MAYBE , . , ,
TRUE_OR_MAYBE ( true,
true , false), [19.5].
. [ 19.11] " ".

,
, , EXISTS FORALL . 8, EXISTS FORALL
OR AND, .
, r tl, t2, ..., tm, V , , (V) , V ,
EXISTS V ( ( V )

.
false OR p ( tl ) OR ... OR p ( tm )
,
FORALL V ( ( V ) )
.
true AND p ( tl ) AND ... AND p ( tm )
, i p(ti) unk? ,
r .
(
(

1,
2,
3 )
1, 2, UNK)
( UNK, UNK, UNK )

,
, , ,
INTEGER. .

740

V.

EXISTS

v ( v.c > 1 )
EXISTS V ( V.B > 2 )
EXISTS V ( MAYBE ( V.A > 3 ) )
EXISTS V ( IS_UNK ( V.C ) )

: true
: unk
: true
: true

FORALL V ( V.A > 1 )


FORALL V ( V.B > 1 )
FORALL V ( MAYBE ( V.C > 1 ) )

: false
: unk
: false


.
WEIGHT * 454
WEIGHT . , UNK? ? , UNK. ,
UNK, UNK. , , WEIGHT UNK, UNK.
WEIGHT + 454
454 + WEIGHT
+ WEIGHT
WEIGHT - 454
WEIGHT * 454
WEIGHT / 454

454 - WEIGHT
454 * WEIGHT
454 / WEIGHT

- WEIGHT

. , ,
. ,
WEIGHT - WEIGHT, ,
UNK, WEIGHT/0
UNK
(, , WEIGHT UNK). .
, ( ), IS_UNK, ,
IF_UNK. , | | UNK,
UNK, UNK, UNK. ( , .)
IF_UNK
, UNK.
UNK, IF_UNK . ,
UNK , UNK.
, , UNK
CITY S. .
EXTEND S ADD IF_UNK ( CITY, 'City unknown' ) AS SCITY

19.

741

, SCITY 'City unknown' ,


s UNK.
, IF_UNK
IS_UNK. ,
IF_UNK ( exp1, exp2 )
expl 2 ,
.
IF IS_UNK ( expl ) THEN exp2 ELSE expl END IF
UNK
, UNK ( "
") ( unknown) 4. , , (, ), UNK
. . , X
(BOOLEAN).
: true, false . , "X "
, X .
, "X UNK" , .
UNK
, , ,
(.. ) UNK. ,
- ,
! , UNK, "", UNK, , .
, 6, , [6.1].
.

. : , , , ( UNK
).
, , UNK
.
, , ,
,
true, .. , false .
4

, SQL (. 19.7).

742

V.

.
MAYBE, , " "
.
. , , .
tl t2 , 1, 2, . . . , An i (i = 1, 2, . . . , ) Ai tl Ai t2.
UNK, UNK ( ) , . , , UNK, ?
, : UNK,
, [14.7]5. :
"... ...
. ".
, . , , .
tl t2 ,
1, 2, . . ., An i (i = 1, 2,
. . ., ), Ai tl Ai t2,
Ai tl t2 UNK.
, , . , , :
tl = t2;
tl t2 .
,
. , r1 r2
r , t, t rl r2 ( ).
, ( ). , t
5
[14.7] ,
, (. 14).
, "" 9-, 8- (.. ),
(. . 19.4), "" , , , 8-
(. 19.5).

19.

743

r1 MINUS r2 ,
- rl,
r2. ( ,
, , .
, t rl INTERSECT r2
, - rl
- r2.)

.
1. R UNK
R INSERT
, UNK
(, ,
, UNK.)
R UNK, R
( INSERT UPDATE),
UNK, .
2. R (
INSERT UPDATE) .
.

9, ,
false. , ,
( , , ). , , ,
.
, WHERE
false, true ( ).
19.3.
, ,
, . .

, , , true,
. ,
, .

744

V.

= true.
.
, UNK.
OR NOT (p) true.
.
OR NOT(p) true (.. ), .
, unk, unk OR
NOT (unk), .. unk OR unk,
unk, true. ,
,
. , "
" "
", ,
. ,
: "
, , (may be), " ( ,
, true, ..
OR NOT (p) ,
OR NOT(p) OR MAYBE (p)).
. , , ,
" " " " .
, ,
, .
: " , ", "
, ", " ".
, [19.6], ,
,
, .
"" , , ,
, , . ( ,
, , . ,
, ( , ..), " ",
" ". .)
r JOIN r r.
r r (..
). , UNK
, , ( [14.7]) , ,

19.

745

" ", "


" ( !?).
INTERSECT JOIN.
, , , , .
= AND = = .
"
".
, , ,
. . , ,
,
r JOIN r = r (. 18). ,
( ), (
"" ). ,
. , .
, .


. ( [19.9];
,
). ,
, . 19.1.

. 19.1. ,
.
DEPT.DEPT# = EMP.DEPT# AND EMP.DEPT# = DEPT# ('Dl')
DEPT .
unk AND unk,
.. . , "" , ,
= = , = , - ( 18, 18.4). .

746

V.

DEPT.DEPT# = EMP.DEPT# AND EMP.DEPT# = DEPT# ('D1')


AND DEPT.DEPT# = DEPT# ('Dl')
unk AND unk AND false
false ( ).
.
.# WHERE EXISTS DEPT ( NOT ( DEPT.DEPT# =
EMP.DEPT# AND EMP.DEPT# = DEPT# ('D1') ) )
1, " " , ,
" ". , , "" . , , , ,
, , .

.
, , .
, n- , (+1)-
> 1; .

. 1 , UNK d.
d D1, . ,
.
DEPT.DEPT# = EMP.DEPT# AND EMP.DEPT# = DEPT# ('Dl')
d Dl,
false, . d D1, false,

EMP. DEPT# = DEPT# ( ' Dl' ). ,
false, , UNK. , ,
, , , ! , , .. ,

!
. ,
( [19.1]-[19.11]).

19.

747

(. ). ,
, .

, , , : (E2,D2) (1,UNK).
: " D2 2",
" 1". (, " UNK" , . , (E1,UNK),
,
(1).) , , "" , ( !)
( ).
, ,
, , OR,
.
" #, D#"
" ".
, ( ) "" (Ei,UNK) Ei!
, "", , " UNK"
"". ( , "" , .)
.
" UNK", ( )
. ,
"" , "" ,
""
( )
. , UNK
.
19.4.
. UNK
, .. NULL.
, (NULL) . ,
, .
.

748

V.


9.10, ,
, , ,
( ) . (
) . ,
,
( ).
.
(NULL).
:
) ;
)
( ); ) ,
; )
; ) ,
"".
.
1. , ,
, "
", . (,
,
.)
2. , , -,
(NULL).
, (NULL),
,
.
? , ,

(NULL),
, .
.
3. , ,
,
, -,
(NULL).
R ,
(NULL). ,
(
). ,
(
(NULL)).

19.

749

,
(NULL) 6 , (
19.6). : "
". , ( , , ). . 19.2
SURVEY, .
,
,
. ( BIRTHYEAR .) "????" BIRTHYEAR
, .

. 19.2. SURVEY

, . 19.1. , ,
, DEPT#
. , .
:
, 7 (NULL), , 9.
( ).
.
, ,
. ,
6
7

, ([19.12]).

,
, , ,
!

750

V.

(.. NULL) ,

, .
.
1. (NULL)
. (,

, , .)
2. (NULL)
, SET NULL,
DELETE UPDATE
, , .
VAR SP BASE RELATION { ... } ...
FOREIGN KEY { S# } REFERENCES S
ON DELETE SET
NULL ON UPDATE
SET NULL ;
DELETE
(NULL)
,
.
, UPDATE s#
(NULL)
,
. .
SET NULL ,
(NULL). 3. , ,
"" (NULL)

[19.19]. .
,
. , ,
DEPT#
, () ED
# DEPT#, ,
.
, ,
ED.
19.5. (
)
[19.3], [19.4], [19.7], [19.14],
[19.15].
. ,

19.

751

, ,
(NULL)
, ,
. . , ( , NULL ).
( S JOIN SP )
UNION
( EXTEND ( ( S { S# } MINUS SP { S# } )
JOIN S ) j ADD { NULL AS P#, NULL AS QTY )
)
,
. (NULL) P# QTY.
. . 19.3. S SP,
, . ,
( !) " " ,
( S5),
"" . ,
.
,
, . ,
, . , [6.2] ,
. ,
, , .
, ,
(NULL),
.
, ,
, -,
, . (
,
, .) . 19.3
, ,
. , ,

- [19.7]. ,
.

752

V.

,
, , . 19.3. , [19.7], " ", ,
SQL.
, ..
" " (. [19.7], ).

. 19.3. ()
, ,
, . (NULL)
, , (
, ,
). , . 19.3 , . 19.4.
WITH ( S RENAME S# AS X ) AS Y :
( EXTEND Y ADD ( SP WHERE S# = X ) AS PQ ) RENAME X AS S#
, , S5,
. 19.4 , -
(NULL), ,
. 19.3. , ,
. , , ,
.

19.

753

,
(NULL),
. ,
, . 19.3? , , " " " ". ,
: " ".
[19.7].

. 19.4. S5 ( )
, ""
, ,
[14.7]. , [6.2] {
) .
,
.
,
, (NULL) (
). , 8.
, .
,
, .
.
(
), ,
.
.
, ,
;
., .. (..[1.9.2, . .)
8
[14.6]; [6.2]
.

754

V.

19.6.
, (NULL) ,
1969 [6.1] 1979 [14.7].
, 19.4,

. , . , "?" , - 9. , ,
,
, , . , .
HOURS_WORKED ,
. (
TRUMPS () , : "
", " ", " ", " " " ".)
, , ,
,
. (NULL), , SQL,
(NULL) . ,
, [19.12].
19.7. SQL
(NULL) SQL , . , , SQL WHERE ,
, WHERE false unk (.. true).
, , G, HAVING,
G,
HAVING false unk (.. true)10. ,

, SQL , , .
9
, (NULL).
([19.12]).
10
SQL ,
GROUP BY (, ).
SELECT , "" .

19.

755

. (NULL) SQL
; , , SQL
, , , .
SQL [4.23]
[4.20].

4, SQL
BOOLEAN ( 1999 ,
, ). AND, OR NOT, , . ,
, , ( TRUE, FALSE UNKNOWN), ,
BOOLEAN , . , {unknown)
NULL! .
UNKNOWN BOOLEAN
.
= UNKNOWN
true (, , TRUE);
.
, = UNKNOWN
, ! ,
" = NULL" (
).
,
, .
, ( , ). , , , V . ,
, V, , V,
(.. ), . , V ",
! , -,
( ), v
,
. , V ,
11
, SQL ; . IS [NOT] NULL
" ".

756

V.

,
V = V , ,
V IS NULL FALSE. , , , ((V = V) is NOT TRUE) is TRUE TRUE, v
, .

6.6 6, , ; ( ), NULL. , ,
(, NOT NULL).
,
, NOT NULL,
, SQL,
. , ,
SQL . , NOT NULL , PRIMARY KEY.

8 ( 8.7) ,
JOIN SQL 1992 . ,
JOIN LEFT, RIGHT FULL ( OUTER ), .
.
S LEFT JOIN SP ON S.S# =
SP.S# S LEFT JOIN SP USING (
S# ) S LEFT NATURAL JOIN SP
, s#,
.
SQL , ( SQL: 1992,
SQL:2003). .

, SQL
.
, .
. SQL , IS NULL IS NOT NULL,
. .

19.
<row value constructor IS

[ NOT ]

757

NULL

<row value constructor


"" , SQL
, ,
, ;
.
, ,
,
, ,
! , r
, r IS NOT NULL NOT (r IS NULL)
; cl is NOT
NULL AND c2 is NOT NULL, 1 IS NOT NULL OR c2 IS
NOT NULL. , r
,
, r, ,
, .
true, false unknown.
(
, ), .
IS [ NOT ] TRUE IS
[ NOT ] FALSE p IS [
NOT ] UNKNOWN
.

, IS NOT TRUE NOT p


.
. IS UNKNOWN
MAYBE (). , SQL unk
,
IS NULL.
EXISTS. EXISTS SQL
, true
false, unk, unk .
, false, ,

758

V.

, , true ( true, ).
[19.6].

UNIQUE. , UNIQUE
, ( !). ,
UNIQUE (< table exp>) true, , < table exp>, , ,
rl r2, rl = r2 true;
false. UNIQUE, EXISTS,
true, .
DISTINCT. DISTINCT, ,
, .
Left Right; Left Right
, , . , i- Left Right,
, Li Ri (i = 1, 2, . . ., ); Li Ri
, Li = Ri .

Left IS DISTINCT FROM Right
false, i "Li = Ri" true, , Li Ri, ;
true.

, .
"". NULL
(,
INSERT), ; SQL , "
NULL ... ...
, [] "
[4.23]. , , NULL
; ,
"WHERE = NULL" . ( , ,
WHERE X IS NULL).
COALESCE. COALESCE
IF_UNK SQL. , COALESCE (x,y, . . . , z)
, , , . . ., z
; ,
.
. SQL (SUM, AVG ..)
,
19.2,
( COUNT (*),
,

19.

759

). , , , COUNT ,
. (
8, , SQL
.)
" ".
, , , (SELECT
S.CITY FROM S WHERE S . S# = S# (' S1 ' ) ) , TO
,
.
,
. , , SQL
.

SQL , .
. , ,
.
, ,
SQL -
( , SQL
). , SQL
(,
, ,
, [4.20].
", 2 , INSERT UPDATE... INSERT
UPDATE , 2 ,
, kl, ... ,
, kl 2, ? ,
:
1. kl 2 ;
2. kl 2
;
3. kl 2 .
1 , 2 UNIQUE, 3
, 19.2.
, , kl 2, , ,

760

V.

1, unk, 2 false 3 true".


. , ,
, . .
.
(CASCADE, SET NULL ..), ON
DELETE ON UPDATE. ( , SET
DEFAULT, .)

; [4.20].
SQL
.
SQL. ( 4
SELECT.)
EXEC SQL SELECT STATUS, CITY INTO
:RANK, :TOWN FROM S WHERE
S# = S# ( :GIVENS# ) ;
, STATUS
.
SELECT , STATUS
( SQLSTATE
22 002). , ,
,
, , . .
EXEC SQL SELECT STATUS, CITY
INTO :RANK INDICATOR :RANKIND, :TOWN
FROM S
WHERE S# = S# ( :GIVENS# ) ;
IF RANKIND = -1 THEN /* STATUS */
... ; END IF ;
, ,
,
-1 (, , ).
. ,
, ORDER BY.
(, .)
: " B,
,
,
?". SQL .

19.

761

1.
.
2.
,
(
).
19.8.
,
( ) , . , , (,
, " NULL").
, ,
, unknown ( ), . , , , , , ,
( ) , , UNK.
UNK
AND, OR NOT ( MAYBE), EXISTS
FORALL, ,
INSERT UPDATE. IS_UNK
( UNK), IF_UNK ( UNK , UNK).
UNK. , ,
UNK .
. ,
. - .
, .. .

( ,
). . ,
( , ), , ,
. ,
.
"" , .

SQL. SQL

762

V.

, , . , ([19.6], [19.10]) SQL


. , , ,
(
18.8 18).
.
, , , , , .
, ,
, "",
, .
, ,
, SQL -
" ".
,
,
.
" " (
). [
19.12].
, , 19.3.
, " ",
. , "" ,
"" , "" ( ) .

19.1. , = 6,
= 5, = 4 D UNK.
) = OR ( > AND A > D ).
)
)
)
)
)
)
3)

> AND ( < OR IS_UNK ( A - D ) ).


< OR < OR NOT ( A = ).
< D OR = D OR > D.
MAYBE ( > AND > ) .
MAYBE ( IS_UNK ( D ) ).
MAYBE ( IS_UNK ( A + ) ).
IF_UNK ( D, A ) > AND IF_UNK ( C, D ) < B.

19.2. r .
(
6,
5,
4 )
( UNK,
5,
4 )

19.

763

( 6, UNK, 4 )
( UNK, UNK, 4 )
( UNK, UNK, UNK )
, ,
, INTEGER. , v , r.
) EXISTS V ( V.B > 5 ).
) EXISTS V ( V.B > 2 AND V.C > 5 ).
) EXISTS V ( MAYBE ( V.C > 3 ) ).
) EXISTS V ( MAYBE ( IS_UNK ( V.C ) ) ).
) FORALL V ( V.A > 1 ).
e) FORALL V ( V.B > 1 OR IS_UNK ( V.B ) ).
) FORALL V ( MAYBE ( V.A > V.B ) ).
19.3. , is_UNK . ?
19.4. [14.6] "maybe''-
. , maybe-
, ,
unk, true. , ,
. ?
19.5. true false.

: true,
false, true false (.. NOT),
. ,
16 (. ,
).

, NOT, AND OR
(, ).
19.6. ?
? w- ?
19.7. "-"
(
, "|").

764

V.

, | q NOT p AND NOT q ( "-"


" ... ..." , "
, "). ,
20 .
. , "" ""
.
,
? ? n- ?
19.8. ( [19.5].) . 19.5 .
, SP SHIP# ( ), #
UNK.
( .)

. 19.5.
.
S WHERE NOT EXISTS SP ( SP.S# = S.S# AND
SP.P# = P# ('P2') )
s SP .
( )?
) , 2.
) , ,
2.
) , ,
2.
) , , ,
2.
19.9. SQL,
.
19.10. EXISTS , UNIQUE IS DISTINCT FROM
SQL. - , ,
? IS

19.

765

NOT DISTINCT FROM? , "" :


) EX I ST S ;
) UNIQUE.

19.1. Codd E.F. and Date C.J. Much Ado About Nothing // C.J. Date. Relational Database
Writings 1991-1994. - Reading, Mass.: Addison-Wesley, 1995.
, ( , ,
!).
. : " , " ().
19.2. Darwen H. Into the Unknown // C.J. Date. Relational Database Writings 1985-1989.
Reading, Mass.: Addison-Wesley, 1990.
,
: " ( 6.4 6) TABLE_DEE true, TABLE_DUM -
false, TABLE_DEE TABLE_DUM , ?".
19.3. Darwen H. Outer Join with No Nulls and Fewer Tears // C.J. Date and Hugh Darwen.
Relational Database Writings 1989-1991. Reading, Mass.: Addison-Wesley, 1992.
, , . . [3.3].
19.4. Date C.J. The Outer Join // C.J. Date. Relational Database: Selected Writings.
Reading, Mass.: Addison-Wesley, 1986.
, SQL.
19.5. Date C.J. NOT is Not "Not"! (Notes on Three-Valued Logic and Related Matters) // C.J.
Date. Relational Database Writings 1985-1989. Reading, Mass.: Addison-Wesley, 1990.
, BOOLEAN.
X true, false .
"X true" , X
, false. , X = NOT true
, X false (.
NOT). , NOT "" ...

766

19.6.
19.7.

19.8.

19.9.
19.10.

19.11.

V.
( SQL) , , .
Date C.J. EXISTS is Not "Exist"! (Some Logical Flaws in SQL) // C.J. Date. Relational
Database Writings 1985-1989. Reading, Mass.: Addison-Wesley, 1990.
Date C.J. Watch Out for Outer Join // C.J. Date and Hugh Darwen. Relational Database
Writings 1989-1991. Reading, Mass.: Addison-Wesley, 1992.
19.5 ,
" ". .
1. -
.
2. 0-.
3. < ,
< OR A = ( ).
4. 9- .
5.
.
, SELECTFROM-WHERE SQL .
, " " .
1. WHERE .
2. AND, ,
.
3. WHERE
.
4.
.
5. SELECT ( ) .
, , .
Date C.J. Composite Foreign Keys and Nulls // C.J. Date and Hugh Darwen. Relational
Database Writings 1989-1991. Reading, Mass.: Addison-Wesley, 1992.
.
Date C.J. Three-Valued Logic and the Real World // C.J. Date and Hugh Darwen.
Relational Database Writings 1989-1991. Reading, Mass.: Addison-Wesley, 1992.
Date C.J. Oh No Not Nulls Again // C.J. Date and Hugh Darwen. Relational Database
Writings 1989-1991. Reading, Mass.: Addison-Wesley, 1992.
.
Date C.J. A Note on the Logical Operators Of SQL // Relational Database Writings
1991-1994. Reading, Mass.: Addison-Wesley, 1995.

19.

767

(3VL) true, false


unknown ( t,, f u, ). , 3 * 3 * 3 = 27 ,
t,f t,f .
39=19 683
(. , ).

n- (nVL)
2 (. , ).

n- , > 2, .
? (,

{NOT, AND}, {NOT, OR}.)
? (, {NOT,
AND, OR} .)
[19.11] , SQL ( )
19 710 .
19.12. Date C.J. Faults and Defaults (in five parts) // C.J. Date, Hugh Darwen and David
McGoveran. Relational Database Writings 19941997. Reading, Mass.: AddisonWesley, 1998.
,
. , , , .
19.13. Dey D., Sarkar S. A Probabilistic Relational Model and Algebra // ACM TODS.
September 1996. 3.
" " . " " .

768

V.

19.14. Galindo-Legaria C.A. Outerjoins as Disjunctions // Proc. 1994 ACM SIGMOD Int.
Conf. On Management of Data, Minneapolis, Minn. May 1994.

[19.4]. ,
, , .
.
19.15. Galindo-Legaria C.A., Rosenthal A. Outerjoin Simplification and Reordering for Query
Optimization//ACM TODS. - March 1997. - 22, 1.
" " , .
19.16. Goel P., Iyer . SQL Query Optimization: Reordering for a General Class of Queries //
Proc. 1996 ACM SIGMOD Int. Conf. on Management of Data, Montreal, Canada.
June 1996.
, [19.15],
: "[] [] SQL , ... ... [] [
, ] ".
19.17. Heath I.J. IBM internal memo. April 1971.
( ) .
19.18. Liu K.-C, Sunderraman R. Indefinite and Maybe Information in Relational Databases //
ACM TODS. - March 1990. - 15, 1.

(, " 7
") (,
" 8 9 "). (I-tables) (), . , , , , .
19.19. McGoveran D. Nothing from Nothing (in four parts) // C.J. Date, Hugh Darwen and
David McGoveran. Relational Database Writings 1994-1997. Reading, Mass.:
Addison-Wesley, 1998.
. I . II ,
. III , "" . , IV
, .
19.20. RescherN. Many-Valued Logic. - New-York, N.Y.: McGraw-Hill, 1969.
.

20

20.1.
20.2.
20.3.
20.4.
20.5.
20.6.
20.7.
20.8.






,


20.9.
20.10. SQL
20.11.

20.1.
. , 5. , ""
, ,
.
14 ( ) , () , , PROGRAMMER
EMPLOYEE, EMPLOYEE
PROGRAMMER. ,
( ,

770

V.

).
,
, 5.
, .
( ), , .
, .
.

(
, 5 9).
.
;
, () .
,

_ ( ).

, .
_,
:
(,
),
""
, ;
,
,
;
, , .
, .
, .
, , ,
(.., , ),
, .
( .)

20.

771

, , , ELLIPSE () CIRCLE (), . ,


CIRCLE ELLIPSE ( ELLIPSE
CIRCLE). ,
.
(..
),
.
, ,
, (
), . , THE_CTR
(" ") ,
, THE_R (" ")
.
, , ,
(-,
), . ,
> b ( b, ,
),
. , b
r,
; = b
, ,
.
. . ,
, .
: CIRCLE ELLIPSE,
,
ELLIPSE. , , ,
, , ! (
.)

? -, , .
,
,
,
,
, , .

772

V.

(
14).
, (
)
,
. , , ,
, (, , CIRCLE
);
.
, ,
,
, . [20.13].
... [ ,
] ... ,
... [-]
.
, (Hugh Darwen) 1 [3.3].
, , , ,
. !

, ,
.
.
.
5, v , v , , :
" ", " " " " ( ..).
, ,
, . ,
ELLIPSE CIRCLE.
1
, ,
.
, "
".

20.

773

.
. , .
VAR E ELLIPSE ;
ELLIPSE. , ,
,
. ,
, , ,
,
ELLIPSE
CIRCLE.
.
""
. , ,

, ,
. ,
. ,
,
(
), ,
.
, , , [3.3].
, .
, 2
, , . ,
.
( ),

, , ,
, , , . ,
, , [3.3].

2
, , ,
. ,
, , , (
5), , , , , .

774

V.
.
, (.. )
, , ,
, ,
, , .
. , ( , , , ),
,
, ! ,
, (behavioral
inheritance), (structural inheritance), , , ,
, .
. ,

.
" ".
,
, (, ).
, ,
, ,
- . , SQL
,
,
, (. 26). , ,
,
( , [14.13]), .

,
, , .
(
..), .
20.2.
,
.
(PLANE_FIGURE, ELLIPSE, CIRCLE, POLYGON ..),
(. 20.1).

20.

775

. 20.1.
Tutorial D (
).

TYPE PLANE_FIGURE ... ;


TYPE ELLIPSE
IS PLANE_FIGURE
POSSREP { A LENGTH, LENGTH, CTR
POINT
CONSTRAINT A > } ;
TYPE CIRCLE
IS ELLIPSE
CONSTRAINT THE_A ( ELLIPSE ) = THE_B (
ELLIPSE ) POSSREP { R = THE_A ( ELLIPSE ) ,
CTR = THE_CTR ( ELLIPSE ) } ;
. ,
, , , b ;
, , b ( , " ", " ").
, b ( ). , r ( ).
.
PLANE_FIGURE ( )
; ,
PLANE_FIGURE . (
,
.
; [3.3].)
ELLIPSE, ,
; ,
{a,b,ctr} ,
> b.

776

V.

. , b .
. ,
CIRCLE , ,
, = b. ,
{r, ctr}
,
. ,

.
, , , CIRCLE ELLIPSE ( ),
, .
.
OPERATOR AREA ( E ELLIPSE ) RETURNS AREA ;
/* " " -
, */ /* AREA ,
*/
END OPERATOR ;
OPERATOR THE_A ( ELLIPSE ) RETURNS LENGTH ;
/* " " */
... ; END OPERATOR ;
OPERATOR THE_B ( ELLIPSE ) RETURNS LENGTH ;
/* " " */
... ; END OPERATOR ;
OPERATOR THE_CTR ( E ELLIPSE ) RETURNS POINT ;
/* " " */
... ; END OPERATOR ;
OPERATOR THE_R ( CIRCLE ) RETURNS LENGTH ;
/* " " */
... ; END OPERATOR ;
, THE_R, ELLIPSE, , , , CIRCLE; ,
, THE_R
CIRCLE.

, ,
. .
.1. , , POLYGON
() SQUARE ().
2. , , ELLIPSE ELLIPSE.

20.

777

3. B, B ,
(proper supertype) , , POLYGON SQUARE. B,
B; ,
, B.
, , ,
, .
4. , , SQUARE
POLYGON.
5. , , ELLIPSE
ELLIPSE .
6. , ,
; , , ,
SQUARE POLYGON. ,
.
, .
7. ,
,
, , , RECTANGLE
() SQUARE, a SQUARE
RECTANGLE. ,
Tutorial D, , IS
() , "
" .
8. (root type) , ,
, PLANE_FIGURE .
. , . , "" ,
, ,
.
9. (leaf type) , ,
CIRCLE .
. ,
( , [3.3]).
10. .
.
,
. , [3.3] ,
.
11. , , -,
, -, (..

778

V.
1, 2, , . . . , , 1
2, 2 ,..., 1), .
. , (,
).


,
: 1 2 ( , , ,
), , ;
, 1 2. ,
.
.
12. .
13. .
14. .
, " ",
; ,
ELLIPSE ( ).
,
v , ,
, v,
(, T).
, , , , . , , v , 1 2,
. , , 1 ,
2 ( ,
. 20.3). v , ..
.
.
, , ,
. [3.3].

, ,
, , ,
,
.

20.

779

, , 3, , .
,
, ( , ,
). .
20.3.
, ,

, 20.1.
,
. , .

, '
, , , T'. , AREA ()
,
, AREA (),
. ,
,
( ), (
). , AREA
ELLIPSE (. 20.2), AREA () CIRCLE.
, ( , ,
20.2) , .
ELLIPSE . . .
POSSREP { ..., ..., CTR ... } ;
TYPE CIRCLE . . .
POSSREP { R . . ., CTR . . . } ;
3
, - ,
. ,
,
; ,
; , .. ,
, ,
, .. .

780

V.

AREA,
, ELLIPSE,
CIRCLE. ,
, . , .
OPERATOR AREA ( E ELLIPSE ) RETURNS AREA ;
RETURN ( 3.14159 * THE_A ( E ) * THE_B ( E
) ) ; END OPERATOR ;
( b.) , , , _ _
r. , CIRCLE,
AREA, THE_R _
_.
. , ,
,
. , , .
, , , .
, , , , ELLIPSE, a
, ELLIPSE CIRCLE
.
4. !
, AREA
CIRCLE, (
AREA).
.
.
, , ,
AREA, , AREA, , , , . , , AREA
, ,
. , , , , ,
!
4
,
,
, (, _ ..). ( ,
, , ,
.)

20.

781

, ,
( 5). , SQL ( "=", " + ", " | | "
) .
; , PL/I
"" ( GENERIC).
,
(overloading polymorphism). , , AREA,
(inclusion polymorphism) ,
()
[20.4].
, .
. ,
.

( ,

, ). ,
"+",
"+" , " + "
..
,
, (
,
, , ).

. ,
, , , ..
( )
.
FOR EACH x
DIAGRAM CASE ;
WHEN IS_SQUARE ( X ) THEN CALL DISPLAY_SQUARE ...
; WHEN IS_CIRCLE ( X ) THEN CALL DISPLAY_CIRCLE
... ;
END CASE ;
( , IS_SQUARE, IS_CIRCLE ..,
, ; . 20.6.) ,
, .
FOR EACH X DIAGRAM CALL DISPLAY ( X ) ;

782
V.
. DISPLAY .
DISPLAY, ,
.
DISPLAY , DISPLAY, .
5 (run-time binding). ,
, CASE CASE,
,
,
CASE .
, , . , ,
POLYGON
TRIANGLE . , CASE , ,
.
WHEN IS_TRIANGLE ( X ) THEN CALL DISPLAY_TRIANGLE ... ;

.
, ,
, "
"; , , ( ) . ( ) ,
, , ( ), .

,
,
. , , AREA (), ,
, AREA (),
. , ,
, .
, ,
, T',
' .
.
5
, ,
. ,
, .

20.

783

, , : r ELLIPSE, r CIRCLE,
ELLIPSE. , ,
ELLIPSE, v
_ (v) CIRCLE,
ELLIPSE.
, , ,
. , , ; ,
.
20.4.
, , , ELLIPSE CIRCLE, .
VAR E ELLIPSE ;
VAR CIRCLE ;
,
, (, ), .
:= CIRCLE ( LENGTH ( 3.0 ), POINT ( 0.0, 0.0 ) ) ;

CIRCLE. 5,
,
. , "" , .
. , POINT , ( 5)
CARTESIAN. CIRCLE
.
.
:= ;
(.. )
, ,
, ( ,
), . ,
, ELLIPSE,
CIRCLE,
( ).
, ,

784

V.

,
CIRCLE, ELLIPSE. ,
.

.
6 ( ,
" "). , ,
- ,

. ,
,
. (. " TREAT DOWN",
, ,
.)
,
,
. ,
. .
, ,
AREA, .
VAR A AREA ;
.
:= AREA ( )

, .
-,
AREA(E) . ,
ELLIPSE, AREA
ELLIPSE, 20.2.
-, ,
(, )
CIRCLE, AREA,
; ,
, .
, , AREA, , ELLIPSE, ; , onepaop AREA.
6
, , ,
, ,
.

20.

785

, v V .
, v
<DT, MST, v>. , .
DT. (Declared Type DT) V.
MST. (Most Specific Type MST)
V ( ,
V).
v. MST,
V.
DT, MST v V
, , DT (V), MST (v) v (V).
: -, MST (V) (
) DT (V); -, MST (V) v (V) ; -, MST (V) v (V), .
, , , . , , ,
, . , , a v(X) . .
DT (X),
O, X. DT(X)
.
MST(X),
, v(X). MST(X)
( ) .
. .
V := X ;
V , . DT (X) DT(V) ,
( ).
, ,
MST (V) MST (X), v (V) v(X).
, , V , " " V.

786

V.

, ( ELLIPSE)
CIRCLE, " "
CIRCLE, ELLIPSE PLANE_FIGURE. " X" , ,
MST(x).

.
OPERATOR COPY ( E ELLIPSE )
RETURNS ELLIPSE ; RETURN ( E ) ;
END OPERATOR ;
COPY
ELLIPSE,
CIRCLE, , , , COPY
. ,
,
( ) .
, , -, ( ) , , , (-, )
.
TREAT DOWN
, .
VAR E ELLIPSE ;
VAR CIRCLE ;
:= CIRCLE ( LENGTH ( 3.0 ), POINT ( 0.0, 0.0 ) ) ;
:= ;
MST(E) CIRCLE.
,
L. .
VAR L LENGTH ;
L := THE_R ( E ) ; /*
! ! ! */
, ,
- . , - , THE_R ("
"), , CIRCLE, ELLIPSE, CIRCLE. ,
, - ( )

20.

787

, ,
. , ,
, , , .

TREAT DOWN (" ").
, .
L := THE_R ( TREAT_DOWN_AS_CIRCLE ( E ) ) ;:
TREAT_DOWN_AS_CIRCLE(E) CIRCLE,
. .
CIRCLE,
. ,
TREAT DOWN , , z,
, -, D T ( Z ) , CIRCLE,
". . ._AS_CIRCLE" ("... "); -,
MST(Z), MST(E),
CIRCLE; -,
v ( Z ) , v ( E ) ; , -,
"THE_R(Z)", (
L).
ELLIPSE,
CIRCLE, TREAT DOWN
- , .
TREAT DOWN , - TREAT DOWN.
. , CIRCLE, , ,
, O_CIRCLE (-; "-" ), , .
TYPE O_CIRCLE
IS CIRCLE
CONSTRAINT THE_CTR ( CIRCLE ) = POINT ( 0.0,
0.0 ) POSSREP { R = THE_R ( CIRCLE ) } ;

O_CIRCLE, CIRCLE. , TREAT DOWN
.
TREAT_DOWN_AS_CIRCLE ( )
, , Z, , -,
DT ( Z ) CIRCLE , ". . ._ AS _ CIRCLE ";

788

V.

-, MST(Z) O_CIRCLE, O_CIRCLE


; -, v(Z) v(E). (
), TREAT DOWN " ",
, .

TREAT_DOWN_AS_T(X) ,
. -, MST(X) ( ); , ,
Z DT(Z) , , MST ( Z ) ,
MST(X), v ( Z ) , v(X).
. [3.3] TREAT DOWN, ,
.
20.5.
ELLIPSE.
ELLIPSE ( LENGTH ( 5.0 ), LENGTH ( 5.0 ), POINT ( . . . ) )
.
,
,
CIRCLE, ELLIPSE?
, , , (
[20.6]). , CIRCLE.
: T' ,
,
T', ( )
T'. ( )
( ) ,
. , [3.3] , " ", "
" ,
.
. . 26.
,
ELLIPSE b, = b ( , ); ,
ELLIPSE , . ,
ELLIPSE

20.

789

, . , ,
" ".
, , , , = b
CIRCLE, (specialization
by constraint) [3.3], ,
(., , [20.10], [20.14]).
_
5, _ , ( ""
, ). , ,
ELLIPSE, () , , , .

b ( ),
.
_ ( ) := LENGTH ( 4 . 0 ) ;
, , _ ; (
5). , ,
_, ,
.
:= ELLIPSE ( _ ( ), LENGTH ( 4.0 ), THE_CTR ( E ) ) ;
.
_ ( ) := LENGTH ( 5 . 0 )
.
:= ELLIPSE ( _ ( ), LENGTH ( 5.0 ), THE_CTR ( E ) ) ;
,
( = b),
, MST(E) CIRCLE,
ELLIPSE.
.
_ ( ) := LENGTH ( 4 . 0 ) ;
, , b, , MST () ELLIPSE, .. , (generalization
by constraint).
. , ( 20.4) CIRCLE O_CIRCLE ( "-"
) .

790

V.
TYPE O_CIRCLE IS CIRCLE
CONSTRAINT THE_CTR ( CIRCLE ) = POINT ( 0.0, 0.0 )
POSSREP { R = THE_R ( CIRCLE ) } ;

O_CIRCLE,
CIRCLE. , , 7.
_ ( ) := LENGTH ( 7 . 0 ) ;
_ ( ) := LENGTH ( 7 . 0 ) ;
" " . , - " "? , , -. ,
, O_CIRCLE
( , CIRCLE).

, ELLIPSE.
, , "
" (, ELLIPSE,
, CIRCLE). ,
, ,
" " (, CIRCLE,
, ELLIPSE).
? , , ELLIPSE 8, CIRCLE NONCIRCLE, .
, .
CIRCLE ( = b),
, >b,
, MST () NONCIRCLE.
NONCIRCLE ( > b),
, = b,
, MST(E) CIRCLE.
, .
7

,
.
8

, , ELLIPSE . . 20.7.

20.

791

. ,
, , , < , ( , ELLIPSE).
20.6.
, , , ELLIPSE CIRCLE,
.

:=

, , ,
TRUE,
.
=
. , Y . = Y ,
DT (X) DT (Y) ( , , ).
(
). ,
TRUE, v(x) v(Y), FALSE . ,
, X Y " ", , v(X) v(Y), MST(X)
MST (Y).

7, 9
. , , ,
( , ) .
RX RY, . 20.2. ,
RX ELLIPSE,
RY CIRCLE. ,
Ei ,
, Ci . .
RX RY, , RJ (. 20.3). ,
RJ
CIRCLE ( RX, ELLIPSE, " " RY). , RJ
9

, ,
.

791

V.
CIRCLE, ELLIPSE.
.

. 20.2. RX RY

. 20.3. RJ RX RY
, RX RY, , RX JOIN RY RX INTERSECT RY.
,
JOIN, , ,
INTERSECT.
, RX INTERSECT RY RX MINUS (RX MINUS RY). ,
, ( RX
MINUS RY), RZ. :
) RZ
ELLIPSE
RZ ELLIPSE;
) , RX MINUS RZ,
RX, RZ ELLIPSE,
,
, , ELLIPSE.
,
RX INTERSECT RY, RX JOIN RY,
ELLIPSE, CIRCLE, ( ),

CIRCLE!
, MINUS. RX MINUS RY.
,
ELLIPSE, CIRCLE,
ELLIPSE.
RY MINUS RX? ,
CIRCLE,
,
CIRCLE, ELLIPSE. , RX INTERSECT RY

20.

793

RX MINUS (RX MINUS RY), , RY


MINUS (RY MINUS RX), , RY MINUS RX CIRCLE . , RY MINUS RX
ELLIPSE, CIRCLE, ,
CIRCLE.
, RX UNION RY. , ELLIPSE,
ELLIPSE. ,
UNION ELLIPSE ( , JOIN, INTERSECT MINUS,
).
, .
, r r - ,
r r , , DT () DT (Ay).
r r ( , ,
, ). DT () DT (Ay) , ( ).
, .
,
, : -,
,
, , -,
.

20.3 ,
IS_SQUARE, IS_CIRCLE .. ,
.
. ,
.
IS_T ( X )
TRUE, X ,
FALSE. , CIRCLE,
TRUE.
IS_CIRCLE (
) IS_ELLIPSE (
)

794

V.

ELLIPSE, CIRCLE,
TRUE.
IS_CIRCLE ( E )
. . , R
ELLIPSE, , R,
, .
.
R WHERE THE_R ( A ) > LENGTH ( 2 . 0 )
-
, THE_R
CIRCLE, ELLIPSE, CIRCLE.
(, ,
,
, , .) ,
, , ,
. , ,
.
R : IS_CIRCLE ( ) WHERE THE_R ( A ) > LENGTH ( 2 . 0 )
( )
, . ,
:
) , R, ,
CIRCLE, ELLIPSE;
) R,
CIRCLE, .
, ,
.
R :

IS_T ( )

R ,
(, r), . , :
) , r, ,
;
) r,
, ,
.

20.

795

. [3.3] ,
, , IS_T, ,
, , ,
.
20.7. ,
20.3,
, . ,
T'
( ), ,
T'.
.
OPERATOR MOVE ( E ELLIPSE, R RECTANGLE ) RETURNS ELLIPSE
VERSION ER_MOVE ;
RETURN ( ELLIPSE ( THE_A ( E ) , THE_B ( E ) ,
R_CTR ( R ) ) )
; END OPERATOR ;
MOVE, , "" ,
R , ,
, , ,
, , , , R. VERSION
, ER_MOVE
MOVE ( ). , R_CTR,
.
MOVE, , 10, .
OPERATOR MOVE ( CIRCLE, R RECTANGLE ) RETURNS CIRCLE
VERSION CR_MOVE ;
RETURN ( CIRCLE ( THE_R ( ), R_CTR ( R ) ) )
; END OPERATOR ;
MOVE , , ,
ELLIPSE SQUARE (, ES_MOVE), ,
, ,
CIRCLE SQUARE (, CS_MOVE).

10

(,
).

796

V.

(signature) . (, ,
,
. , ,
, .) ,
:
) ;
) ;
) , (
,
, ).
, (
!), (specification signature), (version signature) (invocation signature). .

, ,
O, .
, ,
. ,
MOVE MOVE (ELLIPSE,
RECTANGLE).
. [3.3] ,
.
, (
,
); ,
.
,
, .
. ,
,
PLANE _ FIGURE ;
AREA PLANE_FIGURE, ELLIPSE, POLYGON ..

,
,

20.

797

. ,
, . ,
CR_MOVE MOVE
MOVE(CIRCLE, RECTANGLE).
,

.
(, " "; ,
).
, , R , , CIRCLE SQUARE.
MOVE (, R) MOVE MOVE (CIRCLE , SQUARE ).
, ,
( , ) , . , , , , ,
, " " .
(.. , )
, 20.3.
, , , -, ; -, ; -, ,
, ( ). ,
, .
, ,

MOVE , . , ,
.
OPERATOR MOVE ( E ELLIPSE, R RECTANGLE ) UPDATES
E VERSION ER_MOVE ;
THE_CTR ( E ) := R_CTR ( R
) ; END OPERATOR ;
( , , ,
, , .
,
, 5.)

798

V.

, MOVE
( ,
" " , ).
, ,

ELLIPSE CIRCLE; , ".
, . ,
, , ; ,
, O_CIRCLE CIRCLE? (.
MOVE
ELLIPSE CIRCLE,
O_CIRCLE, .
O_CIRCLE .)

, , ,
, .
, AREA , CIRCLE
, , . ( ; , AREA AREA, , ,
LENGTH. !)
, , ( ), . , , TOLL_HIGHWAY (
) HIGHWAY (), a TRAVEL_TIME ( )
, , . (d/s) + (n*t), d , s ,
t , . ,
d/s. TRAVEL_TIME .
(.. , , , ) . , AREA ,
11

10, ,
; .

20.

799

, ,
. , , .
1. ELLIPSE AREA.
, AREA
.
2. CIRCLE ELLIPSE, ()
AREA .
3. AREA
, , al.
AREA, ELLIPSE ( ,
).
4. AREA
.
5. AREA
, , 2 (
AREA, CIRCLE).
, , , 2 = al.
; ,
( ) ,
AREA, , ()
.
TRAVEL_TIME. , (
, , ,
). .
TOLL_HIGHWAY HIGHWAY,
,
.
(.. HIGHWAY)

. HIGHWAY ,
" "; "
" ( ).
TRAVEL_TIME HIGHWAY "
", " d/s
".
, TRAVEL_TIME TOLL_HIGHWAY
" (d/s) + (n*t)
". TRAVEL_TIME
! - ,
;

800

V.
, .
( ,
, , , , .)

. ,
. , ; ,
( ), , , (.. ). , (
, ), , , ,
. , , -, ( ), , -,
, ,
.
20.8.

, ,
? ( !) , , , ,
,
[20.6]. , ,
, ELLIPSE CIRCLE. , .
:= ELLIPSE ( LENGTH ( 5.0 ), LENGTH ( 3.0 ),
POINT ( 0.0, 0.0 ) )
; := CIRCLE ( LENGTH ( 5.0 ), POINT ( 0.0, 0.0
) ) ;
, , , _ () _ () ,
.
, , , " ", , .
_ ( )

:= LENGTH ( 6 . 0

( ), !
_

( )

:= LENGTH

6.0

? ,
, "",

20.

801

, , = b; a
: , b, , - ( ).
, " ", , CIRCLE.
" " , ,
. ,
b (.. ) . , _ _ CIRCLE
- .
. ,
. , _ . , ,
_(), ,
.
:= CIRCLE

...

CIRCLE _ LENGTH ( 6 . 0 ) . CIRCLE _!


THE_R THE_CTR. , , .

, , , _ _ . , () _
( , ) ,
_, .. -
= b . .
-, _ _
( !)
.
-, ,
,
,
, .
, ,
, .

802

V.

-, , .
, , ELLIPSE
, NONCIRCLE; , , , , > b, _ ,
, b.
? , ?

, ,
_ _ ,
, .
.
) , CIRCLE ELLIPSE.
) , CIRCLE ELLIPSE, , ,
,
( , ).
) ,
_ _ .
? ?
, .
, CIRCLE
ELLIPSE, , ? ,
?
? , ?
. , _ ,
( ), _
ELLIPSE
CIRCLE! , . , , , , ,
(, ?).
, ,
, (. [20.2]).
, , , . , 20.10, SQL
" " . ( SQL

20.

803

,
, .
20.10.)

, , .
" _
_" , " ".
" "
.
,
.
, , !
?
( ), ,

. "
" , . , , ,
, (
CIRCLE ELLIPSE
ELLIPSE). , , . ,
.
,
.
, ,
.
!
, . (,
" " , ,
.)
, , , , ELLIPSE, ,
ELLIPSE, , , . , " , ", ,
.
,
, ( ,
,
).

804

V.

, , .
(, ), , ,
, , T', T'
( ).
, (
).
? ,
, . ,
, , ELLIPSE,
CIRCLE?
, , , .
, THE_CTR
, ( ) _ . ,
; , ,
.
.
ELLIPSE MOVE
( , )
_, _ THE_CTR.
CIRCLE MOVE
( , )
THE _ CTR THE _ R , _
_.
. MOVE .
, ,
, , . , MOVE, , ,
ELLIPSE, ,
CIRCLE ( ,
O_CIRCLE!). ( )
, ,
, , .
20.9.

, , , . , : ", CIRCLE ,
COLORED_CIRCLE" ( ,

20.

805

" " ). . , ,
, , , . , , ,
,
. , " " ,
, , , . COLORED_CIRCLE CIRCLE, 12. ,
CIRCLE, COLOR, (
) CIRCLE.

. , . ( ).
TYPE ELLIPSE ...
POSSREP { ..., ..., CTR ... } ;
TYPE CIRCLE ...
POSSREP { R ..., CTR ... } ;
, , , . (, )
, . ,
, , " " ( ),
, , b, . , ; , .
, , ,
"", , , 13. (
12
, COLORED_CIRCLE CIRCLE ,
COLOR ( ,
CIRCLE).
13
; ,
,
, , . ,
, CIRCLE ELLIPSE, [3.3]
, _ _
CIRCLE , , , ,
. , CIRCLE ELLIPSE,
, .

806

V.

) , CIRCLE COLORED_CIRCLE, , !
,
, , , .

( ) , (.. ).
,
.
,
. ,
.
TYPE ELLIPSE
IS PLANE_FIGURE
POSSREP { A LENGTH, LENGTH, CTR
POINT CONSTRAINT A > } ;
TYPE CIRCLE
IS ELLIPSE
CONSTRAINT THE_A ( ELLIPSE ) = THE_B (
ELLIPSE ) POSSREP { R = THE_A ( ELLIPSE ) ,
CTR = THE_CTR ( ELLIPSE ) } ;
, CONSTRAINT CIRCLE , = b
CIRCLE . ,
,
CONSTRAINT COLORED_CIRCLE,
COLORED_CIRCLE ; , , ,
.
, , -,
, COLORED_CIRCLE CIRCLE , , COLORED_CIRCLE
, CIRCLE,
COLOR, .
TYPE COLORED_CIRCLE POSSREP { CIR CIRCLE, COL COLOR } ... ;
.
, , ,
! ,
: ' ,
,
,

20.

807

T1 (
T' ). ,
T T1 -, T' (
, T' ).
.
, T', , (
), T' .
, T' ; ..
,
( )
, . ,
, , P '.
, ' ,
TRUE
, .

( T').
', ,
, , T,
T'. ,
T' ,
P'.
, .
, ,
, COLORED_CIRCLE CIRCLE.
20.10. SQL
SQL () () ; ,
DISTINCT14.
( -.
).

14
, SQL ( , [3.3], ).
.

808

V.

CREATE
[
[
[

TYPE <type name>


UNDER <type name> ]
AS <representation> ]
[ NOT ] INSTANTIABLE ]
NOT FINAL [ <method specification commalist> ] ;

SQL
PLANE_FIGURE, ELLIPSE CIRCLE.
CREATE TYPE
PLANE_FIGURE NOT
INSTANTIABLE NOT
FINAL ;
CREATE TYPE ELLIPSE UNDER
PLANE_FIGURE AS ( A LENGTH,
LENGTH, CTR POINT ) INSTANTIABLE
NOT FINAL ;
CREATE TYPE CIRCLE UNDER
ELLIPSE AS ( R LENGTH )
INSTANTIABLE
NOT FINAL ;

( 5).
1. NOT INSTANTIABLE ,
, ( )
,
15. , ,
.
INSTANTIABLE ,
; ,
,
. PLANE_FIGURE
NOT INSTANTIABLE, ELLIPSE CIRCLE
INSTANTIABLE (
INSTANTIABLE).
2. 5,
NOT FINAL ( SQL:2003, -,
FINAL). NOT
FINAL ,
, FINAL, ,
.
3. UNDER
(, SQL, direct supertype),
. , , CIRCLE ELLIPSE ,

15

[4.23] " " (?!).

20.

809

, , . .
) "" (
) ,
( ). ,
SQL , ,

(. . 5).
) (
) ,
; . ,
SQL
,
, . ,
, , ,
.. ( . ,
, :
v ELLIPSE,
, ,
CIRCLE, ,
, , .
, SQL : v
ELLIPSE,
,
CIRCLE, ,
; .)
) : ,
. 5,
, ,
; ,
. ,
CREATE FUNCTION
CREATE PROCEDURE,
CREATE TYPE,
CREATE TYPE (
).
(.. )
,
,
( ;
. 25).
4. SQL
(maximal supertype), PLANE_FIGURE
. (, , SQL

810

V.

, , CIRCLE .)
5. <representation> , ,
<attribute
definition commalist>, ,
<attribute> <attribute name>,
<type name>. ,
<representation>
, (
,
. 3). , , SQL
<representation>
.
. , 5, , <representation> .
6. <attribute> - (observer
method) - (mutator method),

,
_, Tutorial D (
5). ,

,
,
. 5,
, , , ,
. , , "",
, " ", a CTR " " (
, , , , Y,
).
ELLIPSE ()
,
, b , .
ELLIPSE () . ( LENGTH () . L ( 4.0 ) ) .
( LENGTH () . L ( 3.0 ) ) . CTR (
POINT () . X ( 0.0 ) . Y ( 0.0 ) )
( , LENGTH ,
L FLOAT.)
7. ,
; , ,
,

20.

811

. (
), SQL ! . 3. 8.
.
, , ,
, SQL
. '
26.

SQL. , , SQL ,
( , , ), , , . , SQL (
, , ,
SQL
). SQL .
SQL TREAT
DOWN , , .
SQL TREAT_DOWN_AS_CIRCLE (E) TREAT(E AS
CIRCLE).
SQL I S_CIRCLE (E) () IS OF (CIRCLE).
SQL
R : IS_CIRCLE ( )
.
SELECT TREAT ( E AS CIRCLE ) AS E, F, G, ..., H
FROM R
WHERE TYPE ( E ) IS OF ( CIRCLE )
F, G, . . ., R, .
SQL , , , . ,
, , .
DECLARE E ELLIPSE ;
SET =
; SET =
EX ;
, , , CIRCLE ELLIPSE. ( ELLIPSE) CIRCLE,

812

V.

ELLIPSE. , (
) .
, 5,
"=",
, .
, SQL ,
,
TRUE! , - , SQL , , .
, , , .

, , , .
, SQL (
) ,
.
, .
CREATE TYPE ELLIPSE UNDER PLANE_FIGURE
AS ( A LENGTH, LENGTH, CTR POINT ) ... ;
CREATE TYPE CIRCLE UNDER
ELLIPSE AS ( R LENGTH ) ...
;
CIRCLE , , CTR (
ELLIPSE) R ( CIRCLE).
, ,
, !
, , CIRCLE
- <representation>;
,
ELLIPSE. , CIRCLE
R ("radius" ),
, .
R "",
" ", .. "", , , , R.
, , , " " SQL. ,
, SQL . , .

20.

813

CREATE TYPE CIRCLE


AS ( R LENGTH, CTR POINT
) INSTANTIABLE NOT
FINAL ;
CREATE TYPE COLORED_CIRCLE UNDER
CIRCLE AS ( COL COLOR )
INSTANTIABLE
NOT FINAL ;
, , 20.9, , " "
, , . , , ,
. , , , , .
, COLORED_CIRCLE
CIRCLE "UNDER",
, (,
), (
). , , " " , ,
. , ,
SQL
, ,
, . , , , "" ( ) (, " "
" "
). ,
SQL , , - .
20.11.
. ( , ),
, , (,
, ,
, , ).
, , .
.
,
.

814

V.
, .
, ( , ).

( ),
, (
)16, , .
,
, , 1 2 ,
. , ( ).
() () ,
. , , , , . ,
.
.
,
(
),
,
. ( ,
, , .)
V ( , ) <DT, MST, v>, DT ,
MST v . TREAT DOWN, ,
- ,
. (
- , TREAT DOWN.)
, ,
16

, , , ,
, ( ) , , [3.3].

20.

815

( , ,
), . _;
, _ ,
.
,

(, , ).
(IS_T ..). , ,
,
( , , ).
, , "
". , , . ,
( )
- , ( )
. (
. ,
, -
, " " .) , .
, (delegation),
, ( ).
SQL , , . , SQL 26.

20.1. :

20.2. TREAT DOWN.

816

V.

20.3. :

;
;
;
;
;
;
.

( . . 5.2.)
20.4. , . 20.1, ,
ELLIPSE.
(ELLIPSE CIRCLE) ?
20.5. ,

. , ,
PLANE_FIGURE, ELLIPSE CIRCLE ( )
, . 20.1, ,
CIRCLE, SQUARE RECTANGLE ( ). ,
, ELLIPSE ( ),
( ,
, ,
. 20.1), CIRCLE
" ".
. 20.1?
20.6. , ,
RECTANGLE () SQUARE ().
,
, ,
, .
20.7. , . 20.6,
90 . ,
.
20.8. 20.6 : ",
R ELLIPSE.
, R ,
, ".
20.6 :
R : IS_CIRCLE ( ) WHERE THE_R ( A ) > LENGTH ( 2 . 0 )

20.

817

)
WHERE, , ?
R WHERE IS_CIRCLE ( ) AND THE_R ( ) > LENGTH
(2.0)
) .
R WHERE CASE
WHEN IS_CIRCLE ( A ) THEN
THE_R ( TREAT_DOWN_AS_CIRCLE ( A ) )
> LENGTH (2.0)
WHEN NOT ( IS_CIRCLE ( A ) ) THEN
FALSE END CASE
? , ?
20.9. [3.3] .
R TREAT_DOWN_AS_T ( )
R , (, r), , . .
) , r,
.
) , r,
,
.
, TREAT DOWN . ?
20.10. R:IS_ T( A) .
?
20.11. SQL - .
?
20.12. , , SQL ?
?

, , ,
. -, , ,
. -, " " 1, 2, . . ., ( > 0)
',
1, 2, . . ., , T'. , , , [3.3].

818

V.

20.1. Alphora. Dataphor Product Documentation //


Dataphor, Alphora (. http://www.
alphora. com).
Dataphor , ,
( , [3.3]).
20.2. Atkinson M. et al. The Object-Oriented Database System Manifesto // Proc. 1st Int.
Conf. on Deductive and Object-Oriented Databases. Kyoto, Japan, 1989. New York,
N.Y.: Elsevier Science, 1990.
,
( 20.1),
: " : , ,
...
,
".
,
.
[20.5] (Cleaveland) : "[ ]
[] , -
".
. ( [20.11] .)
(Baclawski) (Indurkhya) [20.3] : "
[] [].
, ,
...
. , ,
, ...
... ,
, [] ;
,
". , !
, .
. 25 [25.1],
.
20.3. Baclawski ., Indurkhya . Technical Correspondence // CACM. September 1994.
37, 9.
20.4. Cardelli L., Wegner P. On Understanding Types, Data Abstraction, and Polymorphism //
ACM . Surv. - December 1985. - 17, 4.
20.5. Cleaveland G.J. An Introduction to Data Types. Reading, Mass.: Addison-Wesley,
1986.

20.

819

20.6. Date . J. Is a Circle an Ellipse? //http: / /www. dbdebunk. com, July 2001.
, , , .
,
.
. , ;
http://www.dbdebunk.com.
20.7. Date . J. What Does Substitutability Really Mean? // http: / /www. dbdebunk. com,
July 2002.
[20.9].
20.8. Fun Y.-C et al. Implementation of SQL3 Structured Types with Inheritance and Value
Substitutability // Proc. 25th Int. Conf. on Very Large Data Bases, Edinburgh,
Scotland. September 1999.
: " ,
DB2... -,
, , /,
, . -, ,
, , . -, ".
. " , ",
, SQL ( "" , , ,
).
20.9. Liskov ., Wing J. A Behavioral Notion of Subtyping // ACM TOPLAS (Transactions on
Programming Languages and Systems). November 1994. 16, 6.

(Liskov Substitution Principle LSP).
.
20.10. Mattos N., DeMichiel L.G. Recent Design Trade-Offs in SQL3 // ACM SIGMOD
Record. December 1994. 23, 4.
SQL
( , (Zdonik) (Maier) [20.14]). . ,
.

820

V.

20.11. Meyer . The Many Faces of Inheritance: A Taxonomy of Taxonomy // IEEE Compu
ter. May 1996. 29, 5.
20.12. Rumbauch J. A Matter of Intent: How to Define Subclasses //Journal of Object-Oriented
Programming. September 1996.
20.9, ,
. ,
- (, ,
) . : " SQUARE RECTANGLE? ... X .
, . . , ... ... - ,
...
:
" ( ).
. 25, , .
, ,
- " ,
". , ,
, . ( , , , [3.3].)
20.13. Taivalsaari A. On the Notion of Inheritance //ACM . Surv. September 1996. 28, 3.
20.14. Zdonik S.B., Maier D. Fundamentals of Object-Oriented Databases// [25.52].

21

21.1.
21.2.
21.3.
21.4.
21.5.
21.6.
21.7.
21.8.




"/"

SQL

21.1.
2 .
: " ,

,
,
,

. ,
,
,
".
, ,
,
( World Wide Web . 27)
.
, 2 "/",
.
"/ " 21.5.
.

822

V.

21.2.
, ,
.
(site),
, :
) ,
) ,
,
.
, ,
( , ). . 21.1.
, .
, ,
,
(
, , ..)
. ,
,
( , ).

.


. ,
().
, ( , , . 21.1), ,
. ( ). . ,
,
(). ()
.

( ) .
21.1 .
. , , .
, .

21.

823

. 21.6.

. 21.1.

? ,
, , , .. , , .. , .. , , ..
, , , . ,
, . . ,

824

V.

, ,
.
, .
. 21.1. , , - , . -, -
-. : ( ,
) ( - - ).
, ,
, . ,
,
. , ,
, , . , , , , , .
, .


. . . -, SDD-1,
- Computer Corporation of
America 1970- 1980- [21.32]. -, R* (
"R-star" "R-")1, - System R,
IBM 1980- [21.37].
-, Distributed Ingres, Ingres,
1980- [21.34].
, SQL
, , , . : Ingres/Star ( Ingres),
Oracle
DB2.
-> .
, ,
( )
. ,
1
" " (KJeene), "R*" "
[System] R":

21.

825

; ,
. , , ,
, , ,
( , SQL). ,
,
.
[15.6].
.

, [21.13].
, .
,
, . (
), ( ).
. ( ),
.
. , , , ,
(, ) X , , Y z (. ).
2. ,
. .
1.
2.
3.
4.
5.
6.
7.
8.

.
.
.
.
.
.
.
.

2
"" , ,
[21.13]. " " " ".
"" "" .
"".
.

826
9.
10.
11.
12.

V.
.
.
.
.

, . ,
(
, , ,
). .

. 21.3 . 21.4 , 21.5, , "/". 21.6
,
. , 21.7 SQL, 21.8
.
. , (, ,
"/").
, "". , , , , . , , . (
, " ".) ( ), .
21.3. 1.

, .
, .
X Y, (,
Y , X ,
X ; , , ).
, , . , , .
, , , ,
, .

21.

827

, , X
.
: . (. [21.13], .)
2.
, . , , , ,
. , , , ,
.
,
, . "
" ,
.
.

. -, , ,
, , - ( ), , ( ).
3.
,
.
,
.
, " "; ( , )
, .
, . ,
,
(
6).
, .. , .
, , , ! , , , .. ,
- , , .

828

V.

4.
!
,

, . , ( , ),
.
.
, ,
-
. ,

.
. ,

. , ,
, "", , . 21.4,
( " ").
5.
, , ,
, . . , , . ,
,
. 21.2. , ,

(. . 21.2).
FRAGMENT EMP AS
N_EMP AT SITE 'New York1 WHERE DEPT#
= DEPT# ('Dl')
OR
DEPT# =
DEPT#
('D3') ,
L_EMP AT SITE 'London'
WHERE DEPT#
= DEPT# ('D2') ;
. ,
- , D1 D3 , -, a D2 , . , - -,
. , N_EMP L_EMP.
: ;
( . 21.2
). .
, .

21.

829


, 13.6 13.
, 12 13.

, ..
, , ,
, , .
. ,
; . .

. 21.2.

(
, ). , ,
(..
).
.
, ,
. , . 21.2,
-, , {EMP#,DEPT#} {SALARY} .

830

V.

, ,
TID (Tuple ID).
TID, , . ,
. , , , {TID,EMP#,DEPT#} {TID, SALARY}, , , . , ,
, TID ,
, ( ) ,
.
, , ,
,
. ,
[15.6].
. ,
, (
). ,
, , ,
.
( )
, . , ,
( )
, , .
, ,
,
.
,
. , , . 21.2, , .
WHERE SALARY > 40K AND DEPT# = DEPT# ( ' Dl ' )
( , , ; ,
-, ,
.
.
() , NJEMP L_EMP, .
VAR "VIEW"
N_EMP UNION L_EMP ;

/* */

21.

831

{ N_EMP UNION L_EMP ) WHERE SALARY > 4OK


AMD DEPT# = DEPT# ('Dl')
( ).
( N_EMP WHERE SALARY > 4OK AND DEPT# = DEPT# ('Dl') )
UNION ( L_EMP WHERE SALARY > 40K AND DEPT# =
DEPT# ('Dl') )
L_EMP ,
UNION .
EMP WHERE SALARY > 4OK AND DEPT# =
DEPT# ('Dl') AND DEPT# = DEPT# ('D2')
, WHERE (TRUE).
, .
N_EMP WHERE SALARY > 40 AND DEPT# = DEPT# ('Dl')
, .
. ,
.
EMP WHERE SALARY > 4OK
, ,
( ). , , (. 10).
, ( , )
,
(, , ), , .
6.
, ( ) , , .
(. 21.3). , NL_EMP
LN_EMP.
REPLICATE N_EMP AS
LN_EMP AT SITE 'London' ;
REPLICATE L_EMP AS
NL_EMP AT SITE 'New York' ;

832

V.

. -,
, , .
-, ,
( , ),
. , , , , (
). 21.4 .
, , ,
1.

. 21.3.
, , , " ". , ,
, (
" "). ,
, , ,
. ( ) ,
.
,
,
.
,
,
. .
, ,
,
, .. " ".

21.

833

21.4.
7.
, ,
.
-, : "
". , , . ,
, .
, , ,
: - ,
, .. , . , ,
, , ,
2 - ,
,
-, .
,
.
-, ,
. , , ,
.
,
. ,
. , , , Rx,
X, Ry, Y,
Rx Y Ry X,
- Z ..
, ("
"), 21.4.
, ,

. ,
( )
( !). , ,
, , ,
,
( :
, ).
8.
, , :
. .

834

V.

,
.
, , ,
. , , , . ,
, , ,
, , .
. ( " ") , ,
, .
, 15, .
21.4.
,
, , . [16.1]. , -, ,
.
21.4.
9.
.

, , IBM, Fujitsu, HP,
, ..
" " [21.9]. , ,
, , .
10.
. ,
,
(, OS/390, UNIX Windows
).

21.

835

11.
, , .
, , , .
12.
,
.
. , , , , ,
,
, . ,
Ingres Oracle SQL, ,
, Ingres Oracle
. , , , ,.
.
.
, , - . , .
( ), (. 21.6).
21.4.
, 21.3. , , , , , , .
5 10 . 510 .
( ,
, .) (
, , ) , ..
. , , . , , .
.
.
.
.
.

836

V.


, , . , ,
. ,
, Q X, ,
Q Ry Y, 10 . ,
Rz z, 10 . .
Q. ,
Ry Z, Rz Y (,
, , Ry, Rz X). , Ry Z, Z .
, (Rothnie) (Goodman)
[21.31].
.

, .
()
, .,'. S { S#, CITY } 10 000
{ #, COLOR } 100 000
SP { S#, # }
1 000 000

, 25 (200 ).
(" ")
( ( S JOIN SP JOIN P ) WHERE CITY = 'London' AND
COLOR = COLOR ('Red') ) { S# }


10
, 100 000


50 000 /
0,1

,
i Ti
:
( ) +
( / )
( ):
( / 10 ) + ( / 50000 )

21.

837

.
[1] = 0,1 + ( 100000 * 200 ) / 50000
= 400 ( 6,67 )

.
[2] = 0,2 + ( ( 10000 + 1000000 ) * 200 ) /
50000 = 4040 ( 1,12 )
,


, .
.
.
[ 3 ] = 20000 ( 5 , 5 6 )
, ,
,
.
.
.
[ 4 ] = 2 ()
,
, s# #
. .
[5] = 0,1 + ( 100000 * 200 ) / 50000
= 400 ( 6,67 )
,
, .
.
[6] = 0,1 + ( 10 * 200 ) /
50000 = 0,1
()
. 21.1 .
.
,
.
, .
.

.
.
[21.33].
.,,

838

V.

,
21.1. ()

,
, , ,
, .

, , ,
, ..,
, ,
. : " ?". .
1. .
.
2. . .
3. .
, .
.
4. 1 3. ,
3. ,
,
1.
. 1
" ". 2
, . 3 ( ). 4 3 (
), .

21.

839

!
, R* [21.37].
R*,
.
.
X (, )
, , R, ( ) , , .. . , , .R
Y. R, , . .
, R*.
, (, SELECT SQL),
,
. .
, .. ,
CREATE .
, .. ,
CREATE.
, .. .
, .. ,
.
,
. , , .
MARILYN @ NEWYORK . STATS @ LONDON
( , ) STATS, MARILYN
- 3.
- ,
(. ).
, . , , ,
" " (
STATS), , R*
CREATE SYNONYM.
CREATE SYNONYM MSTATS FOR MARILYN @ NEWYORK . STATS @ LONDON ;

3
R* . , .
.

840

V.

.
SELECT ... FROM STATS ... ;
SELECT ... FROM MSTATS ... ;
, .. ,
, ,
,
. ,
System R - R* (.. System R R*).
, .. , . .
, ,
.
, .
1. ,
.
2. , .
, , MSTATS. ( ).
( ),
( ).
. 1. -
, . , , , ,
- ( ).
-
. 2. , .
, , , , .
-.
-.
,
- -.

.
.

21.

841

, , DB2, , .

, 21.3,
,
. ,
, , , ,
,
. , , , , , , , , ,
. -
, . ,
, .
( ) ,
.

, .
(
).
,
. , ,

.
. , ,
COMMIT,
ACID (. 15 16).
.
, , . ,
, - , () ( ).
, ACID
, ,
{ ).
,
(, ), { ). ,
, ,

842

V.

, , ,
, , , (,
. [21.1], [21.16] [21.18]).
, , , 4. , , .
,
.
1.
, 10.
,
.
, (
). ,
( ),

(. [21.18]). ,
.
2. , .
,
, , , 22. ,
, "" (
,

, , !),
.
3. ( , ),
,
: , ..
COMMIT,
(. ),
.
, "
?" (,
).

, (. 9 16),
. COMMIT ( , ), . , ,
" ",
( "" "" ).

21.

843


21.3,
( ). , .
, , .. ,
. , .
1. " " ,
,
.
,
. ( )

.
2.
,
, , .
3. Y ,
X, Y ,
X (
, ), (
) .
, ,
15. . 21.4, . ,
, ,
( !). , COMMIT,
ROLLBACK. COMMIT .
" " . . 21.4 "",
t1 t2.
, "". ,
- ( ,
), "Not OK". , "", t3 t4. , : , .
, , ,
,
.

844

V.

, "", . t5
. t5 .
, .
"", ..
. . 21.4 "", t6
t7. "" .
t8 t9.
, .

. 21.4.
, , ,
, ,
. , , t t5 t6.
,
, , "". , t3 t7 " " . t, ,
" " .

21.

845

, , ,
. , ,
, , , .. - , , ,
. , . N
, . , N - .
, ,
N ,
. , , ,
.
, , .
-, [15.6],
,
"
"
.
- ( [15.6]),
" ",
.
-, ,
,
, .
, ( ), ( ). , ,
, , ,
, . , ,
, -
" ", , , .
, , ,
, "" .
. , " " (""), "" ("").
, , ,
"". , , ,
.

846

V.

, .. ,
" ",
"".
. "", " ".
,
, " ". , .
, ..
, "", "
".
( ),

( , , , , ). , , . ,
, .. .
,
. ,
. , "", , , .
" ", ( ) , . (
,
" ".)


. , . , ,

.

21.3, , .. ,
. , ( , ),
. , , ,
.
, (
),
5 :

21.

847

n ;
n ;
n ;
n ;
n .

, , , . , , .
, .
,
, " ".
, (,

). ,
5 2+3 ( , ,
, ). , , ,
.
(, , [15.6]. ,
, .)
, , ,
, . , , . 21.5,
.
1. 2 , 1
.
2. 1 X , 1 Y
.
3. 1 Y , 2
.
4. 2 Y , 2 X
. !
, ,
,
. ,
,
. ,
, ,
.

848

V.

( ) R* (, [21.37]).
. 16, -. , ,
.

. 21.5.
21.5. "/"
21.1, "/"
. , "/" , , ; , ; " " ( ). . 21.6 ( . 2.6 2).
1980- 1990-
"/"
. , ,
"/" ,
.
, , "/" ,
. , (front end), (back end) .
, , .
(. 2),
"/" ,

21.

849

5. ,
.

. 21.6. "/"
, ,
.
(
).
. ,
, .
) , ..
.

. , ,
.
) , ..
. ,
,
. ,
.
5

" ", , ,
.

850

V.

) ( ). ,
"/", .
"/"
, "/".
.
, "/" SQL. 21.7.
, ISO (Remote Data
Access RDA) (. [21.23] [21.24]). RDA "/". ,
SQL ( , SQL),
( SQL). , , ( SQL,
, ).
, , , , (Distributed Relational
Database Architecture DRDA), IBM [21.22] (
, ).
DRDA RDA , DRDA
RDA . ,
DRDA (
IBM). , DRDA
SQL,
SQL.
, , ,
. ,
, ,
, ..
, . ,
DRDA -
. DRDA
RDA. , DRDA
IBM,
RDA ,
.
RDA DRDA .
(. [21.20] [21.28], .)
"/"
, "/" . , ,

21.

851

, , ,
.
. , ,
,
, 21.2. , , "/" .
, , "/"
( ).
7 (
) 21.3, ,
,
. "/" ( ) , , , " ", .
.
,
.
. SQL , , .. FETCH CURRENT UPDATE DELETE (. 4).
, , , . ,
, ,
( ). (Remote Procedure Call RPC). , , ,
"/", ,
.
. "/", ,
, .
.


,
.
.
,
. (,
, .)

852

V.


. ,
, , .
, ,
SQL , ,
1996 . 4, SQL/PSM
(Persistent Stored Module ).
21.6.

. . 21.3, ,
. 21.3, , , Ingres Oracle
SQL ( !), ,
.
, SQL.
.
. Ingres
Oracle, , .
, , , .

, (X Y), Ingres
Oracle, . , X
,
Ingres X, Oracle Y.
Ingres, , ,
Ingres.

Ingres. ?
, : Ingres
, " Oracle,
Ingres". ( ). 6 . 21.7. Ingres,
Oracle ( )
6
, ,
" " ( ). , ( , ,
).

21.

853

. , , , . ( ,
.
RDA DRDA, 21.5,
, , XML (. 27).)

. 21.7. Oracle,
Ingres
Ingres Oracle.
, ,
,
Ingres, , Oracle,
, Oracle,
, Ingres.
" SQL" Oracle (
SQL,
). ,
Oracle
SQL.
SQL , , (Call-Level
Interface CLI), SQL/CLI, ODBC JDBC Oracle (. 4).
.
SQL, Oracle.
Ingres Oracle. , (.. ), ( ORDER BY
), (
), ( , ),
, .
[15.6], .

854

V.

SQL Ingres SQL Oracle


( Ingres, Oracle
SQL).
, ,
, , .
. ,
,
, , ;
.
Oracle ( ..)
Ingres.
Oracle Ingres, Ingres
Ingres ,
Oracle.
,
(., , [21.8], [21.11], [21.14],
[21.36] [21.38]).
( Ingres #,
Oracle EMPNO);
( Ingres
, Oracle );
( Ingres ,
Oracle );
( Ingres ,
Oracle ) .
( Ingres)
(, Ingres
Oracle).
, ,
Oracle. ,
( )
,

" " (
, .. ).
Oracle , Ingres,
.. , ,
Ingres. -,
, -, ,
Oracle
Ingres.

21.

855


. ? ,
? , , IMS
Ingres Oracle? , ,
7,
IMS , .
?
: " 100%?"
( " ?"), : "" ( ,
[21.14]). : " ?", . . [21.13] [21.14].

, , "-". .
-, . -,

(, DB2, Oracle
Informix), , ,
, , ..
( , ) , .
,
(middleware) (mediator), .
, (
) . , ,
, , , [21.3]. , .
Cohera Cohera, DataJoiner IBM, OmniConnect InfoHub
Sybase. DataJoiner [21.6].
7
, 85% (..
). , -
.

856

V.

(. 21.8).
, (.. ).
DataJoiner , SQL, , .. ( DataJoiner
AIX DB2 IBM.)
DataJoiner ( ),
,
( , , , VSAM). ,
DataJoiner ,
/
. , 8,
/ , ,
, ( ).
. DataJoiner
SQL DB2 , . WITH HOLD
(. 15).
, , , , , (..
). , , , , DataJoiner,
( ). ,
,
, [21.17].
, ,
. ;
[21.7].
DataJoiner
, ,
"-", , , .
(
ODBC.) DataJoiner , , , , .
, DataJoiner , (, , ..),
, . , , IBM
s
"" ; ,
( - ), , , , ,
IMS - , SQL (-, . [21.14]).

21.

857

DataJoiner DB2;
, DB2,
( , IBM) , (
, , , Informix, Oracle, SQL Server Sybase). , DB2, DataJoiner, IBM , " " [21.9].

. 21.8. DataJoiner


, ,
SQL. , . , , , . ,
, (,
!).

858

V.

21.7. SQL
SQL 9
. ,
, , , .
, , FRAGMENT, REPLICATE
.. [15.6]. SQL .
, SQL "/", , , CONNECT DISCONNECT . ,
SQL CONNECT ,
- (
CONNECT ). , , .. , SQL ,
.
SQL , ,
. . ,

SET CONNECTION, ,
.. ,

, .
. SQL ( ),
.
, , . , ,
, , -, ,
, SQL.
, , ( ,
), DISCONNECT, DISCONNECT, CONNECT, .
( , SQL, )
SQL [4.23], [4.24] [4.20].

21.

859

21.8.
.
[21.13].
, .
, , , ,
. , ,
; , 21.6
,
.
"/",
. ,
SQL,
"/", ,
(.. ,
SQL).
.
. , , . ,
,
, ( ), [21.31]. .
,
(. [18.56]). , .
,
, . , , , " ".
, , , , ..
,
( , , , 4, 5, 6 8), , ,
[10.3]. .
(). " ... [ , ]
, .
) ( ).

860

V.
) (
)".
, ( ) 46 912, ..
, "",
. , , .

21.1. ,
.
21.2. ?
21.3. ?
?
21.4. :

;
;
;
;
.

21.5. R*.
21.6. "-" (
)
. SQL
.
, .
21.7. "/".
CONNECT
DISCONNECT? SET CONNECTION
- " "?
? ?

? ?
?
( , )?
21.8. , SQL.
? ,
? ? ?
SQL?
(IF-THEN-ELSE)? ?
? ?
?
?

21.

861


21.1. Anderson ., Breitbart Y., Korth H. F., Wool A. Replication, Consistency, and Practica
lity: Are These Mutually Exclusive? // Proc. 1998 ACM SIGMOD Int. Conf. on
Management of Data. Seattle, Wash. June 1998.
(
lazy), .
.
, [21.18],
. ( , ) . ,
"
".
21.2. Bell D., Grimson J. Distributed Database Systems. Reading, Mass.: Addison-Wesley,
1992.
, ( [21.10] [21.29]).
. , .
21.3. Bernstein P. A. Middleware: A Model for Distributed System Services // CACM.
February 1996. - 39, 2.
: "
, ,
.
".
21.4. Bernstein P. A. et al. Query Processing in a System for Distributed Databases (SDD-1) //
ACM TODS. - December 1981. - 6, 4.
. [21.32].
21.5. Bernstein P. A., Shipman D. W., Rothnie J. B. Concurrency Control in a System for
Distributed Databases (SDD-1) //ACM TODS. March 1980. - 5, 1.
. [21.32].
21.6. Bontempo . J., Saracco . . Data Access Middleware: Seeking out The Middle
Ground // InfoDB. - August 1995. - 9, 4.
,
DataJoiner IBM ( ).
21.7. Breitbart Y., Garcia-Molina H., Silberschatz A. Overview of Multi-Database Transaction
Management // The VLDB Journal. October 1992. 1, 2.
21.8. Bright Y., Hurson A. R., Pakzad S. Automated Resolution of Semantic Heterogeneity in
Multi-Databases// ACM TODS. - June 1994. - 19, 2.
21.9. Brodie M.L. Data Management Challenges in Very Large Enterprises (
) // Proc. 28th Int. Conf. on Very Large Data Bases, Hong
Kong. August 2002.

862

V.


. : " []
[] . , 40%
...
".
21.10. Ceri S., Pelagatti G. Distributed Databases: Principles and Systems. New York, N.Y.:
McGraw-Hill, 1984.
21.11. Cohen W. W. Integration of Heterogeneous Databases without Common Domains Using
Queries Bases on Textual Similarity // Proc. 1998 ACM SIGMOD Int. Conf. on
Management of Data. Seatle, Wash. June 1998.
, " ".
, (, "AT&T
Bell Labs" "AT&T Research") ( ,
). ,
" ,
". ,
, "
", , , .
21.12. Daniels D. et al. An Introduction to Distributed Query Compilation in R* // Distributed
Data Bases (ed. H.-J. Schneider): Proc. 2nd Int. Symposium on Distributed Data
Bases. - New York, N.Y.: North-Holland, 1982.
. [21.37].
Date . J. What is a Distributed Database System? // Date C. J. Relational Database
Writings 1985-1989. Reading, Mass.: Addison-Wesley, 1990.
( 21.3 ). , 100%.
, .

,
.
( )

, .

( ) R X. ,
R, X,
R.
,
,

21.
, .
, .

863

, ,
( ),
-.
. [15.6], .
21.14. Date . J. Why Is It So Difficult to Provide a Relation Interface to IMS? // Relational
Database: Selected Writings. Reading, Mass.: Addison-Wesley, 1986.
, IMS,
.
1. , IMS
?
2. "" IMS,
IMS ?
, , ,
( ,
IMS, , -, );
, ( ,
100%). .
21.15. Epstein R., Stonebraker M., Wong E. Distributed Query Processing in a Relational
Database System // Proc. 1978 ACM SIGMOD Int. Conf. on Management of Data.
Austin, Tex. May-June 1978.
. [21.34].
Goldring R. A Discussion of Relational Database Replication Technology // InfoDB.
1994.-8, 1.
.
21.17. Grant J., Litwin W., Roussopoulos N., Sellis T. Query Languages for Relational MultiDatabases // The VLDB Journal. April 1993. 2, 2.
. , ,
( , " ").
21.18. Gray J., Helland P., O'Neil P., Shasha D. The Dangers of Replication and a Solution //
Proc. 1996 ACM SIGMOD Int. Conf. on Management of Data. Montreal, Canada
June 1996.
, : "
, , ... , () ,
".

864

V.

21.19. Gupta R., Haritsa J., Ramamritham K. Revisiting Commit Processing in Distributed
Database Systems // Proc. 1997 ACM SIGMOD Int. Conf. on Management of Data. Tucson, Ariz. May 1997.
, , "
".
21.20. Hackathorn R. D. Interoperability: DRDA or RDA? // InfoDB. 1991. 6, 2.
21.21. Hammar M., Shipman D. Reliability Mechanism for SDD-1; A System for Distributed
Databases // ACM TODS. - December 1980. - 5, 4.
. [21.32].
21.22. IBM Corporation. Distributed Relational Database Architecture Reference. IBM
FormSC26-4651.
DRDA, IBM, .
1. .
2. .
3. .
4. .
, , ,
.
. , IBM,
, , , SQL.
. ,
SQL Y.
( )
Y. X
Y (, , z) ,
.
( RUW Remote Unit of Work). ,
X
Y
(.. ). ,
Y.
, ,
.
. , , "/" .
( DUW Distributed Unit of Work).
, X Y, Z ...

21.

21.23.

21.24.
21.25.
21.26.

865

(..
). ,
. , . X
, .. , , .
.
"/" .
. ,
. , ,
( SQL) . ,
, ,
Y Z.
, ,
.
.
International Organization for Standardization (ISO). Information Processing Systems,
Open Systems Interconnection, Remote Data Access Part 1: Generic Model, Service, and
Protocol. ISO DIS 9579-1. - March 1990.
International Organization for Standardization (ISO). Information Processing Systems,
Open Systems Interconnection, Remote Data Access Part 2: SQL Specialization.
ISO DIS 9579-2. - February 1990.
Kossmann D. The State of the Art in Distributed Query Processing // ACM Comp.
Surv. December 2000. 32, No. 4.
Lindsay B. G. et al. Notes on Distributed Databases // IBM Research Report RJ2571.
July 1979.
, R*,
, .
.
1. .
2. .
3. .
4. .
5. , .
1 . 2, ,
( R). 3
, .
4 , , .

866

21.27.

21.28.
21.29.
21.30.

21.31.

21.32.

V.
, 5
, , .
Mohan , Lindsay . G. Efficient Commit Protocols for the Tree of Processes Model of
Distributed Transaction // Proc. 2nd ACM SIGACT-SIGOPS Symposium on Principles
of Distributed Computing. 1983.
. [21.37].
Newman S., Gray J. Which Way to Remote SQL? // DBP&D. December 1991. 4,
12.
Oszu M. ., Valduriez P. Principles of Distributed Database Systems (2nd edition).
Englewood Cliffs, N.J.: Prentice-Hall, 1999.
Rennhackkamp M. Mobile Database Replication // DBMS. October 1997. 10, 11.
,
,
. ,
, , ,
(, , ) .. (. [21.1], [21.18]). .
Rothnie J. ., Goodman N. A Survay of Research and Development in Distributed
Database Management // Proc. 3rd Int. Conf. on Very Large Data Bases. Tokyo,
Japan October 1977.
, .
1. .
2. .
3. .
4. .
5. .
, 21.8 .
Rothnie J.B., Jr. et al. Introduction to a System for Distributed Databases (SDD-1) //
ACM TODS. - March 1980. - 5, 1.
[21.4], [21.5], [21.21], [21.32] [21.32] SDD-1, PDP-10
DEC, ARPAnet (. 27.2 27).
,
. .
. SDD-1 (. [21.4]) , 7.8

21.

867

7.
, ,
. , ,
S , SP ,
: "
".
S, , ,
.
TEMPI SP S# .
TEMPI .
2 TEMPI S
S# .
2 .
2 SP s#
. .
,
, . size (TEMPI) +
size (TEMP2) < size ( S ) size()
, ,
(, ).
TEMP1 2.
. SDD-1
" " (
). .
, .

, ,
! ,
[16.3] .
[21.5]. .
- , ,
,
.
, , .
. .
, , ..
,
, .
, , , ,

,

868

V.

( ),
, .. .
21.33. Selinger P. , Adiba M E. Access Path Selection in Distributed Data Base Management
Systems // S.M. Deen and P. Hammersley. Proc. Int. Conf. On Data Bases. Aberdeen,
Scotland July 1980; London, England: Heyden and Sons Ltd., 1980.
. [21.37].
21.34. Stonebraker M. R., Neuhold E. J. Distributed Data Base Version of Ingres // Proc. 2nd
Berkley Conf. On Distributed Data Management and Computer Networks. Lowrence
Berkley Laboratory, May 1977.
[21.15], [21.34] [21.35]
Distributed Ingres. Distributed Ingres
University Ingres,
PDP-11 DEC. ( SDD-1 R*);
( , ),
, , . SDD-1 R*, Distributed
Ingres ,
; , , , .
Ingres, 18 . [21.15].
Distributed Ingres
: ,
(
), , [21.35]. ,
( ).
, Distributed Ingres
, , , , .

, , , ( ),
.
21.35. Stonebraker M. R. Concurency Control and Consistency of Multiple Copies in
Distributed Ingres // IEEE Transactions on Software Engineering. May 1979. 5,
3.
. [21.34].

21.

869

21.36. Wen-Syan Li and Clifton C. Semantic Integration in Heterogeneous Databases Using


Neural Networks // Proc. 20th Int. Conf. on Very Large Data Bases. Santiago,
Chile. - September 1994.
21.37. Williams R. et al. R*: An Overview of the Architecture // P. Scheuermann. Improving
Database Usability and Responsiveness. New York, N.Y.: Academy Press, 1982. (
: IBM Research RJ3325. December 1981.)
[21.12], [21.27], [21.33] [21.37] R*,
System R.
R* ,
, , . .
( , ;
).
, .
21.38. Yan L.L., Miller R.J., Haas L.M., Fagin R. Data-Driven Understanding and Refinement
of Schema Mappings // Proc. 2001 ACM SIGMOD Int. Conf. on Management of Data,
Santa Barbara, Calif. May 2001.

22

22.1.
22.2.
22.3.
22.4.
22.5.
22.6
22.7.
22.8.
22.9.







SQL

22.1.
.
(David McGoveren) Alternative Technologies.
,
. "
, ... " [22.9].
,
, ,
.
1940- 1950- , .. ,
. (.
1) ,

.

.

872

V.

1960- 1970-
[22.26].
, [22.6]-[22.8]. ,
.
(decision support system),
" "
, , , (On-Line
Transaction Processing OLTP),
.
.
1970- ,
() . ,
RPG, , Focus, Datatrieve NOMAD.
,
. , , - .
, , (data store),

, (
).
,
. 1980- ,

. , ,
(ad hoc) , .
SQL ,
, .. , . , . , ,
.
,
.
( ). , ,
, : (data warehouse),
(data mart), (operational data store),
(online analytical processing OLAP),
.
. , ,

22.

873

, . ,
, ,
, . ,
,
( ). SQL,
Tutorial D. " " SQL
{, , , ). , ,
2.
. 22.2 , ,
. 22.3
. 22.4 (..
,
);
. 22.5 , . 22.6 (OLAP) . 22.7
, 22.8 SQL. , 22.9
.
22.2.

,
, ( ) . .
INSERT, DELETE ,
UPDATE .
. , .
( 22.3
). , ,
.
.
(
, ,
).

874

V.

(,
, 23,
).
, (
), 1
.
, , .
.
,
, . , .
.
WHERE.
, ,
.
, ( ). - , ,
,
. ,
.
.
, , .. ,
. ,

2.
1
(, ) , IV .
,
, .

(),
1981 , , , .
, , , . , , ,
( ).
, !
. .

22.

875

. , 13, , , .
,
,
, ,
, , ,
.
.
.
(
).
,
, ,
. , ,
, ,
, .
.
.
. ,
SQL,
.

.
,
,
,
. (
), , . , 22.1,
, 3,
. , ,
,
, , ,
, .

3

(OLAP), , ""
, ,
.
.

876

V.

22.3.

: , , III, , : ,
.
1. , .
.
, ,
, ,
.
(),
( ).

.
2. ,
. , ,
. ,
, ,
,
[2.5]. ,
, ,
,
, .
, , ,
, .
, , . .
, ,
. , , SP
() () . SP , - .
, . (, , .)
, ,
, , , SP
, -, - .
,
(
, 21,

22.

877

). , . ,
, , ,
.
, 9, .
, ,
, , . , , ,
, ,
. , , SQL
. ( ).
.
, , . .


. . , , ,
(OLTP) . , .

, 22.2, ,
.

, , , .
, , , ( ,
ADDRESS). .
,
. ,
, - . () . ,
,
, .
, , ,
.

878

V.


, ,
( ) . ,
.
. , . .
9,
.

, . ,

(. 18).
.
/ , .
,
. , - .
,
,
. , ( ,
).

.
, ,
, . . ,
. , , ( 1
12), . SP , . 22.1. , MID ( ) SP.