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

DATABASE SYSTEMS

A Practical Approach to Design,


Implementation, and Management

Third Edition

Thomas M. Connolly
Carolyn E. Begg
UNIVERSITY OF PAISLEY

A
TT
ADDISON-WESLEY
Boston San Francisco New York Toronto Montreal
London Munich Paris Madrid Capetown Sydney
Tokyo Singapore Mexico City

-
2003

32.973.26-018.2.75
64
681.3.07

""
. ..
.. , .
.
"" :
info@william8publishmg.com, http://www.wiHiamspubUshing.com
, , , .
64

. , .
. 3- . : . . . : "",
2003. 1440 . : . . . .
ISBN 5-8459-0527-3 (.)

, ,
. , .
Web
Web, JDBC, SQLJ, ASP, JSP PSP
Oracle.
, OLAP, , - - .
,

,
, ,
.

32.973.26-018.2.75
.

, , , Addi:;on-Wesley UK.
Authorized translation from the English language edition published by Addison-Wesley
Longman, Inc., Copyright Pearson Education Limited 1995, 2002
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 2003
1BN 5-8459-0527-3 (.)
ISBN 0-201-70857-4 (.)

"", 2003
Pearson Education Limited, 1995, 2002

23
25

I.

41

1.
2.

43
77

.
3.

113
115

4.
5. SQL:

137
163

6. SQL:
7. QBE
8. : Access Oracle

211
255
283

III.
9. ,

10.
11. "-"
12. "-"
13.

329

IV.
14.

15,

16.

17.

331
367
397
429
447
495
497
525
569
603

V.
18.
19.

619
621
655

20.
21. SQL

723
777

VI.
22.

813
815

23.
24.
25. -

26. -
27. -

869
927
961
1005
1049

VII.
28. Web-
29. XML
30.
31.
32, OLAP

1105
1107
1173
1227
1263
1289

VIII.
.
DreamHome
.
.

.

.
ER-
.

.
3. Web-

1315
1317
1325
1339
1359
1365
1369
1377
1381
1395
1413
1427


UML ( )






I.
II.
III.
IV.
V.
VI.
VII.

23
25
25
26
27
28
29
30
30
31
31
31
32
33
33
34
35
36
38
38
40
40

I.
1.
1.1.
1.2.
1.2.1. ,
1.2.2. ,
1.3.
1.3.1.
1.3.2.
1.3.3.
1.3.4.

1.4.
1.4.1.
1.4.2.
1.4.3.
1.4.4.
1.5.
1.6.

41
43
44
46
47
52
55
55
56
60
62
63
63
64
65
65
65
68

2,
2.1. ANSI-SPARC
2.1.1.
2.1.2.
2.1.3.
2.1.4. ,
2.1.5.
2.2.
2.2.1. DDL
2.2.2. DML
2.2.3. 4GL
2.3.
2.3.1.
2.3.2.
2.3.3.
2.3.4.
2.4.
2.5.
2.6.
2.6.1.
2.6.2.
2.6.3. "/"
2.7.
2.7.1. IRDS

77
78
80
80
81
81
83
84
84
85
86
88
89
90
92
92
93
98
101
101
102
102
107
108

.
3.

113
115

3.1.
3.2.
3.2.1.
3.2.2.
3.2.3.
3.2.4.
3.2.5.
3.2.6.
3.3.
3.3.1.
3.3.2.
3.3.3.
3.3.4. ,
3.4.
3.4.1.
3.4.2.
3.4.3.
4.
4.1.
4.1.1.
4.1.2.
4.1.3.
4.1.4.
4.1.5.
4.2.

116
117
118
121
122
123
124
126
128
128
129
130
130
131
131
132
132
137
138
139
141
145
149
150
152

4.2.1.
4.2.2,
4.3.
5. SQL:
5.1. SQL

152
156
159
163
164

5.1.1. SQL
5.1.2. SQL
5.1.3, SQL
5.1.4,
5.2. SQL
5.3.
5.3.1.
5.3.2. ( ORDER BY)

164
166
167
168
168
169
170
179

5.3.3. SQL

182

5.3.4. ( GROUP BY)


5.3.5.
5.3.6. ANY ALL
5.3.7.

5.3.8. EXISTS NOT EXIST


5.3.9. (

UNION, INTERSECT EXCEPT)


5.3.10.
6. SQL:
m
6.1. SQL, ISO

184
187
190
191

198
199
202
211
212

6.1.1. SQL
6.1.2. SQL

212
213

6.2.1.

218

6.1.3. ( exact numeric)


6.2.
6.2.2.
6.2.3.
6.2.4.
6.2.5.
6.3.
6.3.1.
6.3.. ( CREATE TABLE)
6.3.3. ( ALTER TABLE)
6.3.4. ( DROP TABLE)

6.3.5. ( CREATE INDEX)


6.3.6. ( DROP INDEX)
6.4.
6.4.1. ( CREATE VIEW)
6.4.2. ( DROP VIEW)
6.4.3.
6.4.4.
6.4.5.
6.4.6. WITH CHECK OPTION
6.4.7.
6.4.8.

6.5.

214
218

219
220
221
222
223
223
224
228
230

230
231
231
232
235
235
236
237
239
240
243

244

6.5.1.

6.6.
6.6.1.
( GRANT)
6.6.2.
( REVOKE)
7. QBE
7.1. Microsoft
Access
7.2. QBE

7.2.1.
7.2.2.
7.2.3.
7.3. QBE
7.3.1.
7.3.2.
7.3.3.
7.3.4. ,
7.3.5.
7.4.
7.4.1.
7.4.2.
7.4.3.
7.4.4.
8. : Access Oracle
Microsoft Access 2000
8.1.1.
8.1.2. Microsoft Access
8.1.3.
8.1.4.
8.1.5.
8.1.6.
8.1.7.
8.1.8.
8.2. Oracle 8/8i
8.2.1.
8.2.2. Oracle
8.2.3.
8.2.4.
8.2.5. PL/SQL
8.2.6. , ,
8.2.7.
III.

9. ,

9.1.
9.2.
9.3.

246
246
247
249
255
256
259
259
262
265
266
267
269
269
272
273
274
274
277
277
277
283
283
284
284
286
291
292
294
295
298
299
301
303
311
314
315
320
322
329
331
332
333
335

9.4.
9.4.1.
9.5.
9.5.1.
9.5.2.
9.6.
9.6.1.
9.6.2.
9.6.3.
9.7.
9.7.1.
9.8.
9.8.1.
9.8.2.

9.9.
9.10.
9.11.
9.12.
9.13.
9.14. CASE-
9.15.

9.15.1.
9.15.2.
9.15.3.

10.
10.1.
10.2.
10.3.
10.3-1.
10.3.2.
10.3.3.
10.3.4.
10.3.5.
10.4.
10.4.1. DreamHome
10.4.2. DreamHome

10.4.3. DreamHome
10.4.4. DreamHome
10.4.5. DreamHome
11. "-"
11.1.
11.2.
11.2.1.
11.2.2,
11.3.
11.3.1.
11.3.2.

336
337
337
339
339
340
341
342
343
346
347
351
351
353
355
355
356
356
357
358
360
360
361
362

367
368
368
370
370
370
371
372
373
373
374
379
388
395
397
398
401
403
404
405
407
11

11.3.3,
11.3.4.
11.4.
11.5.
11.6.
11.6.1. " "
11.6.2. " " (1:*)
11.6.3. " "
11.6.4.
11.6.5.
11.7. -
11.7.1. ""
11.7.2. ""
12. ""
12.1. /
12.1.1.
12.1.2. /
12.1.3.
12.1.4.

407
408
410
410
412
412
413
415
416
418
419
419
422
429
430
430
431
432
433

12.1.5.
12.1.6. /
12.1.7. /
Branch
DreamHome
12.2.

12.3.
13.
13.1.
13.2.
13.2.1.
13.2.2.
13.2.3.
13.3. .

433
436
437
441

443
447
448
449
450
450
451

13.3.1.
13.3.2.

13.3.3.
13.3.4.

451

451

455
456
458

13.4.

459

13.5. (1)
13.6. (2)
13.6.1.
13.6.2.

460
464
465
465

13.7. ()
13.7.1.

468
468

13.7.2.
13.8.
13.9. - ()
13.9.1. ' -
13.10. ( 1 )
13.11. (4)

468
472
472
473
476
483

13.11.1.
13.11.2.
13.12. (5)
13.12.1.
13.12.2. (5)
IV.
14.

14.1.
14.1.1.
14.1.2. ,

14.1.3.

14.2.
14.3.
1.

15.

15.1.

2.

3.

16.

16.1.

16.2.

16.3.

4.

5.
6.
7.
17.

, 8.

9.
V.

18.
18.1.

483
485
486
486
486
495
497
498
499
499
500
500
503
503
525
526
526
549
569
570
571
572
573
578
598
599
603
603
614
619
621
622
13

18.1.1.
18.2.
18.2.1.
18.2.2. ()
18.2.3.
18.2.4.
18.2.5.
18.2.6. RAID (
)
18.3. Microsoft Access
18.4. Oracle
18.5. Web
18.5.1. -
18.5.2.
18.5.3.

18.5.4.
18.5.5. Kerberos
18.5.6.
HTTP
18.5.7.

18.5.8. Java
18.5.9. ActiveX
19.
19.1.
19.1.1.
19.1.2.
19.2.
19.2.1.
19.2.2.
19.2.3.
19.2.4.
19.2.5.
19.2.6.

19.2.7.
19.2.8.
19.3.
19.3.1.
19.3.2.
19.3.3.
19.3.4.

644
645
646
646
647
648
651
655
656
659
660
660
660
664
671
679
683
687
689
690
694
694
695
699
705

19.4.4.
19.4.5.
19.5.
Oracle
19.5.1. Oracle
14

633
635
638
640
643
643

702

19.4.
19.4.1.
19.4.2.
19.4.3.

623
625
627
630
631
631
632

706
709
710

711
712
713
714

19.5.2.
19.5.3.
19.5.4.
20.
20.1.
20.2.
20.3.
20.3.1.
20.3.2.
20.4.
20.4.1.
20.4.2. (S = a p (R))
20.4.3. (T=(R ><F S))
20.4.4. (S = 1',2',....m(R))
20.4.5.
(T-RuS, T=RnS, T=R-S)
20.5.
20.6. Oracle
20.6.1.
20.6.2.
20.6.3.
21. SQL
21.1. SQL
21.1.1. SQL
21.1.2. SQL (SQLCA)
21.1.3.
21.1.4.
SQL
21.1.5.
21.1.6. ISO SQL
21.2. SQL
21.2.1. EXECUTE IMMEDIATE
21.2.2. PREPARE EXECUTE
21.2.3. SQL (SQLDA)
21.2.4. DESCRIBE
21.2.5.
SQL
21.2.6.

21.2.7. SQL
ISO
21.3. ODBC (Open Database Connectivity)
21.3.1. ODBC
21.3.2. ODBC
VI.
22.
22.1.
22.1.1.
22.1.2.
22.1.3.

715
716
716
723
725
728
733
733
739
740
740
742
750
758
761
762
763
764
768
770
777
778
778
780
782
784
790
791
793
794
794
796
799
801
802
802
804
806
807
813
815
816
817
822
825

15

22.2.
22.3.
22.3.1.
22.3.2.
22.3.3.
22.3.4.
22.4.
22.4.1.
22.4.2.
22.5.
22.5.1.
22.5.2.
22.5.3.
i 22.5.4.
22.5.5.

22.6. ,

23.
23.1.
23.2.

23.2.1.

23.2.2.

23.2.3.
23.2.4.
23.3.

862
869
870
871
872
872
873
876
881
881

23.4.2.
23.4.3. (2)
23.4.4. ()

882
883
891

23.4.5.
23.5. /
23.6.

891
894
897

23.6.1.

898

23.6.2.

903

23.7.1.
23.7.2.
23.8.
23.8.1.
23.9. Oracle
23.9.1.
Oracle
23.9.2. Oracle
24.
24.1.
16

861

877

23.4.
23.4.1.

23.7.

828
833
833
833
835
835
838
839
840
851
851
854
857
861

907

907
911
912
914
914
915
919
927
928

24.2.
24.3. -
24.3.1. ,
24.3.2.
24.3.3.
24.3.4.
24.3.5.
24.3.6. ,
24.3.7.
24.3.8.
24.3.9.
24.4.
24.4.1.

24.4.2.
24.5.
25. -

25.1. -

25.1.1.
25.1.2,

934
939
940
940
942
944
945
946
948
950
951
952
953

954
955

25.2.

25.2.1.
25.2.2.
25.3.

961
963
964
966
967

969
972
973

25.3.1.

974

25.4.4.

983

25.3.2.
25.4.
25.4.1.
25.4.2.
25.4.3.
25.4.5.
25.5. " "
25.6.
2 5.6.1.
25.6.2. -
25.7. -
25.7.1. -

25.7.2.

25.7.3.
26, -
26.1. OMG
26.1.1. OMG
26.1.2. CORBA
26.2. ODMG 3.0
26.2.1. ODMG
26.2.2. ()
26.2.3. ODL

976
978
978
979
980
985

989
991
991
993
995
995
996

999
1005
1006
1006
1010
1012
1012
1014
1023
17

26.2.3. ODL
26.2.4. OQL
26.2.5. ODMG
26.3. - ObjectStore
26.3.1.
26.3.2. ObjectStore
26.3.3. ObjectStore
27. -
27.1. -
27.2.
27.2.1.
27.2.2. (Third Manifesto)
27.3. Postgres
27.3.1. Postgres
27.3.2.
27.3.3.
27.3.4.
27.4. SQL3
27.4.1.
27.4.2. ,
27.4.3.
27.4.4.
27.4.5.
27.4.6.
27.4.7.
27.4.8.
27.4.9.
27.4.10.
27.4.11.
27.4.12.
27.4.13.
27.4.14. SQL3 OQL
27.5.
27.5.1.
27.6. - Oracle
27.6.1. ,
27.6.2.
27.6.3.
27.6.4.
27.7.

1023
1026
1033
1036
1036
1039
1043
1049
1050
1054
1054
1055
1058
1059
1059
1060
1062
1062
1063
1064
1067
1068
1069
1069
1072
1074
1076
1078
1080
1083
1085
1085
1086
1089
1090
1090
1097
1098
1099
1100

VII.

1105

28. Web-
28.1. Internet Web
28.1.1.
28.1.2.
28.2. Web
28.2.1. HTTP
28.2.2. HTML
28.2.3. URL-
28.2.4. Web-

1107
1109
1110
1111
1113
1114

1119
1119

28.3. Web

28.3.1. ,
Web
28.3.2. Web
28.3.3.
Web
28.3.4. Web
28.4.
28.4.1. JavaScript JScript
28.4.2. VBScript
28.4.3. Perl
28.5. Common Gateway Interface (CGI)
28.5.1. CGI
28.5.2. CGI

1120

1120
1121
1124
1129

1131
1131
1132
1133
1135
1137

28.6. Cookie- HTTP


28.7. Web-
28.7.1. API- Netscape
28.7.2. CGI API
28.8. Java
28.8.1. JDBC
28.8.2. SQLJ
28.8.3. JDBC SQLJ
28.8.4. Java
28.8.5. Java
28.9. Microsoft Web Solution Platform
28.9.1.
28.9.2. Active Server Pages (ASP) Active Data
Objects (ADO)
28.9.3. Remote Data Services (RDS)

1138
1139
1141
1142
1143
1147
1152
1152
1153
1154
1155
1157

28.9.4. ASP JSP

1161

1158
1160

28.9.5. Microsoft Access Web-


1162
28.9.6. ASP ADO
1163
28.10. Oracle Internet Platform
1164
28.10.1. Oracle Internet Application Server
(iAS)
1165
29. XML
1173
29.1.
1174
29.1.1. (OEM)
1177
29.1.2 Lore Lorel
1177
29.2. XML
1182
29.2.1. XML
1185
29.2.2. (DTD)

29.3. XML

1188

1192

29.3.1. DOM SAX

1192

29.3.3. XSL XSLT

1194

29.3.2. Namespaces
29.3.4. XPath (XML Path)
29.3.5. XPointer (XML Pointer)
29.3.6. XLink (XML Linking)
29.3.7. XHTML

29.3.8. XML Schema

1194

1195
1197
1197
1198

1198
19

29.3.9. (RDF)
1204
29.4. XML
1207
29.4.1. Lore Lorel
XML
1207
29.4.3. XML
1210
29.4.4. XML Query
1215
29.4.5. XML (XQuery)
1219
30.
1227
30.1.
1228
30.1.1.
1228
30.1.2.
1229
30.1.3.
1230
30.1.4. OLTP
1231
30.1.5. 1233
30.2.
1235
30.2.1.
1235
30.2.2.

1236

30.2.3.
30.2.4.
30.2.5.
30.2.6.
30.2.7.

30.2.8.
30.2.9.
30.2.10.
30.3.

1237
1237
1237
1238
1238
1238
1238
1239
1241

30.3.1.
30.3.2.

1242
1242

30.3.3.

1243

30.3.4.

30.3.5.
30.4.
30.4.1. ,

1245

30.4.2.

1246

30.5.1.

1252

30.4.3.
30.4.4.
30.5.

1249
1251
1252

30.5.2.
30.6.
Oracle
30.6.1. Oracle 9i
31. '
31.1.
31.2.
31.2.1. DM ER
31.3.

31.4.
20

1244

1244
1245

1254

1256
1256
1263
1264
1264
1268
1269
1276

31.5.
Oracle
31.5.1. Oracle Warehouse Builder
31.5.2 Oracle Warehouse Builder
32. OLAP
32.1. (OLAP)
32.1.1. OLAP
32.1.2. OLAP
32.1.3. OLAP
32.1.4.
32.1.5. OLAP
32.1.6. OLAP
32.1.7. SQL OLAP
32.2.
32.2.1.
32.2.2.
32.2.3.
32.2.4.

32.2.5.
32.2.6.

32.2.7.

32.2.8.

VIII.
.
DreamHome
A.I. Branch DreamHome
.1.1.
.1.2. ()

.2. Staff DreamHome


.2.1.
.2.2. ()

.
.1. University Accommodation Office
.1.1.
.1.2. ()
.2. EasyDrive School of Motoring
.2.1.
.2.2. ()
.. Wellmeadows Hospital
,3.1.
,3.2. ()

8.1.
8.2.
8.3.
8.4.
8.4.1.
8.4.2. ,
.5.

1279
1279
1280
1289
1290
1291
1292
1294
1294
1297
1300
1302
1305
1305
1307
1308
1310

1311
1311
1311

1312

1315
1317
1317
1317
1319

1320
1320
1322

1325
1325
1325
1327
1328
1329
1329
1330
1330
1336

1339
1340
1341
1342
1344
1347
1348
1349
21

8.5.1.
8.5.2. -

1349
1350

8.5.3.

8.5.4.
8.5.5.

.6.
8.6.1.
8.6.2.
.

.
ER-
.1. ER-

.2. ER-
" "

1351

1352

1353
1355
1357
1358
1359
1365
1365
1365

.

1369
1.

1369
2.

1370
3.

1373
4.

1374
5.

6.
7.
8.

9.
.

3. Web-
3.1. JavaScript
3.2. PostgreSQL
3.3. CGI Perl
3.4. Java JDBC
3.5. Java SQLJ
3.6. JSP
3.6. ASP ADO
3.8. PSP Oracle

22

1374

1375
1375
1375
1375

1377
1381
1381
1383
1384
1386
1387
1388
1389
1392
1395
1413
1427


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



30
.
.
. ,
.
. , , , ,
, . "
", " ", .

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

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

25

.
, ., .
, , DreamHome. , ,
.

UML ( )
, .
, "-" (Entity-Relationship ER).
.
ER-. , , , , .
(Chen).
, ; .
" " (Crow's Foot).
,
. " " " "
" " .
(Computer-Aided
Software Engineering CASE).
, .
. , Pearson Education, ,
- UML (Unified Modeling Language ). UML ,
, -
: , (Rumbaugh),
- (Booch)
Objectory (Jacobson).
. -,
UML . , OMG
(Object Management Group
) UML
. -, UML, ,
. -, UML
, UML . UML. 26

. UML,
, UML
. Pearson Education Database Solutions: A Step-by-Step Guide to
Building Databases.
.
Microsoft Access,
Oracle.
, CD-ROM Rational Rose.


,
, . .
,
.
, : Microsoft Access Oracle.
, , , , , .
"-" (Entity-Relationship ER)
"-" (Enhanced Entity-Relationship EER)
UML.
.
,
DreamHome.
, SQL, :
, ,
SQL ODBC (Open Database Connectivity
).
,
Microsoft Access Oracle, Web.

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

27

ODMG (Object Data Management


Group
), 1999 ,
ObjectStore.
-
SQL3.
Web .
,
Web.
JavaScript, PHP PostgreSQL, CGI Perl, Java JDBC SQLJ,
Java (Java Server Pages), (Active Server Pages) PL/SQL (PL/SQL
Server Pages) Oracle.
XML,

XML,
, , . ,
, .


-
, ,
, . , , :
, , .
, , , , , , , .
,
.
,
. 16, , 20, , , .
, .
, , 1.
,
, 21 SQL 26.3,
ObjectStore.

28


1. , "-", , . ,
.
2. , , , ,
. ,
.
3. , ,

.
4.
, .
.
, .
5.
( SQL Structured Query Language QBE Query-By-Example),
-
ODMG.
6. , SQL, SQL.
7. , : Microsoft Access Oracle.

Microsoft Access Oracle.
8. ,
.
9. -
( ), ODMG, , SQL (SQL3).
10. Web Web.
11. ,
XML XML.
12. ,
(OLAP) .

29

13. , . .
14. , , ,
.


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

, .
, .
,
.
, .
,

.
Instructor's Guide ( ).


Pearson
Education. Instructors Guide ( ) .
. , , ,
. , ,
,
.

30

.
.

.

( , ) .
. ,
, .
Instructor's Guide
Web- Pearson Education :
http://www.booksites.net/connolly.


I.

--

t,-.

I
.
1 ,
,
(.. ), , .
2 , ANSI-SPARC,
, ,
. ,
.

.
II ,
QBE (Query-By-Example ) SQL (Structured Query
Language ).
: Microsoft Access Oracle.
3 ,
, , .

, .
, 6.
4 ; .
. , 20, ,

31

22, . ,
SQL 5 6, .
5
SELECT, INSERT, UPDATE DELETE, SQL.
, ,
, .
6 SQL. .
SQL , (Integrity Enhancement
Feature IEF) ,
GRANT REVOKE. SQL.
7 ,
QBE (Query-ByExample ),

, . QBE
Microsoft Access.
8 .
: Microsoft Access Oracle. , .

III.
III .
9
. ,
, : , ,
, ( )
( ).

. . .
10 ,
.

. ,
DreamHome.
11 12 "-"
(Entity-Relationship ER) "-"
(Enhanced Entity-Relationship EER).
/ . EER-
-

32

.
UML ER-.
13 ,
.
, , ,
,
.

IV.
IV .
, ,
. DreamHome.
14 .
, , , , .
15 . ,
. ,
, .
16 17 . , .
,
, .

V.
V , .
18
, . , Microsoft Access Oracle.
,
Web, .
19 , : , . ,

33

. , ,
.
Oracle.
20 .
: , ,
,
, .
Oracle.
21 SQL
, . ODBC (Open Database Connectivity
), SQL .

VI.
VI . .
. , .
22 , , , .
23 , . , ,
, , .

(Distributed Transaction Processing DTP),
/Open,
. Oracle.
. ,
,
.
,
,
.
24-27.
24 .
, ,
, -
. . , ,
.

34

25 - ().
-
. , , , , ,
. ( )
. , , , .
,
IV - .
26 ,
ODMG (Object Data Management Group
),
. ObjectStore.
27 - , SQL (SQL3). , .
- Oracle.

VII.
, , :
Web, XML,
, (On-Line
Analytical Processing OLAP) .
28 Web.
Internet Web Web
. Web, , CGI, ,
Java, (Active Server Pages)
Oracle Internet Platform.
29 XML,
XML Web. , XML,
Namespaces, XSL, XPath, XPointer XLink. XML Schema XML (Resource Description Framework
RDF) .
XML.
30 .
, .
, , . ,

35

, . Oracle. '
31 / , . ,
, "-" (Entity-Relationship ER). , DreamHome,
Oracle Warehouse Builder,
32 (On-Line
Analytical Processing OLAP) .
OLAP,
OLAP (Multi-dimensional OLAP - MOLAP), OLAP
(Relational OLAP ROLAP) (Managed Query Environment MQE).
SQL , , Red Bricks Intelligent SQL (RISQL) SQL.
,
, , ,
.

DreamHome,
.
,
.

, , 16,
, 20.
12 (Codd) ,

.

, UML:
(Chen) " ".
,
14-17, ,
.

Oracle.
3 Web,
Web , 28.

. 1.

36

III
9 ,

10 1"
'"

11 ;
"-"

12
"-""

13

IV
141. ....;
' *.

' .

19
;

21
3QL
,

VI
25 - -
''

26 - -..
'3:
'
.;.^

23

' ":>

22
' '-?
'
.

29[:
^

28 Web-
. '

270

VII
30

32 OLAP ,
-:-;.

. 1.


, . , ,
. ,
.
. Web-, ,
, ,
, ,
.
, , .

.
E-mail: infowilliamspublishing.com
W W W http: / / w w w . w i l l i a m s p u b l i s h i n g . c o m


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

(Simon Plumtree) (Nicky
Jaeger) , ;
(Martin Tytler)
(Lionel Browne).
, . , X. (William H. Gwinn), (Texas Tech University);
(Adrian Larner) , (University De
Montfort, Leicester); - (Andrew McGettrick)
(University of Strathclyde);
- (Dennis McLeod)
(University of Southern California); - -
(Josepnine DeGuzman Mendoza)
(California State University); (Jeff Naughton) ..
(.. Schwarzkopf) (University of
Oklahoma); - (Junping Sun) (Nova Southeastern University); -
(Donovan Young)
(Georgia Tech); (Barry
Eaglestone) (University of Bradford);
38

(John Wade) IBM. (Anne Strachan) .


(Sally Mortimore),
(Martin Klopstock) (Dylan Reisenberger)
. , . ,
(Stephano Ceri)
(Politechnico di Milano); (Larsa Gillberg) , (Mid Sweden University, Oestersund);
. , , (St Mary's University,
Halifax, Canada); - (City
University, London); (Munindar Singh)
(North Carolina State University); (Hugh
Darwen), , (Hursely, UK); (Claude
Delobel), , (Paris, France); (Dennis Murray), Pe, (Reading, UK),
(John Kawala) (Peter Knaggs).
(Kate Brewin), (Stuart Hay)
(Mary Lince) . , ,
. (Richard
Cooper), , (University of Glasgow, UK);
(Emma Eliason), , (University of Orebro,
Sweden); (Sari Hakkarainen),
(Stockholm University) (Royal Institute of
Technology); (Nenad Jukic), , ,
(Loyola University, Chicago, USA); (Jan Paredaens),
, (University of Antwerp, Belgium); (Stephen
Priest), , (Daniel Webster College, USA). , , , .
-
(Malcolm Bronte-Stewart) Dream-Home, '
(Moira O'Donnell) Wellmeadows Hospital,
- (Lyndonne MacLeod),
, (June Blackburn), ,
.
.
.
, 2001

39



, : McGraw-Hill Companies, Inc., New York,
. 18.9,
BYTE Magazine 1997 ; Oracle
; Microsoft.


.
ActivePerl ActiveState Corporation; ActiveX,
Authenticode, BizTalk, FoxPro, FrontPage, Microsoft, MS-DOS, Visual Basic, Visual
Studio, Windows Windows NT Microsoft Corporation;
ADABAS Software AG; Aix, CICS, DB2, DRDA, Encina,
IBM, IMS, Poet, SQL/DS, Systems Applications Architecture, TXSeries WebSphere International Business Machines Corporation; AltaVista
Forte Digital Equipment Corporation; AppleTalk
LocalTalk Apple Computer, Inc.; Archie
Bunyip Information Services; DBase IV Borland
International, Inc.; DECNet Compaq; Delphi, InterBase
VisiBroker Borland Software Corporation; Dreamweaver
Macromedia, Inc.; Enterprise JavaBeans, Java, Java Blend
JDBC Sun Microsystems, Inc.; Excite
Excite, Inc.; GemStone Gemstone Systems, Inc.;
HP Intelligent Warehouse Hewlett-Packard Company;
IDMS, IDMS/R IDMS/SQL Cullinet Corporation;
Informix Informix Corporation; INGRES
Computer Associates International, Inc.; Intersolv Merant Solutions, Inc.; ITASCA IBEX Knowledge
Systems SA; JRun Allaire Corporation; Linux
, (Linus Torvalds); LiveWire Pro
Netscape Netscape Communications Corporation; Lycos
Lycos, Inc.; Model 204 Computer
Corporation of America; Oa 02 Technology;
Objectivity/DB Objectivity, Inc.; ObjectStore
eXcelon Corporation; ObjectPAL Object
Design; ONTOS Ontologic, Inc.; Oracle Object SQL Oracle Corporation; Paradox Corel
Corporation; PowerBuilder Powersoft, Inc.; R:base R:BASE Technologies; ServletExec
New Atlanta Communications, LLC; Simula Simula AS;
Smalltalk Xerox Corporation; Sybase
Sybase, Inc.; Tandem Tandem Computers, Inc.;
TOPLink The Object People, Inc.; Tuxedo Systems, Inc.; UniSQL/M UniSQL, Inc.;
UNIX Open Group; Versant Versant Object Technologies; Yahoo Yahoo, Inc.

40

43
77


...

.
.
.
" ".
"".
.
.
, .
.
.
" , ,
, . 20
, ,
10 .
, , , , ,
.
".
([276], [277])
, , ,
. ,
.
, .
,
. , , , .
, , ,
. , -

, ,
, , , .

, , , .
.

1.1
,
. 1.2 1.3 . 1.4 , , ;
, , . 1.5
, 1.6 .
, DreatnHome,
.
10.4 . , . , .

1.1.
.
. , , (Database Management System DBMS), , .
1.3.


, , -. - , .
. ,
. , , .
44

1.


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


, . -
.
,

. ,
, , . ,
, .


, ,
, , , , ..
,
, . ,
, , .
,
, . ,
,
. -, , . .


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

45

, , , .
, .

Internet

Internet. , ,
Amazon.com. Web-
, , ,
. , Web , , , , , .
, ISBN, , , , ,
, .
, . ,
( ), , , . , Amazon

, , .
,
.
Amazon.com ,
, , , ,
.
, .


,
, , ,
. , , , .

1.2.
, (filebased system). . , ,
.
46

I.

, ,
. , . , ""
,
.
, ,
.
* ,
.

1.2.1. ,
. , '
1
; . - .'.
'.' .

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

?

?
?
?
?
?
1.

47

,
.
, , . , .
. - ,
()
. , Dreamffome.
. , , , . 1.1, ,
, , . ,
,
, . 1.1, .
() . . 1.1-1.3
(PropertyForRent;), (PrivateOwner)
(Client). ,
, ,
.
1.1. PropertyForRent
propertyNo

street

city

postcode

type

rooms

rent

ownerNo

14

16 Holhead

Aberdeen

AB7 5SU

House

650

C046

PL94

6 Argyll St

London

NW2

Flat

400

C087

PG4

6 Lawrence St

Glasgow

Gil 9QX

Flat

350

C040

PG36

2 Manor Rd

Glasgow

G324QX

Flat

375

C093

PG21

18 Dale Rd

Glasgow

G12

House

600

CO87

PG16

5 Novar Dr

Glasgow

G129AX

Flat

450

1.2. PrivateOwner
ownerNo

fName

IName

address

telNo

046

Joe

Keogh

2 Fergus Dr, Aberdeen AB2 7SX

01224-861212

087

Carol

Farrel

6 Achray St, Glasgow G32 9DX

0141-357-7419

040

Tina

Murphy

63 Well St, Glasgow G42

0141-943-1728

Tony

Shaw

12 Park PI, Glasgow G40QR

0141-225-7025

48

I.

DreamHome
Property for Rent Details
Property Number: PG21

DreamHome
Client Details
Client Number: CR74
First Name Mute

Allocated to Branch:

Address 18 Dale Rd

. 163 Main Si, Glasgow


Postcode G12
Type House

Address

Branch No B003
Rent 600

Tel No. 01475-392178

PA 1G 1YQ

Staff Responsible

No of Rooms 5

18 Tain St.

Last Name Ritchie

Property Requirement Del

Ann Bench

Preferred Property Type House Maximum Monthly Rent 750


Owner's Details

General Comments Currently iMag at home with parents


Getting married in August

Name CarolFarrel

Business Name

Address 6AcbraySi,

Address

Seen By Ann Beech

Date 24-Mor-Ot

Branch No 8003

Branch City Gtasgo*

GlasgowG329DX
Tel No. 0141-357-

Tel No.

Owner No. COB

Owner No.

Contact Name
Business Type

. 1.1. : ) ; )

1.3. Client
dlentNo

fName

IName

address

telNo

prefType

maxRent

CR76

John

Kay

56 High St, London


SW1 4EH

0207-774-5632

Flat

425

CR56

Aline

Stewart

64 Fern Dr, Glasgow 0141-848-1825


G420BL

Flat

350

CR74

Mike
Mary

Ritchie

ISTalnStPAlGlYQ 01475-392178

House

750

Tregear

STarbotRd,
Aberdeen AB9 3ST

Flat

600

CR62

01224-196720


.
, , . 1.2.
. , . . ,
. 1.4-1.6. (Lease),
(PropertyForRent) (Client),
.
1.4. Lease
clientNo rent

payment
Method

deposit paid rentStart rentFinish duration

PA14

CR62

650

1300

PL94

CR76

400

Visa
Cash

PG21

CR74

600

Cheque

lease

property

No

No

10024
10075
10012

31-May-02

12

l-Jun-01

800

l-Aug-01 31-Jan-02

1200

l-Jul-01

12

30-Jun-02

1.5. PropertyForRent
propertyNo

street

city

postcode

PA14

16 Holhead

650

6 Argyll St

NW2

400

PG21

18 Dale Rd

Aberdeen
London
Glasgow

AB7 5SU

PL94

G12

600

rent

1.6. Client
clientNo

fName

IName

address

telNo

CR76

Kay

56 High St, London SW14EH

0171-774-5632

CR74

John
Mike

Ritchie

18 Tain St, PA1G 1YQ

01475-392178

CR62

Mary

Tregear

5 Tarbot Rd, Aberdeen AB9 3ST

01224-196720

GO

I.

DreamHome
Lease Details
Lease Number: 10012
Client No. CR74

Property No. PG21

Full Name Mike Ritchie

Address

18 Dale Rd,
Glasgow G12

Address (previous) 18 Tain St.


PA 1G 1YO

Tel No. 01475-392178

Payment Details

Monthly Rent 600

Bent Start Date 1-Jul-01

Payment Method Cheque

Rent Finish Date 3Q-Jun-Q2

Deposit 1200 . Paid (Y or N) Y

Duration

/ Year

. 1.2. Lease Details

. 1.3.
, .
,
.
,
.
. , , :
StaffSalary(staffNo,

fName,

IName,

sex,

salary, branchNo)

, :
S t a f f ( s t a f f N o , fName,
branchNo)

IName, position,

sex, dateOfBirth,

salary,

, , . ,
, . (record), . , PropertyForRent, . 1.1, , .
1.

51

^
- '

|.

.*

. 4'
!
* ~-:
";.;


PropertyForRent {propertyNo, street, city, postcode, type, rooms, rent, ownerNo)
PrlvateOwner (ownerNo, fName, IName, address, telNo)
Client (clientNo, fName, IName, address, telNo, prefType, maxRent)

Lease (leaseNo, propertyNo, clientNo, rent, paymentMethod, deposit, paid, rentStart, rentFinish, duration)
PropertyForRent (propertyNo, street, city, postcode, rent)
Client {clientNo, fName, IName, address, telNo)
. 1..

(field), . . 1.1 ,
PropertyForRent , , .

1.2.2. ,
, , . 1.7.
1.7. ,


, . , , , , "".
Proper ForRent ""
. . -

52

I.


. , .


- ,
, , , , . ,
. 1.3 ,
. .
, .
,
, . .
, . ,
. ,
.
,
, .. , .
, . , ,
, .
. ,
.
, , ,
. ,
.


, . ,
. , PropertyForRent 40 41 , , ,
(.. ,
), PropertyForRent . .. :
1,

53

Proper ForRent ;
;
,
.
;
PropertyForRent;
PropertyForRent.
, PropertyForRent
.
. ,
, , . , PropertyForRent,
. ,
.

(program-data dependence).


, . ,
, COBOL,
, . .
, , ,
. ,
, .
propertyNo ,
PropertyForRent .
ownerNo , PrivateOwner. , COBOL, .

propertyNo PropertyForRent
, . , .

.
.
, .
. -, , 54

!.

(ad hoc) , ,
.
-, . , .
, , ,
, . : ;
. , .. .
,
, .

1.3.

.
1. , .
2. .
,
(database) ,
(Database Management System DBMS).
, .

1.3.1.
. ]
;( ), .
,
. , , ,
. . -
, .
, .

. (system catalog), (data dictionary), (meta-data), .. " 1.

55

".
(program-data independence).
, , , ,
, .
, . , (data abstraction), ,
- , , . ,
.
, , . , . ,
.
, , , " ".
, . (entity) (, ,
), .
(attribute) ,
; (relationship) , . , . 1.4
"-", ER- (Entity-Relationship ER),
DreamHome. :
( ):
Branch
(), Staff (), PropertyForRent (
), Client (), PrivateOwner ( ) Lease ( );
( ): Has (), Offers
(), Oversees (), Views (), Owns (),
LeasedBy ( ) Holds ();
, : branchNo
( ), staffNo ( ), propertyNo
( ), clientNo ( ), ownerKo
( ) leaseNo ( ).
, . , .
"-" 11 12.

1.3.2.
. , , ,
^ . :

56

I.

Has

I. 1
Offers

A
Owns
0..1

. 1.4. "-"

,
.
,
(DDL Data Definition Language). DDL
, ,
.
, ,
,
(DML Data Manipulation Language).
DML ,,- (query language).
, ,
, .

(Structured Query Language SQL),

. (SQL "S-Q-L", "SeeQuel".) SQL : 5, 6 21.
:
,
;

1.

57

, ;
, ;
,
,
;
,
.
. 1.5

(. . 1.3). ,
. , .
.


.
, , , ,
, . . 1.5, , ,
, , . 1.3. ,
, . ""

PropertyForRent,
PrlvateOwner. Client, Lease

Property ForRent (propertyNo, street, city, postcode, type, rooms, rent, ownerNo)
PrivateOwner (ownerNo, fName, IName, address, telNo)
Client (clientNo, fName, IName, address, telNo, prefType, maxRent}
Lease (leaseNo, propertyNo, clientNo, paymemMethod, deposit, paid, rentStart, rentFinish)

. 1.5.

58

I.

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

, .
.
,
. , ,
, .
,
.
.
, Monthly
rent ( ),
rent.

,
, , ,
.
, ,
. , ,
.
. . ,
, ,
. . ,
.
, . ,
. , . ,
, , ..
, , , - , . .
1.

59

1.3.3.
. 1.6, : , , .

. 1.6.


. .
.
, .
,
.
. 1.7
DreamHome. - . (backend), . ,
. (frontend),
.
/ (client-server), , --
. 2.6.


, ,
, .
, , C++, Java, Visual Basic, COBOL, Fortran,
Ada Pascal, , SQL,
. ,
, , , ,
. . 2.2.3.

60

I.

. 1.7. DreamHome

, ( ) . . 1.6
.
, , .. " ".
(schema). . 1.5
., (table): PropertyForRent (
), PrivateOwner ( ), Client () Lease
( ). PropertyForRent , : propertyNo ( ), street (), city (), postcode
( ), type ( ), rooms ( ), rent
( ) ownerNo ( ). ownerNo
PropertyForRent PrivateOwner,
.. (Owns)
"-", . 1.4. , . 1.1 1.2 , 046, Joe Keogh,
14.
, 2.7.
1.

61


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

,
. 1.4.

1.3.4.

, . , . 1.5 :
PropertyForRent, PrivateOwner, Client Lease.
? : .
. ,
, ,
, , .

. .
,
.
, , . ,
, , .
,
. ( 14-17) ,
62

1.

. . , ER-, . 1.4, , .
,
, , .
,
. - .
.
;-
, . , .

1.4.


. : , , .

1.4.1.

, , .

. , {Data
Administrator DA), ,
, ,
,
.
, .
, (Database Administrator DBA), , , , , .
, .
, . 9.15.

1.

63

1.4.2.

:
. {.. ), ,
, .
.
.
DreamHome.
.
.
,
.

. .
, , ,
, .
- ,
: , , -.

, :

;
,

;
.
, . ,
.

. "?",
"?".
, . 14,
15, 16 17.
64

I.

1.4.3.
, . . ,
. , ,
, , , .
, .

1.4.4.
,
, .
.
.
.
, .
, .
,
. , , -.
-,
, ,
,
.
. , . , SQL.
.

1.5.
, .
. . ,
1960- , Apollo .
,
. ,
- , .
North American
Aviation (NAA) ( Rockwell International) GUAM (Generalized Update Access
Method). GUAM ,
1,

65

,
. , ,
(hierarchical structure). 1960- IBM
NAA GUAM,
IMS (Information Management System). ,
IBM IMS , ,
,
, .
. IMS , , .
1960- IDS (Integrated Data Store) General Electric.
(Charles Bachmann).
(network)
,
. , , , .
1965
CODASYL (Conference on Data Systems Languages),
,
List Processing Task Forte, 1967 Data
Base Task Group (DBTG). DBTG
, .
1969 , 1971 . DBTG
.

( ), ,
.
,
.

, .
DBTG .
(Data Definition Language DDL),
.
( DDL),
,
.
(Data Manipulation Language DML),
.

(American National Standards Institute ANSI),
DBTG. CODASYL, DBTG-. CODASYL- 66

I.

. ,
Web- (URL ).
.

.
.
,
1970 . . (. F. Codd), IBM, ,
.
, 1970-1980- . System R,
IBM, -, , 1970- [9].
, . .
SQL,
.
1980-
, DB2 SQL/DS IBM Oracle Oracle Corporation.

,
. INGRES II
Computer Associates Informix Informix Software, Inc. Access
FoxPro Microsoft, Paradox Corel Corporation, InterBase BDE
Borland, R:Base R:Base Technologies.
. 3.
, . . 1976
(Chen) "-" (Entity-Relationship model ER),
, 14 15. 1979
RM/T (1979), RM/V2 (1990).
, ,
(semantic data modeling).

: - , (ObjectOriented DBMS OODBMS), - ,
(Object-Relational DBMS ORDBMS). , , . ,
24-27.
1.

67

1.6.
,
, ,

. 1.8.
1.8.


1.2, ,
. , . 1.3
. , ,
,
.
, .
, . .


.
,
,
68

I.

.
,
, .
, .


. ,
. 1.3
. ,
.
, .
.

,
. . . ,

,
, , .
,
,
/, .

. ,
.. ,
.
. , , 40 000
,
, . , , .

. ,
.
, .
,
.
1.

69

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

.
, ,
, , ,
.
1



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


. ,
,
.
, .

, , .
, , , . ,
, ,
. ,
400 , SQL:
SELECT *

PROM PropertyForRent
WHERE type'Plat1 AND rent>400;

70

I.


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


, .
(, 40 41 ) ,
. : , .
. 2.1.5.
, .


, .
,
.
19.

. ,
.
, , , , .
. 19.3.

, ,
. 1.9.

1.

71

1.9.

,
,
. ,
, , . , .

,
, .


. , 100 .
, , : 100 000 1 000 000 . ,
, .

,
,
. , , , , .
.


.
72

I.

, , .
,
.
, , .


, ,
. , -
.
, .

.
,

.

()
, . , .
, .. ,
, .
. ,
, .
, . ( ),
. , ,
, .
, (Data Definition Language DDL),
,
(Data Manipulation Language DML), , .

.
, , /, . , , .

1.

73

(), (, ), , . , ,
.
. CODASYL . IMS (Information Management
System), (CODASYL-) - IDS (Integrated Data
System). 1960- . ,
. . 1970 ,
. , 100 . - .
, , ,
, , . ,
,
.

1.1.
1.2.

1.3.
1.4.
1.5.
1.6.

1.7.

74

, ,
1,1.
:
) ;
) ;
) ;
) ;
) ;
) ;
) .
, . ?
,
, .
. ?
:
) ;
) ;
) ;
) ;
) ;
) .

?

I.

. |'|1111|1|'111||1'|111|111 ; t ^

1
1.8.

. ?
? ?
1.9. ( , ), ( , , , , ).
.
. ,
, .
, ?
1.10. DreamHome, 10.4 .
? , ,
? ? , , ?
1.11. Wellmeadows Hospital, .
? , ,
?
?

1.

75


...

.
, .

.
.
DDL DML.
.
.
.
.
"/"
.
(
Transaction Processing)
.
( )
,
, . , ,
.
"" ,
, . ,
DreamHome :
" ", staff (), PropertyForRent
( ), PrivateOwner ( )
Client ();
,
(, staff name (), position
() salary ());
(, Staff Manages PropertyForRent).

, ,
, , .

ANSISPARC.
.

2.1 ANSI-SPARC
, . 2.2 , , 2.3
, . 2.4 , , 2.5 2.6
. 2.7
, (.. , ).
DreamHome, 10.4 .
. , , . , , .

2.1. ANSI-SPARC

1971 DBTG.
CODASYL (Conference on Data Systems and Languages ), .
DBTG , , .. (schema),
, .. (subschema). 1975
SPARC (Standards Planning and Requirements Committee) (American National Standard
Institute ANSI), ANSI/X3/SPARC [5]. ANSI/SPARC .
, Guide and Share,
IBM, .

[144]. ANSI/SPARC ,
.

, .. . , , 78

I.

, . 2.1. , ,
(external level),
(internal level). ,
. (conceptual level)

.

.
, .

, .

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

- .
1

\11

. 2,1. ANSI-SPARC

2,

2.1.1.
' . .
, , .
.

. "
", .
, " ", . , , , , .
, -
. ,
(, , ), (, , ). , , . , DreamHome . ,
.
,
.
. 3.4 6.4.

2.1.2.
. ; ,1
, , , .

" ' :";,'"^

.
( ). , . :
, ;
;
;

.
,
, (
) . . , (, 80

I.

) ( ),
, .

2.1.3.
. .
5 , .
.
,
.
( ) , , ..
:
;
( );
;
.
(physical level), , .

. ,
.
(,
, ).

2.1.4. ,
.
,
, . 2.1.
,
. ,
. , , . ,
.
, ' , .
.
2.

81

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

. .
. 2.2. : (sNo), (fName) (iName), (age),
(salary).
(staf fNo), (IMame) ,
(branchNo). . ,
(age) (DOB).
. , sNo
staf fNo .
,
. . (next), . , ,
. ,
.
1

struct STAFF {
intstaffNo,
int branchNo,
charfName [15],
float salary,
struct STAFF 'next,

/* Staff */

index staffNo, index branchNo;

/* */

, 2.2.

82

I.

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

2.1.5.
, ,
. : .
.
^ , -1
.
,
, ,

. , ,
, , , .
.
*! ,
.
,
, , ,
.
. . . 2.3
.
ANSI-SPARC ,
. ANSISE'ARC , . ,
.
2.

83

. 2.3. ANSISPARC

2.2.
^: (Data Definition Language DDL) (Data Manipulation Language DML). DDL
, DML , . , , , .
, , COBOL, Fortran, Pascal, Ada, , C++, Java Visual Basic.
(host language).
,
, . , , . . ,
, .
*

2.2.1. DDL
DDL. , ,
^, , ,
, .
, DDL. DDL , .
.
!.

DDL- ,
, . .. , ,
. , , ,
.
.
, ( ) , .
2.7.

DDL, DDL
, DDL DDL .
DDL,
, , .

2.2.2. DML
DML. , one-j
; .
:
;
, ;
, ;
.
,
, .
, .
, .
, , , .
DML, ,
. ,
.
"" ,
. " " "
" ,
, .
DML . DML: .
, ,
DML,
, . , ,
.
2.

85

DML
DML. , ,
, , .
DML , ,
, .
,
( ),
.
DML , , , ,
, .. , . DML
,
.
DML
( 2.3).

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

SQL (Structured Query Language)
QBE (Query-by-Example).
, . DML, , . SQL 5, 6 21, QBE 7.

2.2.3. 4GL
4GL (Fourth-Generation Language).
, , ,
. 86

I.

(3GL)
COBOL , 10-20 .
,
4GL , ,
, , . , , " ".
, ,
, . , , , .
:
, ;
,
;
,
, , ;
, .
SQL QBE.
.


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



. ,
, .
, ,
. ,
.
2.

87

: .

.
, .


, .
, , ,
..


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

2.3.

,
. . ,
;
, . ,
, . .
.
, , .
" " , . , , . , ,
. , , .
.
88

I.

, .. ,
.
,
( , ).
() , .
. , . 2.1 ANSI-SPARC
:
, ,
(Universe of Discourse UoD);
, ( ) , ;
, , .
.
: (object-based) ,
(record-based) .

, .

2.3.1.
,
, .
( , , ), . , , .
.
"-", ER- (Entity-Relationship model).
.
.
- .
ER- ,
. -
, , ,
, .. . ,
. "-" 11 12, - 24-27.

2.

89

2.3.2.
, .
, .
: (relational data model), (network data model) (hierarchical
data model). ,
.


. ,
. . 2.1 2.2
DreamHome, . ,
. 2.2 , John White 30000 (branchNo)
005, , . 2.1, 22 Deer Rd,
London. , Staff Branch : .
; , , branchNo Staff branchNo Branch.
2.1. Branch
branchNo

street

city

postcode

005

22 Deer Rd
16ArgyllSt

London
Aberdeen
Glasgow

SW1 4EH

Bristol
London

BS99 1NZ

007

163 Main St
32 Manse Rd
56 Clover Dr

8003
004
002

AB23SU
Gil 9QX

NW10 6EU

2.2. Staff
staffNo

fName

IName

position

sex

DOB

salary

branchNo

SL21

John

Manager
Assistant

30000
12000

SG14

David
Mary

Supervisor

l-Oct-45
lO-Nov-60
24-Mar-58

BOOS

SG37

White
Beech
Ford
Howe

Ann

18000

B003

Assistant
Manager
Assistant

19-Feb-70
3-Jun-40
13-Jun-65

9000

B007

24000

9000

BOOS

SA9
SG5

SL41

90

Susan
Julie

Brand
Lee

F
F

i.

, ,
.
, .. ANSI/SPARC. , .
3.


, . ,
, .

. . 2.4
, . 2.1 2.2.
IDMS/R Computer Associates.
Web- (URL
).
005

22Deer.nd

BOQTJ?

16ArgyllSt<::j. Aberdeen!

163 Main St } . Gfasgpv/!>:

su

i. '!!'::!

004

32 Manse Re!'-' jr. "Brtsto('-ii

002

56 Clover Dr-:: ' r::"-l3(Ktofi ' ,'i,.

Julie

Assistant'

' Manager-:

Assi^lant^j
SG37 I

Ann '[ ^Seech [ ..;. j

\1 SG14 j David |
SG5

Susan

Ford
Brand

As'slsta^t'" [; 1)

j ... {supervisor | 15000 |


Manager!

Puc. 2.4.


.
, . .
( )
. . 2.5 , . 2.1 2.2. IMS IBM,
.
Web (URL ).
() . ,
, .
2.

91

BOOS

\~~\1QQ4. L-.
3003 I
SL4i^ j Julie | __lje

;:

.:'J Gtasgw'l

j 007..

1 .;, | ; Asslstant Tj;; /iiQQO

SL21 [ John j While


;

TSG37| Ann_]^'BeeiJl | 7.[ ^ssjstant ; | ; 12


Ford
(~SG5~| Susan | Brano |i; .-J [/24^
;:

SA5 [ Mary | ' Howe ] .;;

Puc. 2.5.

,
.

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

2.3.3.
, , , . , ,
(unifying model) (frame memory).

2.3.4.
,
"" . , .
. 1 .
,
.

92

I.


.
( )

. , , , .
.
.
.
,
. 14 15
, ,
, .
9.6.

2.4.
, .
,
[71]. .

1. ,
| , =
= .
. , 2.1, ,
(, ).

2. ,
, | .
ANSI-SPARC , , .. , ,
, ( ) , ( , "
", ). . :
, ;
;
2.

93

;
, ;
,
(. 2.1,4);
, .
, .
,
, .
, .
, .
, .

.
.
,

, , .
.
.
.
, ,
(data directory),
. " "
. 2.7.

3.
, ;;!:; , ,
,
. DreamHome
, .

.
. , - , ,
94

I.

, .
,
. 19.1.

4.
: , |: - i
. .'
,
.
, , .
,
, ,
. 2 , . 2.3.
2.3. " "

TI

balx

read (bal x )

100

t|
t3

read (bal x )

bal x = bal x + 100

100

tj

bal x = bal x - 10

write (bal x )

200

write (balx)

-s

90
90

: 10 ,
1, 2 100 . , ..
, ,
190 ,
. . , 2
, 100 . 2
100 ( 200 )
. TI 10
( 90 )
,
"" 100 .
,
.
19.2.
2.

95

5.

- .
, . , , . ,
.

. 19.3.

6.

,
.
, &
. , , , .
, .
. , . 18.

7.
-'
.

. .
,
, . (communications messages)
. (DEM Data Exchange Manager).
, , , . ,

. ,
96

!,

, . . 22.1.1.

8.
: , .
. . , ,
,
. , . , ,
. , ,
.
, ,
, .

9.
,
.
2.1.5,
.
, , . .
, ,
, . .

10.
;''

'

.-"'":'

'.-

/"-

...

...;..-.

'.;,

| .

.
, , , ,
.
.
2.

97

,
, ,
.
,
.
, .
,
.

,
.

2.5.
, . ,
. .
, 8.2.2 Oracle.
(),
. , .
, .
, .
. 2.6.
, , , (.. ,
). .
[302], [325], [404] [585].
. 2.6 .
. ,

. 20.
.
.

,
. .
. 2.7.

98

I.

. 2.6.

. . , . ,
.
, ,
( ).
DML. DML- .
DML .
DDL. DDL DDL , . , .
.
. .
,
.
2.

99

. 2.7.
.
.
. .
. , , ,
(, , ).
.
. 20.
.
, .
100

I.

. . , .
.
. , .
. ,
. ( ) ,
.
19.
, , . DAFTG (Database Architecture
Framework Task Group)
1986 .
,

2.6.

, ,
,
"/".

2.6.1.

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

, ,
(, , ).
.
(downsizing), .. , , , , , . :
"/".
2.

101

. 2.8.

2.6.2.
, (). , .
, , . 2.9. ,
.
, .
,
. , , ,

, 163 Main St.
SQL ( 5):
SELECT fName, IName
FROM Branch b, Staff s
WHERE b.branchNo = s.branchNo AND b . s t r e e t =

163 Main St

SQL,
,
Branch () S t a f f (), .
,
.
1. .
2. .
3. , , .

2.6.3. "/"
"/" , . , -

102

!.

. , , , ,
. , .
, . . 2.10 "/", . 2.11
"/".

Hlfllilll

1
I MMI '\

Ni.nir

""1"

. 2.9.
2

~^

SUlJJl !
1

!-^-.

""

()

. 2.10.
"/"
2.

103

2
)

. 2.11. ^
"/":
) ; ) ; &J


, , . ,
SQL , .
, . ,
. ,
, ,
. , . . 2,4.

104

I.

2.4. ,
"/"

.
.
.
, .
, .
. .
.
, .
. , .
.
.
, .. ,
. , , "/"
,
. 22 23.
28.3.2 "/", , .
"/" 2.

105

,
. . , Internet ,
Web-. , .


(). ,
, , ,
(On-Line Transaction Processing OLTP).
,-

.;

-.:.'.

,.:.,..'.,;

-,.;,

"

....".

-..'

-.

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

.

. 2.12. -
"/"

106

!.

. -
, ,
, . , , Oracle 1, Informix 2 IMS
3. -
DTP (Distributed Transaction Processing ) /Open. ,
,
-, .
DTP 22 23.
. - ,
,
. , ,
.
.
. . - ,
, , , . , . ;
, , , .
, -
, . -
, .
- . - .
- CICS Encina
IBM ( IBM
AIX Windows NT, IBM TXSeries),
Tuxedo BEA Systems.

2.7.
2.4 ,
. .
. ,
, .. , " ".
2.

107


. 2.5 , . , ,
. :
, ;
;
, ,
, ,
.
, ,
. :
;
;
, ; .
, " "
, .
, .
, .
- .
, .
.
, - . , .
,
. ,
.
.

2.7.1. IRDS

, ,
. . , , , , CASE-, , .

108

I.

, . , .
. (Information Resource Dictionary System IRDS). IRDS
, , .
, , ,
.
. , IRDS , IRDS- DB2, IRDS-
Oracle DB2.
IRDS
. , - (,
), IRDS
. IRDS
(International Organization
for Standardization ISO) [172], [174].
IRDS
, :
;
;
.
IRDS ,
,
. ,
;
;
/;
.
,
. QBE .
, . (
) . / ,
IRDS- .
IRDS . , , , - .
IRDS , . 2.13.
2.

109

. 2.13. IRDS

ANSI-SPARC : , .
. .
, . ,
, , , .
. , , , ..

. .
.
, .

, .
: DDL
(Data Definition Language) DML (Data
Manipulation Language). DDL , DML .
110

!.

,
, , . : , . , .
"-", , - ,
, .
, ,
, ,
.
,

.
"/" ( ), , . ,
.
(-) ,
, , ,
(On-Line Transaction Processing - OLTP). : , , ,
.
.
" ", . . IRDS (Information Resource Dictionary
System) ISO,
. .

2.1.
2.2.
2.3.
2.4.
2.,5.
26.


.
ANSI-SPARC.
.
?
.
.
, .
2.5 , ? .

2.

111

2.7.

, 2.5.
2.8.
, "/".
, . .
2.9. (-)? (OLTP)?
2.10. .

2.11. , .
, . ?
?
. ?
2.12. ,
. , .
, .
?
2.13. ,
. ,
. , . ,
.
2.14. , 2.13,
"/"?
, ?

112

I.





SQL:
SQL:
QBE
: Access Oracle

115
137
163
211
255
283


...

.
.
.

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

.
15-20 ( 50
),
25%.
,
, . . (. F. Codd) 1970 .
().
()
. () .
. , , , (.. ).

.
.
,
.


, 3.1 -

. 3.2 . 3.3 ,
. 3.4 , , , , .
, 5, 6 21, SQL (Structured Query
Language ), , 7
QBE (Query-By-Example), . 14-17 . ,

. DreamHome, 10.4 .

3.1.
. . (. F. Codd)
1970 "
" [65].
, , , [58]. .
.

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

.
,
.
1970- IBM , , (Astrahan),
"System R",
[9].
.
, , , , , , .
- . , System R :
116

II.

SQL (
"S-Q-L", ()
"See-Quel"), ISO
(International Organization for Standardization) ;
,
1970- 1980- , DB2
SQL/DS IBM, Oracle Oracle Corporation.
,
, INGRES (Interactive GRaphics REtrieval System),
( ) , System R. INGRES

, System R.
INGRES, . INGRES Relational
Technology Inc. ( INGRES II Computer Associates) Intelligent
Database Machine Britton Lee Inc.
Peterlee Relational Test Vehicle IBM, , [305].
, System R INGRES. , , ,
.
1970- - 1980- . , ,
, . Access FoxPro
Microsoft, Paradox Corel Corporation, InterBase BDE
Borland, R:Base R:Base Technologies.
, . , IDMS
Computer Associates, CA-IDMS/SQL
. , , Model 204
Computer Corporation of America ADABAS Software AG,
, , [70], - [294],
[121].
, 24-27, .

3.2.
, . , , , ,
.
, .
3.

117

3.2.1.
. . , .;
,
. ,
, ..
ANSI-SPARC,
2.1.
,
( ),
. .

, ;1 . , , .
, .
, Branch, faranchNo ( ),
street (), city () postcode ( ). Staff (), staff No ( ), fName
(), IName (), position (), sex (), DOB ( ),
salary (), branchNo ( ). . 3.1 Branch Staff. ,
, branchNo .
. .

.
. , . . 3.1
Branch S t a f f . , , .
, ,
.
, . , , . ,
, , (
, ).
. ,
, , .
118

II.

3.1. Branch Staff

branchNo

BranchNumbers

; 4,
1
' ' - '

street

StreetNames

; 25

city

cityNames

; 15

postcode

Postcodes

; 8

fi

Sex

sx

; 1,
1
1
' ' F

DOB

DatesOf Birth

; l-Jan20, dd-mmm-yy

salary

Salaries

; 7 , 6000.00-40000.00

Branch

branchNo

street

city

005
BOOT

004
002

22 Deer Rd
16 Argyll St
163 Main St
32 Manse Rd
56 Clover Dr

London
Aberdeen
Glasgow
Bristol
London

postcode
SW1 4EH

AB23SU
01 1 9QX

BS991NZ
NW106EU

S.

=2

Staff

staffNo fName (Name position


SL21

SG37
SG14
SA9
SG5
SL41

John
Ann
David
Mary
Susan
Julie

White
Beech
Ford
Howe
Brand
Lee

Manager
Assistant
Supervisor
Assistant
Manager
Assistant

sex

DOB

F
M
F
F
F

1-Oct-45
IO-Nov-60
24-Mar-58
19-Feb-70
3-Jun-40
13-Jun-65

salary branchNo
30000
12000
18000
9000
24000
9000

BOOS

007

005

. 3.1. Branch Staff

3.

119

. .
, , . Branch , . , , , .


( (intension)). ,
, . (extension), (state) , .
. ,
,
Branch, . 3.1, , , , . ,
, .. ,
. 1
(unary) ( ).
(binary), (ternary),
- (-).
.
. , .
.
. .
, .
. , .
, , (normalization).
13.


, ,
,
. (file), (records), (fields).
,
. . 3.2 ,
.
1 20

II.

3.2.

3.2.2.

. , , DI D2 ,
D!= {2,4} D 2 = {1,3,5}.
( D2XD2) ,
D l t D2.

, Dlf D3. :
DpOj = { (2,1) , ( 2 , 3 ) , ( 2 , 5 ) , (4,1) , {4,3} , ( 4 , 5 ) }

.
, R, .
R = { (2,1) , (4,1)}

, ,
. , , R ,
1, R :
R = { (,) |xeD 1 ( yeD 2 y=l}
, S, . S :
S = { (,) | x e D 1 ( y e D 2 =2}
:
S = {(2,1)}

.
D l t D2 D 3 > D^xD2xD^
,
, D lt D 2 , D3.
.
:
D! = { ( 1 , 3 ) } , D2 = { ( 2 , 4 ) } D a = { ( 5 , 6 ) }
DiXD^XDa =
{(1,2,5), (1,2,6), (1,4,5), (1,4,6), (3,2,5), (3,2,6), (3,4,5), (3,4,6)}

3.

121

. , . Db D 2 , ..., Dn. :
DiXDzX. . .xD n = { ( d 1 ( d 2 ,

dj l^eD^djeDa, . - . ,d n eD n }

.
-
. ,
, ,
.

3.2.3.
, .
" . ,
.
, 1( :;, ..., D l t D 2 , ..., Dn
{ :D l f A, :D 2 , . . .,A n :D r .}. R, S, . , R n- (A^d^ : 3 2 , . . . ,A n :d r .}, d 1 eD 1 ,d 2 eD 2 , . . . ,dneDr..
- . ,
(d 1 ( d 2 , . . . ,dj , . , ,
.
, . 3.1, Branch branchNo,
street, city postcode . Branch

,
BranchNurnbers, StreetNames ,,
, :
{ ( 0 0 5 , 2 2 Deer Rd,

London,

SW1 4 E H ) }

:
{(branchNo: B005, street: 22 Deer Rd, city: London, postcode: SW1 4EH)}
. Branch , . , . , , .
122

II.

. , . . .
R!, R3, ..., Rn , ( ) R :
R =

Rj. , R 2 , - - . , R n

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

Branch, . 3.1.
, . ,
. ,
, , ,
, ( 13.)
, ,
. branchNo
BranchNumbers , , .
. , (005, 22 Deer Rd, London, SWl 4EH)
.
,
. ,
city postcode, . ,
(, 005 004); .
.
(, )
. ,
. 3.

1 23

.
.

, , .
, .
. ,
-.
, . , .
. , (1, 2)
(2, 1).
, , . , , .
,
. , ,
.

3.2.5.
, .


( ), , .
(superkey). , . .
. ,
, , ,
.
:

. , ,
^ .
R .
. R .
.
.
. , . Branch, . 3.1.
city (, 124
V

II,

).
. , DreamHome , ( branchNo)
( Branch), branchNo . , postcode .
Viewing (),
. (clientNo),
(propertyNo), (viewDate) , , (comment). (clientNo)
. , (propertyNo)
,
. , (clientNo)
(propertyNo)
. clientNo
propertyNo . ,
, (viewDate). , .
,
,
. ,
-, ,
. - , .
" ";
-. , . ,
. 3.1 , Staff IName, .
, White, White
IName .
. , .
-, . , .
, , , . , , . Branch branchNo,
postcode. viewing , clientNo propertyNo,
.
3.

125

. , ";
( , )
..
,
. , branchNo Branch Staff

, it . Branch
branchNo , Staff

, . Staff
branchNo . ,
branchNo Staff , ..
branchNo, (Branch). (
.) , .

3.2.6.
.
DreamHome, , :
Branch (branchNo, street, cizy, postcode)
S t a f f ( s t a f f N o , fName, IName, position, sex, DOB, salary, branchNo}
PropertyForRent (propertyNo, street, city, postcode, type, rooms,
rent, ownerNo, staf fNo, branchNo)
Client (clientNo, fName, IName, telNo, prefType, maxRent)
PrivateOwner (ownerNo, fName, IName, address, telNo)
Viewing (clientNo, propertyNo, viewDate, comment)
Registration (cJlientNo, branchNo, s t a f f N o , dateJoined)

,
( ) .
() .
, , . . 3.3-3.9 .
3.3.
DreamHome. Branch
city

postcode

22 Deer Rd

London

SW1 4EH

16 Argyll St

Aberdeen

AB23SU

163 Main St

Glasgow

Gil 9QX

004

32 Manse Rd

Bristol

BS99 1N2

002

56 Clover Dr

London

NW10 6EU

branchNo

street

005
007

1 26

II.

3.4.
DreamHome. Staff
staffNo

fName

[Name

SL21

John

position

sex

DOB

salary

branchNo

White

Manager

l-Oct-45

30000

BOOS

SG37

Ann

Beech

Assistant

lO-Nov-60

12000

B003

SG14

David

Ford

Supervisor

24-Mar-58

18000

B003

SA9

Mary

Howe

Assistant

9000

B007

Susan

Brand

Manager

1
I

19-Feb-70

SG5

3-Jun-40

24000

BOOS

SL41

Julie

Lee

Assistant

13-Jun-65

9000

BOOS

.5.
DreamHome. PropertyForRent
property

street

city

postcode

type

rooms rent owner staff


No
No

branch
No

14

16Holhead

Aberdeen

AB7 5SU

House

650

C046

SA9

B007

PL94

6 Argyll St

London

NW2

'

400

C087

SL41

BOOS

PG4

6 Lawrence St

Glasgow

Gil 9QX

350

C040

PG36

2 Manor Rd

Glasgow

G32 4QX

Flat

375

C093

SG37

BOOS

PG21

18 Dale Rd

Glasgow

G12

House

600

COS7

SG37

PG16

5 Novar Dr

Glasgow

G129AX

Flat

450

C093

SG14

No

,!.

BOOS

3.6.
DreamHome. Client
clientNo

fName

IName

telNo

prefType

maxRent

CR76

John

Kay

0207-774-5632

Flat

425

056

Aline

Stewart

0141-848-1825

Flat

350

CR74

Mike

Ritchie

01475-392178

House

750

CR62

Mary

Tregear

01224-196720

Flat

600

.7.
DreamHome. PrivateOwner
ownerNo

fName

IName

address

telNo

046

Joe

Keogh

2 Fergus Dr, Aberdeen AB2 7SX

01224-861212

087

Carol

Parrel

6 Achray St, Glasgow G32 9DX

0141-357-7419

040

Tina

Murphy

63 Well St, Glasgow G42

0141-943-1728

093

Tony

Shaw

12 Park PI, Glasgow G4 OQR

0141-225-7025

3.

127

3.8.
DreamHome. Viewing
clientNo

propertyNo

viewDate

comment

CR56

14

24-May-Ol

too small

CR76

PG4

20-Apr-Ol

too remote

CR56

PG4

26-May-Ol

CR62

14

14~May-01

CR56

PG36

28-Apr-Ol

no dining room

.9.
DreamHome. Registration
clientNo

branchNo

staffNo

dateJoined

CR76

005

SL41

2-Jan-Ol

CR56

SG37

11-Apr-OO

CR74

SG37

16-Nov-99

CR62

007

SA9

7-Mar-OO

3.3.
. 2.3,
: ,
, ,
. , .
,
. , ,
, , . . ,
, .

3.3.1.
. , / .
( NULL) "". , , . NULL
. NULL .
,
128

NULL - . NULL , .
" NULL", NULL , , " NULL"
.
, . 3.8 Viewing Comment
, .
NULL - , ,
. -1. , Viewing hasCommentBeenS.upplied ( ) Y (Yes), , N (No)
. .
NULL .
- , , , , , ..
: . NULL
, , [74], [75], [77].
NULL . [77] NULL ,
, , ,
, NULL [87].
.

3.3.2.
. , (. 2.1). 3.4.
.
, , NULL.
, , . , . NULL
, , ,
. , branchNo
Branch, Branch , NULL branchNo.
Viewing,
(clientNo) (propertyNo).
Viewing , NULL clientNo propertyNo, .
3.

129

, . -, , , ? -, ? ,
Viewing (. . 3.8), : "
".
comment. ,
,
NULL ( PG36 PG4 CR56). ,
NULL . [76], [92].

3.3.3.
.
. ,
? !
HULL.
, branchNo Staff ,
branchNo Branch.
025 , Branch , 025.

NULL , .
,
, - .

3.3.4.
. , .
,
. , 20 , ,
, s t a f f
, 20 .
,
. 6 16.
130

II.

3.4.
2 ANSI-SPAKC . "" (view)
.
, (virtual relation), .. , ,

(, ). ,
( ) , ,
. , , . 6.4
SQL.

3.4.1.
, ,
.
I . ,
),"; , .
.
. ,
-^ .; . ,
, . f -

'

'

. - " -

'

,.

''.'-.

"

'

,

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

3.

131

3.4.2.
.
,
.
- , .

,
.
. ,
(. 4.1),
, .
,
, . .
Branch , ,
. Branch Staff Manager.
s t a f f
salary.
, , ( branchNo)
(Branch Number),
.

, .
, (. 2.1.5).
, . ,
, , . ,
,
. 6.4.7,
.

3.4.3.
, . ,
. ,
132

II.

, . , .
, .
, .
, .
:
, .
[119].

Y^-IHIHfHRBH


, 15-20 (50
),
25%.
;
, . . .

.
.
- ,
.
, , , ,

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

3.

133

(NULL) , .
,
. ,


, NULL.
, () . ,
. .
[
3.1.

3.2.
3.3.
3.4.
3,5.

3.6.
3.7.

:
) ;
) ;
) ;
) ;
) ;
) .
?
.
?
.
. " "?
? , .
, .
? .

,.,.
.
Hotel

(hotelNQ, hotelName, city)

Room (roomNo, hoteINg, type, price)


Booking (hotelNo, guestNo, dateFrom, dateTo, roomNo)
Guest (gueatNo, guestName, guestAddress)

134

II.

Hotel ,
hotelNo . Room , (roomNo, hotelNo)
. Booking ;
(hotelNo, guestNo, dateFrom). , Guest
, guestNo.
3.8. . ,
,
3.9.
,
.
, .
. , . , , ,
.
3.11. ,
. , , .

3.

135

...

" ".
.
.
.
(Data
Manipulation Language DML).

. 2.3, ( ),
.
, . ,
, [66J . () , ,
. , , ,
, , . , , , .. ( ).
, .
. , , .

. ,
,
.
. , , ,
, .


4.1 ,
4.2 : . 4.3 .
DreamHome, . 3.3-3.9.
5, 6 21 SQL (Structured Query Language
)
,
. 7 QBE (Query-By-Example
), , .

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

, , ,
.
, , , ,
,, . .
. [404].
,
. [67] ,
. , (selection), (projection),
(cartesian product), (union)
(set difference),
, . , (join), (intersection) (division),
.
. 4.1.
,
. ,
. R
S , = { 1( , . . ., )
= (bj, 2 , . . ., ) .
138

II.

ffxfi

a
a

RDS

RUS

1
2
3
1
2
3

-S

.*; s

7-

) ) )

b
b

) ( )

V+W

1
2
1
2
1

. 4.1.

4.1.1.

: .
4.

139

( )
0^()- R
, ()
R, ().

4.1.
, 10000 .
" s a l a r v a l Q Q Q O \ t )

s t a f f , salary>!0000. , s t a f f ,
salary 10000 . . 4.1. (AND), v (OR) - (NOT).
4.1. Staff
salary > 10000
position

sex

DOB

salary

branchNo

White

Manager

l-Oct-45

30000

BOOS

Beech

Ass .slant

10-Nov-60

12000

B003

Ford

Supervisor

24-Mar-58

18000

BOOS

Brand

Manager

3-Jun-40

24000

BOOS

staffNo

fName

IName

SL21

John

SG37

Ann

SG14

David

SG5

Susan

-.,. .J[R).

; R ! , R,
" . -.

4.2,

staffNo, fName, INametf salary.

n.t af Ha,fName,IName,salary ( S t a f f )
,
s t a f f N o , fName, IName salary S t a f f ,
. . 4.2.

140

II.

4.2. Staff staffMo, fName, IName salary


staffNo

fName

IName

salary

SL21

John

30000

SG37

Ann

White
Beech

12000

SG14

David

Ford

18000

SA9

Mary

Howe

9000

SG5

Susan

Brand

24000

SL41

Julie

Lee

9000

4.1 .2.
.
. , , , .

. '' , :
<_ , R, S, R -*;
, . R s .
R S , , / J , , ,
(/ + J) . ,
, .. ,
.
, . ,
,
.
.

I 4.3.
,
.
n c i t i P (Branch) uFIcity (PropertyForRent}
, Branch
PropertyForRent city, . .
. 4.3.

4.

141

4.3. , city Branch


PropertyForRent

city
London
Aberdeen
Glasgow
Bristol

' R-S. R s ,
R, s. R s
; .

4.4.
, ,
, .
' '
n c i t y (Branch) - 1 ( PropertyForRent)


Branch PropertyForRent,
city.
.
. 4.4.
4.4. , city Branch
PropertyForRent
city
Bristol

R n S. , , R, s. R s
.. .

4.5.
, ,
, .
n c i E y (Branch) n n city (PropertyForRent)

142

II.

, Branch PropertyForRent, city.



. . 4.5.
4.5. , city Branch
PropertyForRent
city
Aberdeen

London
Glasgow
:
R n S - R - (R - S)


.ftxS. ,
;' (.. ) , R s.
. , . ,
/ N , J , (/ J)
(* + ) . . , .

4.6.
, ,
.

Client,
Viewing. , :
(n c ii e n tNo,fName,lName ( C l i e n t ) ) X (n c l i e n C N O ,propertyNo, comment ( V i e w i n g ) )

. 4.6.
, . ,
clientNo.
,
Client .clientNo=Vlewing.clientNo. ,
.
4.

143

Client .ciientNo=Viewing.clientNc ( ' ' -IclientHo, fNarae, IName I*-

> ' 'clientHo,propert;yNo, comment

(Viewing))}

. 4.7. , .
4.6. Client
Viewing ( )
Viewing .client
No

property

Kay

CR56

PA14

Too small
( )

John

Kay

CR76

PG4

Too remote
( )

CR76

John

Kay

CR56

PG4

CR76

John

Kay

CR62

PA14

CR76

John

Kay

CR56

PG36

CR56

Aline

Stewart

CR56

PA14

Too small
( )

CR56

Aline

Stewart

CR76

PG4

Too remote
( )

CR56

Aline

Stewart

CR56

PG4

CR56

Aline

Stewart

CR62

PA14

CR56

Aline

Stewart

CR56

PG36

CR74

Mike

Ritchie

CR56

PA14

Too small
( )

CR74

Mike

Ritchie

CR76

PG4

Too remote
( )

CR74

Mike

Ritchie

CR56

PG4

CR74

Mike

Ritchie

CR62

PA14

CR74

Mike

Ritchie

CR56

PG36

CR62

Mary

Tregear

CR56

PA14

Too small
( )

CR62

Mary

Tregear

CR76

PG4

Too remote
( )

CR62

Mary

Tregear

CR56

PG4

CR62

Mary

Tregear

CR62

PA14

CR62

Mary

Tregear

CR56

PG36

Client. client

fName

IName

CR76

John

CR76

No

144

comment

No

No Dining room
( )

No Dining room
( )

No Dining room
( )

No Dining room
( )

II.

4.7.
Client Viewing ( )
Client. clientNo

fName

I Name

Viewing .clientNo

propertyNo

comment

CR76

John

Kay

CR76

PG4

Too remote
( ]

CR56

Aline

Stewart

CR56

PA14

Too small
( )

CR56

Aline

Stewart

CR56

PG4

CR56

Aline

Stewart

CR56

PG36

CR62

Mary

Tregear

CR62

PA14

No dining room
(
)


. .

, (<).
;
< , . ,
:
TempViewing(clientNo, propertyNo, comment) < , lierit.No, propertyNo,
*^ (Vie wing)
TempClient(clientNo, fName, iName) ^- ri clientNo , fNatne , 1Naroe (Client)
CommentfclientNo, fName, IName, vclientNo, propertyNo, comment) <
TempClient X TempViewing
Result 4- (

vciincHc.(Comment)


( ""), .
.
ps(E) pS(,1,...,.n)(E).
; s ,

4.1.3.
,
, .
4.

145

. . ,
- , , .

, , .
20.4.3.
,
.
- (theta join).
(equijoin),
-.
(natural join).
(outer join).
(semijoin).

-
R >-^ S. - ,
;.- R s, pv ? .aj.0s.bi,
(<, <, >, >,~=).
-
, .
R X F S=0 F (RXS)

, - R S. F (=), (equi-join). , 4.6 (. 4.7).

I 4.7.
, ,
.

4.6
. .
(n c l i e n t K O i t t - a r a e i i H a m a (Client) )
^Client.clientNo.Viewing.clientNo U elienl:No, propereyNo, comment (Viewing) }

146

II.

R e s u l t s TetnpClient x Tempciient.ciientNo.Tempviewing.ciientNo TempViewing


. 4.7.

R txi S. '*
R S, ,
i .
R S .

4.8.
, ,
.
4.7 , clientNo.
.
' c l i e n t N o , IName.lNarne ( C l i e n t ) )

(I l c li*ncHo,propertyKo, coraraent \ ' ^-SWing) )

Result*- TempClient x TempViewing


. 4.8.
4.8. Client
Viewing ( )
clientNo

fName

IName

propertyNo

comment

CR76

John
Aline
Aline
Aline
Mary

Kay

PG4

Stewart.
Stewart
Stewart
Tregear

PA14

Too remote ( )
Too small ( )

CR56
CR56
CR56
CR62

PG4

PG36
PA 14

No dining room { )


, . , .
, , . .

4.

147

, R ix S. ,
R, : s.

NULL. , ,
SQL (. 5.3.7).
, , .. ,
.

4.9.
.

, (
), , . .
(n c l i e n c N o , B t r e e t ,ci C y (PropertyForRent) ) = Viewing
. 4.9.
4.9. PropertyForRent Viewing
propertyNo

street

city

clientNo

viewDate

comment

PA14

16 Holhead

Aberdeen

CR56

24-May-Ol

Too small (
}

PA14

16 Holhead

Aberdeen

CR62

14-May-Ol

No dining room (
)

PL94

6ArgyllSt

London

NULL

NULL

NULL

PG4

6 Lawrence St

Glasgow

CR76

20-Apr-Ol

Too remote (
)

PG4

6 Lawrence St

Glasgow

CR56

26-May-Ol

PG36

2 Manor Rd

Glasgow

PG21

18 Dale Rd

Glasgow

CR56
NULL

NULL

NULL

Glasgow

NULL

NULL

NULL

PG16

5 Novar Dr

28-Apr-Ol

, 4.9 ,
. , , . ,
,
NULL.

148

II.


R >F S- , R, R s.
, , . (. 22.4.2 23.7.2). :
R >F S = { XF S)

R.
-, , .

4.10.
, ,
, 'Glasgow1,
Staff, , , . 4.10.
^stafE.branchNo-branch.branchNo and branch, city - 'Glasgow 1

4. 10. Staff Branch


staffNo

fName

IName

position

sex

DOB

salary

branchNo

SG37

Ann

Beech

BOOS

Ford

10-Nov-60
24-Mar-58
3-Jun-40

12000

David
Susan

Assistant
Supervisor
Manager

SG14

18000

B003

24000

BOOS

SG5

Brand

M
F

4.1.4.
,
. , R , S , (.. ). -, ..
R,
S.
.
R + S, R,.;
,
I s.
4.

149

:
!<-()
T 2 <-n c ({SxT 1 )-R)

4.11.
,
.
, ,
.
, . 4.11-4.13.
(ncLientto,pr0pertyNo (Viewing) )-(>.3 (ProperCyForRent) ) )
4.11. nctentNOipropertvNo{Viewing)
Viewing
clientNo

propertyNo

CR56

14

CR76

PG4

CR56

PG4

CR62

14

CR56

PG36

4. 1 2.
PropertyForRent
clientNo
PG4

PG36
4.13.

clientNo
CR56

4.1.5.
. 4.14.

150

I I .

4.14.


,
() R,
()

....... (R)

RuS

R-S

RnS

,
R,

-
,
, R, S,
R ,
. R s

R s ,
R. s.
R s

, ,
R, S.
R S

RxS

,
(.. )
R S

Rixi F S

,
R S,
F

R><]FS

,
R S,
F (
)

RixiS


R s,
,

, R,
s,

()

R>FS

,
R, R s
,
R, ,
s,
, R,
s

4.

151

4.2.
, . ,
, , .

,
, .
: [67] [202] .
( ) .
, , . ,
" " "
, " ,
. ''
" (" "),
" , " (" " " ").
, " ", .
, . ,
" ",
" " .
,
, .
, , , :
{ ( ) }

(AND), v
(OR) ~ (NOT) .

4.2.1.

, .
. ,
. ,
. ( " "
, , .)
, Staff
S :
152

II.

Staff(S)
, " S, F ( S ) " :
(S|F(S)}

F ( ,
Well-Formed Formula, WFF). , " s t a f f No, fName, IName, position, sex, DOB,
salary branchNo ,
10 000 " :
{SJStaff(S)

S . s a l a r y > 10000}

S. salary salary
S. (, salary),
:
{ S . s a l a r y [ S t a f f ( S ) ' . s a l a r y > 10000}


,
, . (3), "", , , :
S t a f f (S) {} (Branch(B)
.city='London')

(.branchNo=S.branchNo)

, Branch , branchNo,
branchNo S S t a f f , city
' London'. (V), " ", , , :
(VB)

(.city * 'Paris')

, Branch city ' P a r i s ' .


:
() ( F ( X ) ) ^ ~ ( V X ) ( ~ ( F ( X ) > >
tVX) ( F < X > ) = ~<3X) ! ~ ( F ( X ) }}
OX) ( F a ( X )
(VXHF^X)

E F2(X)>
= F2{X))

= ~(VX) ( - ( F i t X ) )

v ~{F2(X)>)

= -OX) ( - ( F i t X ) )

v~{F2(X)J)

:
~()(.city ='Paris')
, .
, V 3; . , 4.

153

, (|). , S
S S t a f f .
{S.fName, S.IName | Staff (S) ()
S.branchNo) .city = ' L o n d o n 1 ) }

(Branch(B) (B.branchNc =


, ,
.
.
:
{Si.aj,

S 3 .a 2 , ...,

S n .a n

F(SL,

S2

, SJ } ;

ra>n

S 17 S2,..., S n ,. . ., Sm , a^ ,
Si, a F
( )
,
.
R ( S i ) , Sj , a R .
Si.! 9 Sj.a 2 , Si Sj , ! ,
S i T 2 , Sj, 6 (<,
<> >, >, =, *); ^ , 9 .
S i - a j 9 , 3 , , Sit ! 6 .
.
.
F! F2 , ,
(Fi/\F2), (FjVFjj)
(-Fi), .
F X, () (F) (VX) (; .

4.12.
. , 25000 .
(S.fName,S.IName|Staff(S)5.position='Manager'.salary>25000}
. ,
.
{S S t a f f ( ) ( ) ( P r o p e r t y F o r R e n t ( ) ( P . s t a f f N o = S . s t a f }
P.city='Glasgow1)}
154

II.

staf fNo PropertyForRent , .


: " , , PropertyForRent , , city
'Glasgow'".
,
, . : " PropertyForRent, city 'Glasgow',
Staff". ,
, .
, ,
.
{5.fName,S.IName|Staff(S) (~ ()(PropertyForRent(P)
(S.staffNo=P.staffNo)))}

, :
{S.fName,S.IName|Staff(S){(Vp)(-PropertyForRent(P)v

~(S.stafNo=P.staffNo)))}
, , .
(C.fNarae,C.lName|Client()((3V)()(Viewing(V)
PropertyForRent(P} (C.clientNo=V.clientNo)
(V.propertyNo=P.propertyNo) P . c i t y = ' G l a s g o w ' } ) }

, ", 'Glasgow'",
", Viewing
' Glasgow' ".
, , ,
.
{.city|Branch(){-()(PropertyForRent(P).city=P.city))}

,
4.4.
. , ,
.

{.city]Branch()(()(PropertyForRent(P).city=P.city))}
,
4.5.
. , ,
.

4.3
. , ,
, 4.

155

. , , Branch, PrcpertyForRent (
).
, , ,
. ,
,
.


, ,
. , , , S t a f f :
{S|-Staff(S)}

. , ,
, ,
;
dora(E). , ,
. ,
, S t a f f .
, , , .
, , Staff (.. ,
). ,
, . ,
, RANGE.
[93].

4.2.2. "
,
. , , , .
:
{di, d2

d, I F t d i , d2

dj);

m > n

dj, d2,..., dn,..., dm (), a F{d 1 (


d2, . .., dj .
, .
156

II.

R (d l 7 d 2 , . . . , d n ) , R di .
di dj, di dj 9
(<, < >, >, =, ?*); di dj ,
0 .
di 9 , d t , di 9 .
.
.
F2 , ,
(] ), (F^yF;,)
(~Fj), .
F^ X, () (F) (Vx) ( F ) .

4.13.
:
(3d1( d2

d n ) (3d,) ,

(3d 2 ) ,

(3dJ

. , 25000 .
{ f N , IN J (3sN, posn, sex, DOB, sal, b N ) ( S t a f f ( s N , f N , IN, posn,
sex, DOB, sal, bN} posn = 'Manager' sal > 2 5 0 0 0 ) }


, 4.12, , , (). Staff (sN, fN, . . ., bN} ,
.
posn = 'Manager'
Staff .position = 'Manager'. .
posn
s t a f f
Staff {posn). ,
posn
, , Staff (sN, fN, IN,
posn, sex, DOB, sal, bN),
position, s t a f f .
, ( posn sal).
, ,
.
{sN, f N , IN, posn, sex, DOB, sal, bN |

{3sNl, cty)

( S t a f f { s N , f N , IN, posn, sex, DOB, sal, bN)


PropertyForRent(pN, st, cty, pc, typ, rras, rnt, oN, sNl, bNl}
( s N = sNl) cty = ' G l a s g o w ' ) }
4.

157

:
{sN, f N , IN, posn, sex, DOB, sal, bN |
( S t a f f ( s N , f N , IN, posn, sex, DOB, sal, bN}
1
PropertyForRent (pN, st, 'Glasgow , pc, typ, rms, rnt, oN, sN, b N l ) ) }

cty PropertyForRent
'Glasgow', sN,
, Staff,
PropertyForRent.
. ,
- .
{fN, IN | (3sN) { S t a f f { s N , f N , IN, posn, sex, DOB, sal, bN} (~ (BsNl)
(PropertyForRent(pN, st, cty, pc, typ, rms, rnt, oN, sNl, bNl)
(sN = s N l ) ) ) ) }
. , .
. { f N , IN |

(3cN, cNl, pN, pNl, Cty}

(Client(cN, fN, IN, tel, pT, mR) Viewing(cNl, pNl, dt, crat}
PropertyForRent(pN, st, cty, pc, typ, rms, rnt, oN, sN, bN)
[cN = cNl} {pN =. pNl) cty'= 'Glasgow')}
. , ,
.
{cty | (Branch(bN, st, cty, pc) ( ~ ( B c t y l J
(PropertyForRent(pN, stl, ctyl, p e l , typ, rms, rnt, oN, sN, bNl)
(cty = c t y l } ) ) }
E , ,
.
{cty | (Branch(bN, st, cty, pc) (3ctyl)
(PropertyForRent(pN, st1, ctyl, pel, typ, rms, rnt, oN, sN, bNl)
(cty = c t y l ) ) }
. , ,
.
{cty | {Branch(bN, st, cty, pc) v
PropertyForRent(pN, stl, cty, pel, typ, rms, rnt, oN, sN, b N ) ) }

, ,
, , , ,
, . , ,
.
1 58

II.

4.3.

,
,
.
: .
,
. . SQUARE [37], SEQUEL [53] ,
SQL. SQL 5, 6 21.
.
,
. QBE (Query-By-Example)
[331]. 7.

(Fourth-Generation Language 4GL),
, (. 2.2 ). , ..
, (Fifth-Generation Language 5GL).
.

,

, . , ,
. , ..
( ).

. , ,
, . , , , , ,
, .
,
, : , , , . , , ,
.
4.

159

, . : .
,
. , , , , .

, .
( ).
, , ,
.

4.1.
4.2.

4.3.
4.4.

4.5.
4.6.
4.7.

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

Hotel,
3.
4.8.

, :
) 1{1 (Room) )
) O H otel.hotelNo - Room.hotelNo ( I ! o t e l

) llhotelName (Hotel

160

Room)

<Hotel.hotelNo = Room.hotelNo (^price >

5 0 (RoOTTl)

) )

I E .

) Guest =><
) Hotel
&J

(odateTo > -i-jmn-aooi- (Booking) )

> H otel.hotelNo - Room.hotelNo (O"price > 50 (Room) )

1'guestName, hoCelNo (BOOKing

^Booking .guestNo Guest .guestNo

GUSt)

-S-

flhotelNo (Ocity > 'London' (Hotel) )

, 4.8.
4.10. , :

4.9.

) {H.hotelName | H o t e l ( H ) A H . c i t y = ' L o n d o n }
) {H.hotelNarae | H o t e l ( ) (3R)
R.hotelNo R . p r i c e > 5 0 ) }

(Room(R) H.hotelNo =

) {H.hotelName J Hotel (H) () (3G) (Booking(B) G u e s t ( G )


H.hotelNo = B.hotelNo B.guestNo = G.guestNo
1
G.guestNarae = 'John S m i t h ) }
r) {H.hotelName, G.guestName, Bl.dateFrom, B2.dateFrom |
Hotel(H) Guest(G) Booking(Bl) Booking(B2) H.hotelNo =
Bl.hotelNo G.guestNo - Bl.guestNo B2.hotelNo = Bl.hotelNo
B2.guestNo = Bl.guestNo 2. dateFrom Bl. dateFrom}

4.11.
,
4.10.
4.12. ,
,
) .
6} 20
.
) ,
.
) Grosvenor
.
) ,
Grosvenor.
) Grosvenor
, ,
, .
) Grosvenor
( guestNo, guestName guest Address).
4. ,
Grosvenor, . ?
4.14. ,
.
? , ,
4.1.
4.

161

SQL:

...

Structure Query Language (SQL)


.
SQL.
SQL.
SELECT.
SQL,
:
WHERE ,
;

ORDER BY;

SQL;
GROUP BY;
;
;
(UNION, INTERSECT, EXCEPT).

INSERT, UPDATE
DELETE.
3 4
. , , Structured Query Language (SQL),
.
SQL (ANSI)
1986 , 1987 (ISO)
[170].
SQL ,
,
.
, SQL ,
, ,

, , -

, .
SQL,
ISO. -
.
, SQL .


5.1 SQL ,
. 5.2 , SQL. 5.3 SQL, , .
6 SQL,
, , .
21 SQL
: , SQL . 27.4
, SQL -
( SQL3). SQL . ( ),
4.

SQL. SQL
, 4.
. 3.33.9 DreamHome.

5.1. SQL
SQL,
, .

5.1.1. SQL

:
;
,
, ;
.
, ,
. , , , .. ,
164

II.

. SQL .
SQL , ,
. SQL, ISO,
:
DDL (Data Definition Language),
;
DML (Data Manipulation Language),
.
SQL3 SQL
; -
. , IF ... THEN ...
ELSE, GO TO, DO ... WHILE ,
.
( ) ( , ).
( )
SQL . ,
SQL. SQL , 21. SQL3, 1999 , 27.
SQL .
, , , . , SQL ,
, SQL
. , .
,
, CREATE TABLE ( ), INSERT (), SELECT (). :
CREATE TABLE S t a f f ( s t a f f N o VARCHAR(S),
salary D E C I M A L ( 7 , 2 ) ) ;
INSERT INTO Staff VALUES

('SG16',

IName V A R C H A R ( 1 5 ) ,

'Brown', 8300);

SELECT staffNo, IName, salary


FROM Staff
WHERE salary > 10000;

SQL ,
(), ,

.
SQL [173],
[176], , .

5. SQL:

165

5.1.2. SQL
3, (
SQL) 1970 . .
( IBM
-). 1974 . , , , "Structured English Query Language",
SEQUEL. 1976 ,
SEQUEL/2; SQL
SEQUEL - .
- SQL "", "--".
1976 SEQUEL/2 IBM
, "System R" [9]. . ,
SQL,
SQUARE (Specifying Queries as Rational Expressions), System R. SQUARE
, [37].
1970- , ,
Oracle, Oracle. , , SQL.
INGRES, QUEL.
, SQL,
. , SQL
, INGRES . 1981 IBM
SQL/DS (
DOS/VSE). 1982 VM/CMS,
1983 MVS, DB2.
1982 (ANSI) RDL (Relation Database Language), , IBM. 1983
(ISO). SQL.
( RDL 1984 , SQL.)
, ISO 1987 ,
. , ,
, , , .
,
[89], [90], [92].
, . ,
(
, , ), , ,
.
1989 ISO , [171]. 1992 166

II.

, ISO,
SQL2 ( SQL-92) [173]. ,
SQL.
, SQL3 [176],
1999 .
- ,
27.4.
, , . ,
SQL , . . .
,
, ISO.
,
, SQL,

. SQL .
SQL IBM,
.
, SQL, ,

5.1.3. SQL
SQL , .
, NDL (Network
Database Language),
CODASYL, .

SQL SQL, , , , . SQL
, .
(, System Application Architecture
(SAA) IBM),
(, /Open,
UNIX), SQL
(Federal Information Processing
Standard FIPS), . SQL Access
Group SQL,
.
SQL
. ISO "Information Resource Dictionary System"
(IRDS) (. 2.7.1) "Remote Data Access" (RDA). ,
, 5. SQL:

167

. , .
SQL, , OnLine Analytical Processing (OLAP).

5.1.4.
ISO SQL , , , , . SQL
ISO. , , SQL ,
3. , SQL ,
SELECT
,
, .

5.2. SQL
SQL ,
SQL. SQL ,
, . SQL .
, ,
. , , (
)
, , , .. . , SQL , ; ,
(;).
SQL .
, , .
, , , . ,
' S M I T H 1 ,
' Smith 1 , .
SQL , SQL

. .
.
,
.
-:: ,
, .
SQL BNF
(Backus Naur Form -).
168


, .
,
.
( ) , a
b | .
, {}.
, [].
( . . . )
,

{ } [ , . . . ] . ,
, .
( )
DDL, DML.
DML DDL.
DML . DDL .

5.3.
SQL DML:
SELECT ;
INSERT ;
UPDATE ;
DELETE .
SELECT
DML, SELECT .
,
, , ,
. INSERT, UPDATE DELETE SQL.
SQL
DreamHome, . 3-33.9. DreamHome :
Branch
Staff

(branchNo, street, city, postcode)


(sjiajE f No, fName, IName, position, sex, DOB, salary,
branchNo)
PropertyForRent (propertyNo, street, city, postcode, type, rooms,
rent, ownerNo, s t a f f N o , branchNo}
Client
(clientNo, fName, IName, telNo, prefType, maxRent)
PrivateOwner
(ownerNo, fName, IName, address, telNo)
Viewing
(clientNo, propertyNo, viewDate, comment)

5. SQL:

169


DML, , , "".
, SQL.
, SQL
( 6.1.1).
, ,
, . , .
.
INSERT INTO PropertyForRent(propertyNo, street, city, postcode,type,
rooms, rent, ownerNo, staffNo, ranchNo)
1
1
1
1
V A L U E S ( ' P A 1 4 ' , 46 Holhead , 'Aberdeen , 'AB7 5SU , 'House , 6 ,
1
1
650.00, 'C046 , 'SA9 , ' B 0 0 7 ' ) ;
rooms ,
rent .
. .

5.3.1.
SELECT . , ,
, (. 4.1), . SELECT
SQL. SELECT :
^SELECT [DISTINCT; [ ALL] .{ * I

[columnExpression IAS newName]]

[,'...'}'}

"FROM TaJbleWame '{alias] [ , . . - ]


. [WHERE condition].,
,v [GROUP BY columnwise] [HAVING condition]
: ; QRDER'BY columnList] '
columnExpression . TableName ( ), . a l i a s , TableName. SELECT
.
FROM. .
WHERE. .
GROUP BY. ,
.

170

HAVING.
.
SELECT. , .
ORDER BY. .
SELECT .
SELECT FROM ,
.
SELECT , ,
(. 4.1). , .


5.1.
.
,
WHERE. ,
. :
SELECT staffNo, fName, IName, position, sex, DOB, salary, branchNo
FROM S t a f f ;

, SQL " " - (*).
:
SELECT *
FROM Staff;

. 5.1.

5.1. 5.1
position

sex

White

Manager

Ann

Beech

Assistant

David

Ford

Supervisor

SA9

Mary

Howe

SG5

Susan

Brand

SL41

Julie

Lee

staffNo

fName

IName

SL21

John

SG37
SG14

DOB

salary

branchNo

l-Oct-45

30000.00

BOOS

lO-Nov-60

12000.00

BOOS

24-Mar-58

18000.00

BOOS

Assistant

19-Feb-70

9000.00

B007

Manager

3-Jun-40

24000.00

BOOS

Assistant

13-Jun-65

9000.00

BOOS

5. SQL:

1
171

5.2.

( staffNo), , .

SELECT staffNo, fName, IName, salary


FROM S t a f f ;
Staff ,
staffNo, fName, IName salary,
.
. 5.2. , . ,
(,
Microsoft Access staffNo).
.
5.2. 5.2
staffNo

fName

IName

salary

SL21

John

White

30000.00

SG37

Ann

Beech

12000.00

SG14

David

Ford

18000.00

SA9

Mary

Howe

9000.00

SG5

Susan

Brand

24000.00

SL41

Julie

Lee

9000.00

5.. DISTINCT
, .
SELECT propertyNo
FROM Viewing;

. 5.3. , , , (.
4.1.1), SELECT
.
DISTINCT. :
SELECT DISTINCT propertyNo
FROM Viewing;

. 5,4.

172

II.

5.3.
5.3

5.4.
5.3
propertyNo
14

PG4

PG36

5.4.
,
, .
SELECT s t a f f N o , fName, IName, salary/12
FROM S t a f f ;
5.2, ,
, . 12. . 5.5.
5.5. 5.4
staffNo

fName

IName

co!4

SL21

John

White

2500.00

SG37

Ann

Beech

1000.00

SG14

David

Ford

1500.00

SA9

Mary

Howe

750.00

SG5

Susan

Brand

2000.00

SL41

Julie

Lee

750.00

( , ).
SELECT SQL.
5. SQL:

173

, , . .
, , , .
, , !4. . , SQL
. SQL
(, !4),
, SELECT. ISO
,
AS. SELECT
:
SELECT staffNo,
FROM S t a f f ;

fName,

INarae, salary/12 AS month!ySalary


monthlySalary, col4.

( WHERE)
SELECT
.
,
.
WHERE. WHERE, , ,
. ( , ISO).
. .
. ,
.
. ,
.
. , .
NULL. , NULL
( ).
WHERE ,
4.1.1. .

174

II.

5.5.
10 000
.
SELECT s t a f f N o , fName, IName, position, salary
FROM Staff
WHERE salary > 10000;
Staff salary > 10000.
,
Staff, salary 10 000 . . 5.6.
5.6. 5.5
staffNo

fName

IName

position

salary

SL21

John
Ann

SG14

David
Susan

White
Beech
Ford
Brand

Manager
Assistant
Supervisor
Manager

30000.00

SG37
SG5

12000.00
18000.00
24000.00

SQL , . 5.7.
5.7.

!<

>=

( ISO)
( )

AND, OR NOT, , ( ).
.
.
.
NOT AND OR.
AND OR.
.
5. SQL:

175

5.6.
.
SELECT *
FROM Branch
1
1
WHERE city = 'London OR city = ' G l a s g o w ;

,
(city = 'London') (city = 'Glasgow'),
WHERE OR.
. 5.8.
5.8. 5.6
branchNo

street

005

002

city

postcode

22 Deer Rd

London

SW1 4EH

163 Main St

Glasgow

Gil 9QX

56 Clover Dr

London

NW106EU
1

5.7. (BETWEEN/NOT BETWEEN)



20 000 30 000 ,

SELECT staffNo, fName, IName, position, salary


FROM Staff
WHERE salary BETWEEN 2 0 0 0 0 AND 3 0 0 0 0 ;

BETWEEN .
20 000 30 000 . . 5,9.
5.9. 5.7
staffNo

fName

IName

position

salary

SL21

John

White

Manager

30000.00

SG5

Susan

Brand

Manager

24000.00

, (NOT BETWEEN), ,
.
BETWEEN SQL, . :
SELECT staffNo, fName, IName, position, salary
FROM S t a f f
WHERE salary >= 20000 AND salary <= 30000;

176

II.

,
BETWEEN , .

5.8.
(IN/NOT IN)
.
SELECT staffNo, fName, IName, posicion
FROM S t a f f

WHERE position IN ('Manager',

'Supervisor');


IN. ,
'Manager 1 'Supervisor 1 . . 5.10.
5.10. 5.8
staffNo

fName

IName

position

SL21

John

White

Manager

SG14

David

Ford

Supervisor

SG5

Susan

Brand

Manager

,
(NOT IN), , ,
. BETWEEN, IN SQL
:
SELECT staffNo,

fName,

IName, position

FROM S t a f f

WHERE position = 'Manager' OR position = 'Supervisor 1 ;


IN
, .

5.9. (LIKE/NOT LIKE)


,
'Glasgow'.

1
' G l a s g o w , address
PrivateOwner. SQL
, .
5. SQL:

177

%. ( ).
_. .
.
address LIKE 'H%'. ,
, .
address LIKE 'H
'. ,
, , ' ' .
address LIKE ' %'.
,
.
address LIKE '%Glasgow%'. ,
, Glasgow;
address NOT LIKE ' H % ' . ,
, .
,
,
ESCAPE "" , , , . ,
45%' :
LIKE '15#%' ESCAPE ' # '

, SQL,
,
. :
SELECT ownerNo, fName, IName, address, telNo
FROM PrivateOwner

WHERE address LIKE ' %Glasgow ! ir' ;

. 5.11.
5.11. 5.9
ownerNo

fName

IName

address

telNo

087

Carol

Parrel

6 Achray St, Glasgow G32 9DX

0141-357-7419

040

Tina

Murphy

63 Well St, Glasgow G42

0141-943-1728

093

Shaw

12 Park PI, Glasgow G4 OQR

0141-225-7025
1

5.10. NULL
(IS NULL/IS NOT NULL)
PG4,
.

Viewing (. . 3.8), ,

178

P G 4 ' , ,
. ,
:
(propertyNo = ' PG4 ' AND comment = ' ' )

(propertyNo = ' P G 4 ' AND comment <> 'too r e m o t e )


. (
NULL) ,
. ,
. , IS NULL:
SELECT clientNo, viewDate
FROM Viewing
WHERE propertyNo = 'PG4' AND comment IS NULL;
. 5.12.
5.12. 5.10
clientNo

date

CR56

26--01

, NULL, ,
(IS NOT NULL).

5.3.2. ( ORDER BY)


SQL
- ( , ). ,
SELECT ORDER BY.
ORDER BY ,
. , 1, SELECT . 1, 2 ..
, , , , AS
SELECT . ORDER BY
(ASC) (DESC)
, , 1

ISO, .

5. SQL:

179

.
SQL , ORDER BY
SELECT. ORDER BY
SELECT.

5.11.
,
.

SELECT staffNo, fName, IName, salary


FROM Staff
ORDER BY salary DESC;
5.2. ,
salary. SELECT ORDER BY,
salary.
,
DESC. . 5.13. , ORDER BY :
ORDER BY 4 DESC. 4 SELECT, .. salary.
5.13. 5.11
staffNo

fName

IName

salary

SL21

John

White

30000.00

SG5

Susan

Brand

24000.00

SG14

David

Ford

18000.00

Ann

Beech

12000.00

SA9

Mary

Howe

9000.00

SL41

Julie

Lee

9000.00

SG37

ORDER BY .
.
salary. , . ,
,
.
- . ORDER BY , .

180

II.

5.12.
, .
SELECT propertyNo, type, rooms, rent
FROM PropertyForRent
ORDER BY type;
(.5.14).
5.14. 5.12

propertyNo

type

rooms

rent

PL94

Flat

400

PG4

Fiat

350

PG36

Flat

375

PG16

Flat

450

PA14

House

650

PG21

House

600

.
, . , ,
rent, :
SELECT propertyNo, type, rooms, rent
FROM PropertyForRent
ORDER BY type, rent DESC;
( , ) (
),
.
. 5.15.
5.15. 5.12

propertyNo

type

rooms

rent

PG16

Flat

450

PL94

Flat

400

PG36

Flat

375

PG4

Flat

350

14

House

650

PG21

House

600

5. SQL;

181

ISO , NULL , ORDER BY,


, , .
.

5.3.3. SQL
ISO :
COUNT ;
SUM ;
AVG ;
MIN ;
.
.
. COUNT, MIN
, , SUM AVG . COUNT ( * ) , ,
. COUNT (*}
COUNT , , , .
, DISTINCT. ' ISO
ALL , , ,
. DISTINCT
MIN .
SUM AVG, ,
. ,
DISTINCT .
,
SELECT HAVING (. 5.3.4). .
SELECT , GROUP BY, (. 5.3.4), SELECT
- , , . ,
:
SELECT staffNo, COUNT(salary)
FROM S t a f f ;

, GROUP
BY, s t a f f N o SELECT
.

182

II.

5.13. COUNT(*)
, 350
,
SELECT COUNT(*) AS count
FROM PropertyForRent
WHERE rent > 350;
,
350 ,
WHERE. ,
,
COUNT. . 5.16.
5.16. 5.13
count

5.14. COUNT(DISTINCT)
,
2001 .
SELECT COUNT(DISTINCT propertyNo) AS count
FROM Viewing
WHERE date BETWEEN ' l - M a y - 0 1 1 AND ' 3 1 - M a y - O l 1 ;

, 2001 ,
WHERE. , , COUNT. ,
,
DISTINCT
. . 5.17.
5.17. 5.14
count

5.15. COUNT SUM



.
SELECT COUNT(staffNo) AS count, SUM(salary) AS sum
FROM Staff
WHERE position = 'Manager';
5. SQL:

183

WHERE. COUNT SUM.


. 5.18.
5.18. 5.15
count

sum

54000.00

5.16. MIN, MAXnAVG


, .

SELECT MIN(salary) AS min, MAX(salary) AS max, AVG(salary) AS avg


FROM S t a f f ;
, WHERE .
MIN, MAX AVG,
salary Staff. . 5.19.
5.19. 5.16

min

max

avg

9000.00

30000.00

17000.00

5.3.4. ( GROUP BY)


,
.
.
. SELECT
GROUP BY. , GROUP BY, , , SELECT,
. , GROUP BY,
. ISO , SELECT GROUP BY
. SELECT GROUP BY SELECT
. , SELECT
:
;
;
;
, .
184

II.

, SELECT, GROUP BY, , . GROUP BY ,


SELECT. GROUP BY
WHERE, , , .
ISO , . NULL ,
.

5.17. GROUP BY
, ,
.
SELECT branchNo, COUNT{staffNo} AS count, SUM(salary) AS sum
FROM Staff
GROUP BY branchNo
ORDER BY branchNo;
s t a f f N o salary GROUP BY, SELECT
. branchNo SELECT - GROUP BY. . 5.20.

5.20. 5.17
branchNo

count

sum

8003

54000.00

005

39000.00

007

9000.00

.
1. Staff .
.
, . 5.1.
2. , , salary,
.
.
3. , branchNo.

5. SQL:

185

' branchNo

005
005
007

staffNo

salary

SG37

12000.00
18000.00
24000.00
30000.00
9000.00
9000.00

SG14
SG5
SL21
SL41
SA9

COUNT(staffNo)

SUM(salary)

54000.00

39000.00

9000.00

. 5.1. ,
SQL SELECT ( 5.3.5).
:
SELECT branchNo,

(SELECT C O U N T { s t a f f N o ) AS count
FROM S t a f f s

WHERE s.branchNo = b.branchNo),


(SELECT SUM(salary) AS sum
FROM Staff s
WHERE s.branchNo = b.branchNo)
FROM Branch b
ORDER BY branchNo;

,
Branch, ,
, .

( HAVING)
HAVING GROUP BY ,
, . HAVING WHERE , .
WHERE , , HAVING
, . ISO , ,
HAVING, GROUP BY .
HAVING , , ;

WHERE . (,
WHERE.)
HAVING SQL -
, HAVING, , .

186

II,

5.18. HAVING

.
SELECT branchNo, COUNT(staffNo) AS count, SUM(salary) AS sum
FROM Staff
GROUP BY branchNo
HAVING COUNT(staffNo) > 1
ORDER BY branchNo;
,
, , , . , HAVING. . 5.21.
5.21. 5.18
branchNo

count

sum

54000.00

005

39000.00

5.3.5.
SELECT,
SELECT. () SELECT
() .
WHERE HAVING SELECT
, . , SELECT INSERT,
UPDATE DELETE (. 5.3.10). .
, , .. . , . 5.13 5.14.
,
. , ,
. 5.15 , .
, ,
IN.

5. SQL:

187

5.19.
, ,
1
463 Main St .
SELECT staffNo, fName, IName, position
FROM Staff
WHERE branchNo = (SELECT branchNo
FROM Branch
WHERE street = '163 Main S t ' } ;
SELECT (SELECT branchNo FROM Branch ...)
, '163
Main S t ' . ( ,
.)
,
. , SELECT , ' B O O V . ,
1
'163 Main St . SELECT
:
SELECT staffNo, fName, IName, position
FROM Staff
WHERE branchNo = 'B0031;
. 5.22.
5.22. 5.19
staffNo

fName

IName

position

SG37

Ann

SG14

David
Susan

Beech
Ford
Brand

Assistant
Supervisor
Manager

SG5

, . , (.. =, <, >, <=, >=, <>) WHERE HAVING.


.

5.20.
, , ,
.
SELECT staffNo, fName, IName, position,
salary - (SELECT AVG(salary) FROM S t a f f ) AS salDiff
FROM Staff
WHERE salary > (SELECT AVG(salary) FROM S t a f f ) ;
,
'WHERE salary > AVG (salary) ',
188

II.

WHERE .
, ,
SELECT, ,
. ,
, 17 000 .
SELECT ,
. SELECT :
SELECT staffNo, fName, IName, position, salary - 17000 As salDiff
FROM S t a f f
WHERE salary > 17000;

. 5.23
5.23. 5.20
staffNo

fName

IName

position

salDiff

SL21

John

White

Manager

13000.00

SG14

David

Ford

Supervisor

1000.00

SG5

Susan

Brand

Manager

7000.00

.
1. ORDER BY,
SELECT.
2. SELECT
, ,
EXISTS (. 5.3.8).
3. , FROM .
, FROM ,
( ).
4. , , . , ,
salary.
SELECT s t a f f N o , fName, IName, position, salary
FROM S t a f f
WHERE (SELECT AVG(salary) FROM Staff) < salary;

5.21. IN
,
, '163 Main st1.
SELECT propertyNo, street, city, postcode, type, rooms, rent
FROM PropertyForRent

5. SQL:

189

WHERE

staffNo

IN

(SELECT s t a f f N o
FROM S t a f f

WHERE brancliNo = (SELECT branchNo


FROM Branch
WHERE street = '163 Main S t ' ) ) ;
, , , 463 Main S t ' . , , , .
=. IN. , ,
. . 5.24.
5.24. 5.21
city

postcode

propertyNo

street

type

rooms

rent

PG16

5 Novar Dr

Glasgow

PG36

2 Manor Rd

Glasgow

G129AX

Flat

450

G324QX

Flat

375

House

PG21

18 Dale Rd

Glasgow

G12

600

5.3.6. ANY ALL


ANY ALL , .
ALL, , .
ANY, , - (
) .
,
ALL ,
ANY . ISO SOME, ANY.

5.22. ANY SOME


,
' '.

SELECT staffNo, fName, IName, position, salary


FROM Staff

WHERE salary > SOME(SELECT salary


FROM Staff
WHERE branchNo = 'B003');

,
' 1 , ,
(. 5.20), , 190

II.

SOME/ANY. {12000, 18000, 24000}, ,


( 12 000). , .
, . 5.25.
5.25. 5.22
staffNo

fName

(Name

SL21

John

SG14

David

SG5

Susan

position

salary

White

Manager

30000.00

Ford

Supervisor

18000.00

Brand

Manager

24000.00

5.23. ALL

,
' '.
SELECT staffNo, fName, INarae, position, salary
FROM S t a f f
WHERE salary > ALL{SELECT salary
FROM Staff
WHERE branchNo = 'BOG3');
.
, ' ' ,
,
. ALL. . 5.26.
5.26. 5.23
staffNo

fName

IName

position

salary

SL21

John

White

Manager

30000,00

,
1

5.3.7.
:
. .
, . SQL
, .

.

5. SQL

191

, , . ' , . FROM
, ,
WHERE , . , , FROM.
. ,
,
. , . , , .

5.24.
,
.
SELECT c.clientNo, fName, IName, propertyNo, comment
FROM Client c, Viewing v
WHERE c.clientNo = v.clientNo;
Client, Viewing, . SELECT ,
. ,
(clientNo) ,
, .
, . (
clientNo Viewing.)

{ ). ' ' , Client.
, clientNo. .clientNo=v.clientNo.
.
, 4.1.3. . 5.27.
5.27. 5.24
clientNo

fName

IName

propertyNo

CR56

Aline

PG36

CR56

Aline

CR56

Aline

Stewart
Stewart
Stewart
Tregear
Kay

CR62

Mary

CR76

John

192

PA14

comment
too small

PG4

PA14
PG4

no dining room
too remote

II.

,
" " (1:*), - (.
11.6.2). , Client
Viewing, .
Viewing () Client (),
Client ()
Viewing (). , , . 3.2.5 ,
"-" . , , , , , . - SQL
, .
5.24 Client (. clientNo)
Viewing (v. clientNo).
SQL
:
FROM Client JOIN Viewing v ON .clientNo = v.clientNo
FROM Client JOIN Viewing USING clientNo
FROM Client NATURAL JOIN Viewing
FROM FROM
WHERE.
clientNo, clientNo.

5.25.
,
- , ,
.
SELECT s.branchNo, s . s t a f f N o , fName, IName, propertyNo
FROM Staff s, PropertyForRent p
WHERE s . s t a f f N o = p . s t a f f N o
ORDER BY s.branchNo, s.staffNo, propertyNo;

,
,
. . 5.28.
5.28. 5.25
branchNo

StaffNo

fName

IName

propertyNo

SG14

David

Ford

PGi6

SG37

Ann

Beech

PG21

SG37

Ann

Beech

PG36

BOOS

SL41

Julie

Lee

PL94

007

SA9

Mary

Howe

PA14

5. SQL:

193

5.26.
,
- , ,
, ,
.
SELECT b.branchNo, b.city, s.staffNo, fName, IName, propertyNo
FROM Branch b, S t a f f s, PropertyForRent p
WHERE b.branchNo = s.branchNo AND s . s t a f f N o = p . s t a f f N o
ORDER BY b.branchNo, s . s t a f f N o , propertyNo;


Branch, Staff PropertyForRent, . Branch Staff
b.branchNo=*s .branchNo, . Staff
PropertyForRent

s. staff No=p. staff No. , .


. 5.29.
5.29. 5.26
branchNo

city

staff Mo

fName

IName

propertyNo

Glasgow

SG14

David

Ford

PG16

Glasgow

SG37

Ann

Beech

PG21

Glasgow

SG37

Ann

Beech

PG36

005

London

SL41

Julie

Lee

PL94

007

Aberdeen

SA9

Mary

Howe

PA14

, SQL
FROM WHERE:
FROM

(Branch b JOIN S t a f f s USING branchNo) AS bs


JOIN PropertyForRent p USING s t a f f N o

5.27.
,
,
SELECT s.branchNo, S.staffNo, COUNT(*) AS count
FROM S t a f f s, PropertyForRent p
WHERE S . s t a f f N o = p . s t a f f N o
GROUP BY s.branchNo, s . s t a f f N o
ORDER BY s.branchNo, s . s t a f f N o ;

, ,
. Staff PropertyForRent
194

II.

staffNo FROM/WHERE. ,
,
GROUP BY. ,
ORDER BY. . 5,30.
5.30. 5.27
branchNo

staffNo

count

SG14

SG37

8005

SL41

007

SA9



, (. 4.1.2).
,
, . , . WHERE, SQL
. , ISO SELECT,
:
-."SELECT [DISTINCT. | ALL] {* j columnList]
FROM
tableNamel CROSS JOIN 2

5.24, client
Viewing clientNo,
, . 3.6 3.8, 20 (4 Client x 5
viewing = 20 ). 5.24 , WHERE.
, SELECT, .
1. , FROM.
2. WHERE,
, .

.
3. ,
SELECT, .
4. SELECT DISTINCT,
-.
5. SQL:

195

, 3 4 ,
, SELECT.
5. ORDER BY, .


,
.

, .
. ISO , (. 4.1.3).
,
.
, Branch
PropertyForRent, . 5.31 5.32.
5.31. Branch"!
branchNo

bCity

Glasgow

004

Bristol

002

London

5.32. PropertyForRentl
pCity
Aberdeen
London
Glasgow

() SQL:
SELECT b . * , p . *
FROM Branchl b, PropertyForRentl p
WHERE b . b C i t y = p . p C i t y ;

. 5.33.
5.33.
Branchl PropertyForRentl
branchNo

bCity

propertyNo

Glasgow
London

PG4

Glasgow

PL94

London

002

196

pC'rty

II.

,
, , .
,
, .

, .
: , .
.

5.28.
,
, ,
.

, :
SELECT . * , . *
FROM Branchl b LEFT JOIN PropertyForRentl p ON b . b C i t y = p.pCity;

. 5.34.
,
, (),
(). NULL.
5.34. 5.28
branch No

bCity

propertyNo

pClty

Glasgow

PG4

004

Bristol

NULL

Glasgow
NULL

002

London

PL94

London

5.29.
,
, ,
.

,
:
SELECT b . * , p . *
FROM Branchl b RIGHT JOIN PropertyForRentl p ON b.bCity = p.pCity;

. 5.35.
,
,
() , ()
. NULL.
5. SQL:

197

5.35. 5.29
branchNo

bCity

propertyNo

pCity

NULL

NULL

PA14

Aberdeen

B003

Glasgow

PG4

Glasgow

B002

London

PL94

London

5.30. }
,
, ,
.

, :
SELECT . * ( . *
FROM Branchl b FULL JOIN PropertyForRent p ON b.bCity = p.pCity;

. 5.36.
,
, , . ,
, NULL.
5.36. 5.30
branchNo

bCity

propertyNo

pClty

NULL

NULL

PA14

Aberdeen

Glasgow

PG4

004

Bristol

NULL

Glasgow
NULL

002

London

PL94

London

5.3.8. EXISTS NOT EXIST


EXISTS NOT EXISTS . TRUE FALSE. EXISTS TRUE
,
. , EXISTS
FALSE. NOT EXISTS , EXISTS.
EXISTS NOT EXISTS
, .
, :
(SELECT * FROM . . . )

198

II.

5.31. EXISTS
, .
SELECT staffNo, fName, IName, position
FROM Staff
WHERE EXISTS(SELECT *
FROM Branch b
WHERE s.branchNo = b.branchNo AND city = 'London');
: "
, Branch ,
branchNo, ,
City 'London'".
. , EXISTS
TRUE. . 5.37.
5.37. 5.31
staff

No

fName

IName

position

SL21

John

White

Manager

SL41

Julie

Lee

Assistant

, , s.branchNo=b.branchNo,
, .
,
, SELECT * FROM Branch
WHERE city='London' TRUE. :
SELECT s t a f f N o , fName, IName, position FROM Staff WHERE true;
:
SELECT staffNo, fName, IName, position FROM S t a f f ;
, , :
SELECT s t a f f N o , fName, IName, position
FROM S t a f f s, Branch b
WHERE s.branchNo = b.branchNo AND city = 'London 1 ;

5.3.9.
( UNION, INTERSECT EXCEPT)
SQL
(union), (intersection) (difference),
.
5. SQL:

199

,
, (), ()
,
, , ,
.
, ,
, .
. 5.2. , , . ,
, ..
. ,
,
. , , . , , , SMALLINT.

Bns

-s

. 5.2.
(, )
, ISO, UNION, INTERSECT EXCEPT.
:
opera tor .[ALL]

{CORRESPONDING [BY {columnl [,

...]}

CORRES POND ING BY


.
CORRESPONDING, 3Y , , . ALL, .
SQL INTERSECT EXCEPT, a
EXCEPT MINUS.

200

II.

5.32. UNION
, ,
.
(SELECT city

FROM Branch
WHERE city IS NOT NULL)
UNION

(SELECT city
FROM PropertyForRent

WHERE city IS NOT NULL);

{SELECT *
FROM Branch
WHERE city IS NOT NULL)
UNION CORRESPONDING BY city

(SELECT *
FROM PropertyForRent

WHERE c i t y IS NOT NULL);

,
, .
. 5.38.
5.38. 5.32
city
London
Glasgow
Aberdeen
Bristol

5.33. INTERSECT
, ,
.
(SELECT city
FROM Branch)
INTERSECT
(SELECT c i t y
FROM PropertyForRent);

(SELECT *
FROM Branch)
INTERSECT CORRESPONDING BY city
(SELECT *
FROM PropertyForRent};

, ,
.
. 5.39.
5.39. 5.33
city
Aberdeen
Glasgow
London

5. SQL:

201

INTERSECT:
SELECT b . c i t y

FROM Branch b, PropertyForRent p

SELECT DISTINCT city


FROM Branch b

WHERE b . c i t y = p . c i t y ;

WHERE EXISTS(SELECT *

FROM PropertyForRent p
WHERE p . c i t y = b . c i t y ) ;

SQL , .

I 5.34. EXCEPT
, ,
,

(SELECT city
(SELECT *
FROM Branch)
FROM Branch)
EXCEPT
EXCEPT CORRESPONDING BY city
(SELECT city
(SELECT *
FROM PropertyForRent);
FROM PropertyForRent);
, ,
, . . 5.40.
5.40. 5.34
city
Bristol

EXCEPT:
SELECT DISTINCT city
FROM Branch
WHERE city NOT IN
(SELECT city
FROM PropertyForRent);

SELECT DISTINCT city


FROM Branch b
WHERE NOT EXISTS
(SELECT *
FROM PropertyForRent p
WHERE p.city = b.city);

5.3.10.
SQL , , .
, SELECT. SQL, .
INSERT ,
UPDATE ,
.
DELETE .
202

II.

( INSERT)
INSERT.
. INSERT
:
# INSERT . INTO TableName
^VALUES
TableName ( ) , ( 6.4). colunmList ( ) ,
, . coIumnLisC
. ,
, ,
CREATE TABLE. INSERT
,
NULL
,
DEFAULT ( 6.3.2). dataValueList ( )
columnList:
;

,
da ta Val uebist
columnList, dataValuel/ist columnList ..;
dataValueList
.
5.35. INSERT... VALUES
staff , .
INSERT INTO Staff
VALUES('SG16', 'Alan', 'Brown', 'Assistant 1 , ' M 1 , DATE '1957-05-25',
8300, ' B 0 0 3 ' ) ;

, . ,
(, ' A l a n ' ) .

I 5.36. ,

staff ,
: staffNo, ftfame, IName, position, salary branchNo.
INSERT INTO Staff (staffNo, fName, IName, position, salary, branchNo)
VALUES { ' S G 4 4 1 , ' A n n e 1 , 'Jones', ' A s s i s t a n t ' , 8100, ' ' } ;

5. SQL:

203

, , . ,
, . , INSERT
:
INSERT INTO Staff
VALUES ( ' S G 4 4 1 , 'Anne 1 , ' J o n e s 1 , ' A s s i s t a n t 1 , NULL, NULL, 8100,
NULL, ' B G 0 3 . ' ) ;
, sex DOB NULL.
--.. -".

INSERT . :
r

INSERT INTO . TableWame


-'.-SELECT .--.- :
^^^^
TableWame columnList ,
. SELECT SELECT. , , ,
. ,
INSERT, .
5. 37. INSERT ... SELECT
, Staff PropCount, ,
:
Staff PropCount (staff No, fNarie, IName, propCount)
staff PropCount , staff
PropertyForRent.
INSERT INTO StaffPropCount
{SELECT s.staffNo, fName, IName, COUNT(*)
FROM Staff s. Proper t ForRent p
WHERE s.staffNo p. staff No
GROUP BY s.staffNo, fName, IName}
UNION
(SELECT s t a f f N o , fName, INa-ne, 0
FROM S t a f f
WHERE s t a f f N o NOT IN (SELECT DISTINCT s t a f f N o
FROM PropertyForRent) ) ;

,
, . UNION,
,
. , ,
. 204

II.

UNION, SELECT , count 0. . 5.41


StaffPropCount .
5.41. SQL 5.37
staffNo

fName

IName

propCount

SG14

David

Ford

SL21

John

White

SG37

Ann

Beech

SA9

Mary

Howe

SG5

Susan

Brand

SL41

Julie

Lee

, SQL
UNION INSERT.

( UPDATE)
UPDATE
. :
^UPDATE.
SET calumnNamel = dataValuel
[WHERE searchCondition]

columnNameS '*= dataValueS

TableN&me , (. 6.4). SET , . WHERE . ,


. WHERE , , , searchCondition.
dataValuel, dataValue2t...
.

5.38.
UPDATE
3%.

UPDATE Staff
SET salary = salary*!.03;
S t a f f , WHERE
.

" 5. SQL:

205

5.39.
UPDATE
5%.
UPDATE Staff
SET salary = salary*!.05
1
WHERE position = ' M a n a g e r ;
WHERE , .
salary , salary =
salary*!.05.

5.40.
UPDATE
(BtafNo='SGl4 ')
18 000 .
UPDATE Staff
SET position = 'Manager', salary = 18000
WHERE staffNo = 'SG14';

( DELETE)
DELETE .
:
'''DELETE FROM TableName
:[WHERE searchConditionJ
INSERT UPDATE, TableName
,
(. 6.4). searchCondition ,
. .
, , DROP TABLE (. 6.3.3). WHSRE ,
, , searchCondition,

5.41. ( DELETE)
PG4.
DELETE FROM Viewing
WHERE propertyNo = 'PG4';
WHERE
,,
' PG4 ', .
206

II.

5.42. ( DELETE)
viewing.
DELETE FROM Viewing/

WHERE ,
. Viewing, .

SQL , ( SELECT, INSERT, DELETE). , .


.
SELECT SQL. : , .
SELECT ,
.
SELECT / ,
.
FROM , , SELECT.
WHERE ,
.
. ORDER BY .
. ORDER BY SELECT,
.
SQL (COUNT, SUM, AVG, MIN
MAX),
. SELECT
, , GROUP BY.
GROUP BY . ,
,
.
, .
HAVING ,
WHERE . 5. SQL:

207

,
. , WHERE, HAVING .
SELECT,
.
WHERE HAVING SELECT,
.
, . , .
: , .
;
, . , .
, .
, , . . , , IN.

, .
FROM, ,
, WHERE. ISO . , (, ), UNION, INTERSECT EXCEPT.
SELECT, SQL DML INSERT,
,
. UPDATE

. DELETE
.

(
5.1.
5.2.
5.3.
5.4.

SQL. ?
SQL?
, SELECT.
?

SELECT? NULL?

5.5.

GROUP BY. WHERE HAVING?

5.6.

? ?

208

II.

5.7-5.28 Hotel, 3.


5.7.
5.8.

.
,
.
5.9.
,
, .
5.10. 40 ,
.
5.11. , dateTo.


5.12.
5.13.
5.14.
5.15.

?
?
?
?


5.16. Grosvenor,
5.17. ,
Grosvenor.
5.18. ,
Grosvenor, .
5.19. ,
Grosvenor, ?
5.20. Grosvenor, .
5.21. - Grosvenor ?

5.22. .
5.23. ,
.
5.24. ,
?
5.25. ?
5.26. -
?
5. SQL:

209


5.27. .
5.28. 5%.


5.29. SQL ,
.
ISO.
, . ., ?
5.30. , ,
HAVING,
HAVING.
5.31. , SQL .

210

II.

SQL:

...

, SQL.

SQL.

SQL, :
;
;
;
;
, .

CREATE TABLE ALTER TABLE.

,
SQL.
.
, .
.
ISO.
GRANT REVOKE .

SQL ,
.
SQL .


6.1 ISO SQL. 1989 ISO
(Integrity Enhancement Feature IEF),
[171]. -


. IEF SQL ,

. 6.2,
SQL 6.3.
6.4 ,
SQL, ,
.
, , ISO SQL , . 6.5 ISO SQL.

. , SQL , ,
.
6.6.
21 SQL , SQL. 27.4 , SQL
- ,
SQL3. , SQL , Dreamffome.
SQL ,
5.2.

6.1. SQL,
ISO
, ISO SQL.
SQL.

6.1.1. SQL
SQL
, . ,
SQL, . ISO
, ;
(A-Z, a-z), (0-9) (_). .
:
128 ( );
;
.
212

II.

6.1.2. SQL
. 6.1 SQL, ISO.
, -
character bit " ",
exact numeric approximate numeric " ". SQL3 , , 27.4.
6.1. SQL, ISO

boolean
()
character
()
bit
()
exact numeric
( )
approximate numeric
( )
datetime
(/)
interval
()

BOOLEAN

LOB

( )

CHAR

VARCHAR

BIT

BIT VARYING

NUMERIC

DECIMAL

INTEGER

FLOAT

REAL

DOUBLE
PRECISION

DATE

TIME

TIMESTAMP

SMALLINT

INTERVAL
CHARACTER
LARGE
OBJECT

BINARY
LARGE
OBJECT

( boolean)
TRUE
() FALSE (). UNKNOWN (), NULL,
- NOT NULL.
SQL . TRUE
FALSE, , NULL UNKNOWN,
UNKNOWN.

( character)
,
.
SQL, , , . ASCII EBCDIC.
:
6. SQL:

213

' CHARACTER [VARYING] [length:


.CHARACTER (. .)
CHARACTER VARYING ( - VARCHAR)

length ,
( 1).

(VARYING) . ,
, . ,
,
. , branchNo
Branch
:
branchNo CHAR(4)
address PrivateOwner
{ 30 ), :
address VARCHAR(30)

( bit)
, .. (), 0, 1. , :

OBIT IVARYING] {length].


, ' ' bitstring:
bitString

BIT(4)

6.1.3. ( exact numeric)


,
. ( , "" ""). (precision) , (scale).
,
, . . ,
-12 .345 , 5 ,
3. . :
''NUMERIC -[ 'precision - [/.-ScaJe] ]
" DECIMAL E precision (, 'scale] }
INTEGER
' SMALLXNT
:
j. INTEGER . ( INT) DECIMAL ( DEC)
214

II.

NUMERIC DECIMAL
. ,
. INTEGER
.
SMALLINT .
. , , SMALLINT,
32 767. rooms PropertyForRent,
, SMALLINT :
rooms

SMALLINT

salary S t a f f :
salary

DECIMAL(7,2)

99 999.99
,

( approximate numeric)
, , .
,
, (), : 10, +5.26, - 0 . 2 - 4 .
:
I FLOAT

[precision]

' REAL
' DOUBLE PRECISION

precision .
REAL DOUBLE PRECISION .

( datetime)
"/"
. , . ISO "/" YEAR (), MONTH (), DAY (), HOUR (), MINUTE (), SECOND
(), TIMEZONE_HOUR ( ) TIMEZONE_MINUTE ( ).
(
). /.

J'DATE

:TIME [timePrecision] [WITH TIME 2ONS]


TIMESTAMP [timePrecision] [WITH TIME ZONE]

DATE ,
YEAR, MONTH DAY. TIME -
6. SQL:

215

, HOUR, MINUTE SECOND. TIMESTAMP


. timePrecision , SECOND. ,
TIME (..
), TIMESTAMP
6 (.. ). WITH TIME ZONE
TIMEZONE_HOUR TIMEZONE_MINUTE. , date Viewing,
(, )
, :
viewDate

DATE

interval
. : YEAR, MONTH,
DAY, HOUR, MINUTE SECOND. : - - . YEAR / MONTH.
DAY, HOUR, MINUTE, SECOND.
:
INTERVAL -{{startField TQ.endField} singleDatetimeField}
StartField = YEAR
MONTH | DAY j HOUR | MINUTE
[CintervaiLeadingFieldPrecisicm) ]
endField
YEAR | MONTH | DAY j .HOUR-.. | MINUTE | SECOND
[(fractionalSecondsPrecision)]
singleDatetimeField = startPield |;SECONB
[ (intervejlbeadingFie.IdPrecis.icm
[,fractionalSecondsRrecision])]
startField
(intervalLeadingFieldPrecision),
. :
INTERVAL Y E A R ( 2 )

MONTH

, 0 , 0 99 , 11 . :
INTERVAL HOUR TO SECOND(4)

, 0 , 0 , 99 , 59 5 9 . 9 9 9 9 .
( 4.)


SQL
, , .. , .
(+, -, * /)
, . 6.2.
216

II.

6.2. SQL, ISO

BIT_LENGTH

. ,
BIT_LENGTH(X'FFFF') 16

OCTET_LENGTH

( ,
8}. ,
OCTETJjENGTHfX'FFFF') 2

CHAR__LENGTH

( ,
). ,
CHAR_LENGTH ( ' Beech') 5

CAST

,
, .
CAST ( .26 AS INTEGER)
,
.
, f Name j | IName

CURRENTJJSER USER

,
(,
, )

SESSION_USER

,
SQL

SYSTEMJJSER

,
,

LOWER


. ,
LOWER(SELECT fName FROM Staff WHERE staffNo =
'SL21') ' john'

UPPER


. ,
UPPER(SELECT fName FROM Staff WHERE staffNo =
SL21') 'JOHN'

TRIM

(LEADING),
(TRAILING) (BOTH) .
, TRIM (BOTH ' * ' FROM ' ***
Hello World * * * ' ) 'Hello World 1

POSITION

.
, POSITION ( ' '
IN 'Beech') 2

SUBSTRING

.
,
SUBSTRING!'Beech' FROM 1 )
'Bee 1

EXTRACT


, .
EXTRACT(YEAR FROM Registration.dateJoined)

6. SQL:

217

. 6.2

CASE

CASE type
WHEN 'House'
WHEN ' F l a t '
ELSE
END

THEN 1
THEN 2
0

CURRENT_DATE

CURRENTJTIME

,
,
, CTJRRENTJTIME ( 6 )

CURRENT_TIME_STAMP

,

. , CURRENT_TIMESTAMP(O)

6.2.
, , SQL.
,
. 3.3 :
;
;
;
;
.
CREATE TABLE ALTER
TABLE.

6.2.1.
, (
NULL). NULL ;
, ,
(. 3.3.1). ,
: , .. ISO NOT
NULL, CREATE TABLE ALTER TABLE.
NOT NULL, 218

II.

.
NULL,
NULL. ISO NULL. , , position
() Staff () ,
, .
position VARCHAR(IO) NOT NULL

6.2.2.
, ..
(. 3.2.1). , , sex () Staff

' ' , ' F ' . ISO
CREATE TABLE ALTER TABLE. CHECK, . CHECK :
:

CHECK

{searchCandition}

CHECK
. , , sex ( ' '
'F'), :
CHAR NOT NULL CHECK

{sex IN

CM ,

'F })

ISO ,
CREATE DOMAIN,
:
: CREATE DOMAIN domainWame [AS] datatype
[DEFAULT defaultOption]
.:[CHECK (searcftCoriditicn)]

,
domainName, , dataType (. 6.1.2), ,
defaulCOption, ,
CHECK. ,
CREATE DOMAIN ,
. ,
sex :
CREATE DOMAIN SexType AS CHAR
DEFAULT ' M '
CHECK (VALUE I N { ' M ' , ' F ' ) ) ;


SexType, ,
6. SQL:

219

" ' F ' . sex Staff ,


SexType CHAR:
sex

SexType NOT NULL

searchCondicion
. , BranchNumber ( ), , branchNo
Branch. :
CREATE DOMAIN BranchNumber AS VARCHAR(4)
CHECK (VALUE IN (SELECT branchNo PROM Branch));

DROP
DOMAIN, :
"DROP DOMAIN domainName [RESTRICT | CASCADE]

(RESTRICT CASCADE) ,
, . RESTRICT, , (. 6.5.2),
. CASCADE,
, , ,
,
.

6.2.3.
. , PropertyForRent
,
propertyNo;
, . ISO
PRIMARY KEY CREATE TABLE ALTER TABLE. ,
PropertyForRent :
PRIMARY KEY(staffNo)

, ,
Viewing, clientNo propertyNo,
PRIMARY KEY
PRIMARY KEY(clientNo, propertyNo)

PRIMARY KEY
.
,
UNIQUE. , 220

II.

NOT NULL.
UNIQUE. INSERT UPDATE,
( ). , Viewing :
clientNo VARCHAR{5) NOT NULL,
propertyNo VARCHAR(S) NOT NULL,
UNIQUE (clientNo, propertyNo)

6.2.4.
, ,
, ,
. ,
,

(. 3.3.3). , branchNo
PropertyForRent Branch, , .
, branchNo Branch. .
ISO FOREIGN KEY CREATE TABLE ALTER TABLE.
,

branchNo

PropertyForRent :
FOREIGN KEY(branchNo) REFERENCES Branch
INSERT UPDATE,
, . , UPDATE DELETE,
,
,
, ON
UPDATE ON DELETE FOREIGN KEY. , , , SQL .
CASCADE. . , ,
,
.. , .
6. SQL:

221

SET NULL. ,
NULL. , NOT NULL.
SET DEFAULT. ,
, .
DEFAULT ,
(. 6.3.2).
NO ACTION. . , ON DELETE .
SQL , .
CASCADE , . , , . ,
PropertyForRent s t a f f No
, staff.
, ,
staff staffNo PropertyForRent NULL:
FOREIGN KEY (staffNo} REFERENCES Staff ON DELETE SET NULL

,
ownerNo PropertyForRent ,
PrivateOwner. , , PrivateOwner ownerNo PropertyForRent
:
FOREIGN KEY {ownerNo) REFERENCES PrivateOwner ON UPDATE CASCADE

6.2.5.
( ), , . , DreamHome
, ) ,
, . ISO CHECK UNIQUE CREATE TABLE ALTER TABLE, CREATE
ASSERTION. CHECK UNIQUE . CREATE ASSERTION
,
. :
222

II.

CREATE ASSERTION

CHECK, . , , ASSERTION,

. ,
,
, :
CHEATS ASSERTION Staff NotHandlingTooMuch
CHECK (NOT EXISTS (SELECT staff No
FROM PropertyForRent
GROUP BY staffNo
HAVING COUNT(*} > 1 0 0 ) )
,
CREATE TABLE ALTER TABLE.

6.3.
SQL DDL (Data Definition Language)
, , , , .
, ,
, . ISO
, . . [45].
SQL.
CREATE
CREATE
CREATE
CREATE

SCHEMA
DOMAIN
TABLE
VIEW

ALTER DOMAIN
ALTER TABLE

DROP
DROP
DROP
DROP

SCHEMA
DOMAIN
TABLE
VIEW

, , .
, SQL:
CREATE INDEX

DROP INDEX

, , , .

6.3.1.
.
().
6. SQL:

223

,
.
ISO , ,
SQL .
ISO,
(environment). , (catalog),
(schema).
,
( ). ],!, , , , , .
, .

, .
():
:

;CREATE. SCHEMA "( )' AUTHORIZATION " Creator-Identifier]

, SqlTests Smith, :
CREATE SCHEMA SqlTests AUTHORIZATION Smith;

ISO , ,
. .
DROP SCHEMA, :
| SCHEMA Name' [ RESTRICT j "CASCADE")

RESTRICT ( ), , .
CASCADE, , ,
. , DROP SCHEMA .
DROP SCHEMA CASCADE
, .
CREATE SCHEMA DROP SCHEMA
.

6.3.2. ( CREATE TABLE)



, , .
CREATE TABLE, :
224

II.

. CREATE ;. TABLED ' '


f (columName data Type '.{NOT NULL) [UNIQUE!
-[DEFAULT defaultoption] tCHSCK (searchCondXtion}:] " t, - - }

[PRIMARY KEY: .<lJSOf Columns) , }


:: - :{ [UNIQUE^d^stOfOsIumns) ,} t [,--. . .] }
;..V{ .[FOREIGN KEY (listOfFdreignKeyColumns)*
. * REFERENCES Parent Tabl eName '[{listOfCandidateKeyColuims} ] ,
tMATCH {PARTIAL f FULL}
' : [ON UPDATE. i-eferentialAction]
CON DELETE referential Action] } [ , , .-.] }
{{CHECK (aearchCoodltioa)} , . , , ] } )

CREATE TABLE . SQL. , ,


,
.
,
TableName,
dataType. 6.1.2.
, , DEFAULT.
,
INSERT . ,
defaultoption
. NULL, UNIGUE CHECK
.
:
CONSTRAINT ConstraintName

,
ALTER TABLE, .
PRIMARY KEY ,
. SQL, , . , , NOT NULL.

PRIMARY KEY. INSERT
UPDATE, () PRIMARY KEY. , .
FOREIGN KEY ()
() . .
UstOfForeignKeyColumns, , .
REFERENCES,
(.. , . SQL:

225

). UstOfCandidateKsyCalumns , , .
CREATE TABLE PRIMARY KEY.
(ON UPDATE)

(referentialAction)
, . referentiaJAcCion
CASCADE, SET NULL, SET DEFAULT NO ACTION. ON
UPDATE , ,
, NO ACTION (. 6.2).
(ON DELETE)

(referentialAction) , , .
referentzalAction
ON UPDATE.
,
NULL . MATCH
, NULL
. MATCH FULL,
(NULL), . MATCH PARTIAL, (NULL), ,
, NULL . , MATCH FULL.
FOREIGN KEY. CHECK CONSTRAINT
. CHECK
, .

SQL , ,
, SQL
(, 6.5). 6.1 CREATE TABLE.

6.1. CREATE TABLE


Proper t yForRen t
CREATE TABLE.
CREATE DOMAIN OwnerNumber AS VARCHAR(S)
CHECK {VALUE IN (SELECT ownerNo FROM PrivateOwner));
CREATE DOMAIN StaffNumber AS VARCHAR(S)
CHECK (VALUE IN (SELECT s t a f f N o FROM S t a f f } ) ;
CREATE DOMAIN BranchNumber AS C H A R ( 4 )
CHECK (VALUE IN (SELECT branchNo FROM Branch)};
CREATE DOMAIN PropertyNumber AS V A R C H A R ( S ) ;
226

II.

CREATE
CREATE
CREATE
CREATE

DOMAIN Street AS VARCHAR(25);


DOMAIN City AS VARCHAR(15);
DOMAIN Postcode AS VARCHAR(S);
DOMAIN PropertyType AS CHAR(l)
CHECK(VALUE IN ('B', 'C' f 'D', 'E 1 , 'F', 'M 1 , ''));
CREATE DOMAIN PropertyRooms AS SMALLINT;
CHECK(VALUE BETWEEN 1 AND 15);
CREATE DOMAIN PropertyRent AS DECIMAL(6,2)
CHECKfVALUE BETWEEN 0 AND 9999.99);
CREATE TABLE PropertyForRent(
propertyNo
PropertyNumber NOT NULL,
street
Street
NOT NULL,
city
City
NOT NULL,
postcode
Postcode,
type
PropertyType
NOT NULL DEFAULT 'F 1 ,
rooms
PropertyRooms NOT NULL DEFAULT 4,
rent
PropertyRent
NOT NULL DEFAULT 600,
ownerNo
Owner-Number
NOT NULL,
staffNo
StaffNumber
CONSTRAINT StaffNotHandlingTooMuch
CHECK (NOT EXISTS
(SELECT staffNo
FROM PropertyForRent
GROUP BY StaffNo
HAVING COUNT(*) > 100)),
branchNo
BranchNumber
NOT NULL,
PRIMARY KEY (propertyNo),
FOREIGN KEY (staffNo) REFERENCES Staff ON DELETE SET NULL
ON UPDATE CASCADE,
FOREIGN KEY (ownerNo) REFERENCES PrivateOwner ON I-vXETE NO
ACTION ON UPDATE CASCADE,
FOREIGN KEY (branchNo) REFERENCES Branch ON DELETE NL *
ACTION ON UPDATE CASCADE);
type ' F ' ( ' F l a t ' ).
CONSTRAINT,
, .
, , , 100.

(propertyNo).
. (staffNo)
, S t a f f .
,
Staff

staffNo

PropertyForRent NULL, , ,
Staff
g t a f f N o PropertyForRent.
(ownerNo) ,
PrivateOwner. NO ACTION
PrivateOwner, PropertyForRent
ownerNo. 6. SQL:

227

CASCADE ,

ownerNo PropertyForRent .
branchNo. FOREIGN KEY HstOCandidateKeyColunms, ,
.
, s t a f f N o
NOT NULL , - ,

(, ).
( ownerNo
brancbNo, )
.

6.3.3.
( ALTER TABLE)
ISO ALTER TABLE . ALTER
TABLE , :
;
;
(5;
;
, ;
, ,
.
.
"ALTER TABLE 'TableName
. [ADD [COLUMN] columnNattie dataType [NOT NULL] . [UNIQUE].
' [DEFAULT defaultOptionJ [CHECK 4searchCondition)]]
[COLUMN] columnWame [RESTRICT | CASCADE]].,
[CONSTRAINT [ConstralntName] ] tableConstraintDefinitian]
tDROP CONSTRAINT ConstraintWame '[RESTRICT | CASCADE]]
[ALTER [COLUMN] SET DEFAULT defaulcpption]
[ALTER [COLUMN] DROP DEFAULT]

CREATE TABLE, , CaJbleConstraintDefinition
PRIMARY KKY, UNIQUE, FOREIGN KEY CHECK. ADD COLUMN CREATE
TABLE. DROP COLUMN , , , ,
DROP , .

228

II.

RESTRICT, DROP ,
(, ). .
CASCADE. DROP
, . ,
, , , -
, , ..

6.2. ALTER TABLE


staff,
'Assistant' it ion,
' F ( female ).
ALTER TABLE Staff
ALTER position DROP DEFAULT;
ALTER TABLE Staff
ALTER sex SET DEFAULT 'F';
PropertyForRent, ,
100
. Client,
, .
ALTER TABLE PropertyForRent
DROP CONSTRAINT StaffNotHandlingTooMuch/
ALTER TABLE Client
ADD prefNoRooms PropertyRooms;
ALTER TABLE SQL.
ALTER TABLE . ,
, , . ,
:
;
DROP
TABLE;
CREATE TABLE;
.
, ,
,
. , INSERT. , .SELECT , .

6. SQL:

229

6.3.4. ( DROP TABLE)


: , * DROP TABLE, :
.DROP TABLE.TableWame [RESTRICT I CASCADE]

, PropertyForRent
:
DROP TABLE PropertyForRent;

, , .
, , DELETE (. 5.3.10). DROP TABLE
, .
RESTRICT. DROP ,
, ,
.
CASCADE. DROP ,
( , ).
DROP TABLE
CASCADE ,
.
DROP TABLE ,
. ,
DROP TABLE , .

6.3.5. ( CREATE INDEX)


,
. (
.) .

, .
,
. SQL. ;
!-'CREATE [UNIQUE] INDEX
ON Table/fame (!8 | DESC]
;

L, - 1 )

. , .
UNIQUE, 230

II.

.
, , ,
(, ).
,
,
. , ( ) . .
Staff PropertyForRent ,
, :
CREATE UNIQUE INDEX ScaffNoInd ON S t a f f ( s t a f f N o ) ;
CREATE UNIQUE INDEX PropertyNoInd ON PropertyForRent

(propertyNo);


(ASC) (DESC),
. , PropertyForRent
:
CREATE INDEX Rentlnd ON PropertyForRent (city, rent) , Rentlnd, PropertyForRent.
city,
rent.

6.3.6. ( DROP INDEX)


,
, DROP INDEX.
:
;;DROP" INDEX JndexWame

,
.
DROP INDEX Rentlnd;

6.4.
, 3.4.
. , *
, . - :
, ,
.
,
.
6. SQL:

231

.

, . . , ,
. , , , ,
. , (
SQL, ),
6.4.3. ,
, ,
, . 6.4.8.
, .

6.4.1. ( CREATE VIEW)


CREATE VIEW :
CREATE VIEW ViewName ([ (newCoIumntfame [,
'AS subselect [WITH [CASCADED ,| LOCAL]

...])].

sutoselect, SELECT SQL.


. , , , subselect. , -
, subselect. , . ,
, AS

? .
subseJect
. WITH CHECK OPTION, ,
, ,
WHERE , ( 6.4.6). ,
SELECT , USAGE
, . , 6.6. , .
.
232

II.

6.3.
, ' '
, .


, .
CREATE VIEW Manager3Staff
AS SELECT *
FROM Staff
WHERE branchNo = '';

Manager3Staff, S t a f f ,
, ' ' . ( ,
branchNo
, ' '.) SQL, , . 6.3.
SELECT * FROM Manager3Staff;
6.3. , ManagerSStaff
staffNo

fName

SG37

INatne

position

sex

DOB

salary

branchNo

10-Nov-60

12000.00

8003

24-Mar-Sa

18000.00

3-Jun-40

24000,00

Beech

Assistant

SG14

David

Ford

Supervisor

SG5

Susan

Brand

Manager

,
Staff, , ,
ManagerSStaff. -
s t a f f ,
, . 6.6.

6.4.
,
' ', ,
,
.

, .
CREATE VIEW Staff3
AS SELECT staffNo, fName, IName, position, sex
6. SQL:

233

FROM S t a f f
WHERE branchNo = ' B O Q 3 ' ;

, ,
Staff ManagerSStaff:
CREATE VIEW S t a f f s
AS SELECT s t a f f N o , fName,
FROM Manager3Staff;

iNa'ne,

position,

sex

Staffs,
S t a f f , salary, DOB branchNo. , , , 6.4.
6.4. , Staff.3
position

sex

Beech

Assistant

Ford

Supervisor

Brand

Manager

staffNo

fName

(Name

SG37

Ann

SG14

David

SG5

Susan

,
, 1
'
S t a f f s , St.if f ManagersStaff.
, , , . ,
,
, , .

I 6.5. ,

, ,
. ,
, (. 5.27).
CREATE VIEW StaffPropCnt (branchNo, s t a f f N o ,
AS SELECT s.branchNo, s . s t a f f N o , COUNT{*)
FROM S t a f f s, PropertyForRent p
WHERE s . s t a f f N o = p . s t a f f N o
GROUP BY s.branchNo, s , s t a f f N o ;

cnt)

, . 6.5. , GROUP BY (

) (
).
234

II.

.

. ,
,
COUNT.
6.5. , StaffPropCnt
branchNo

staffNo

cnt

SG14

SG37

005

SL41

007

SA9

6.4.2. ( DROP VIEW)


DROP VIEW,
:
IDROP VIEW ViewName [RESTRICT j CASCADE]
DROP VIEW
. , Manager3Staff :
DROP VIEW Manager3Staff;
CASCADE, DROP VIEW
. , ,
. , DROP VIEW
, .
RESTRICT , , . RESTRICT.

6.4.3.
, , , . SQL ,
, ' ' .
StaffPropCnt, 6.5:
SELECT staffWo, cnt
FROM StaffPropCnt
WHERE branchNo = ''
ORDER BY staffNo;
6. SQL:

235


Staff PropCnt .
1. , SELECT , .
SELECT :
SELECT s . s t a f f N o AS staf::No, COUNT{*) AS cnt
2. , FROM ,
FROM :
FROM Staff s, PropertyForrRent p
3. WHERE WHERE AND:
WHERE s . s t a f f N o = p . s t a f f N o AND branchNo = ' B 0 0 3 1
4. GROUP BY HAVING
.
GROUP BY:
GROUP BY s . s t a f f N o , s.branchNo
5. ORDER BY
,
:
ORDER BY s.staffNo

6
:
SELECT s . s t a f f N o AS s t a J i f N o ,

COUNT ( * ) AS cnt

FROM S t a f f s, PropertyForRerit p
WHERE s . s t a f f N o = p.sta.':fNo AND branchNo = ' B 0 0 3 1
GROUP BY s . s t a f f N o , s.branchNo
ORDER BY S . s t a f f N o ;

. 6.6.
6.6. ,

staffNo

cnt

SG14

5G37

6.4.4.
ISO ,
SQL .
236

II.


, SELECT ORDER
BY , . , WHERE,
, . , StaffPropCnt, 6.5. cnt COUNT.
.
SELECT COUNT()
FROM StaffPropCnt;
, cnt ,
. ,
:
SELECT *
FROM S t a f f P r o p C n t
WHERE cnt > 2;

, WHERE cnt , .
'' . , StaffPropCnt ,
.

6.4.5.
, , , . , ,
, ()
, . .
StaffPropCnt, 6.5. , ,
INSERT ,
, SG5
:
INSERT INTO StaffPropCnt
VALUES (' 1 , 'SG5', 2) ;

PropertyForRent , ,
' SG5 ' .
, , .
PropertyForRent, .
6. SQL:

237

:
CREATE VIEW StaffPropLiat (branchNo, staffNo, propertyNo)
AS SELECT s.branchNo, s . s t a f f N o , p.propertyNo
FROM Staff s, PropertyForRent p
WHERE s . s t a f f N o = p. s t a f f No,-

:
INSERT INTO StaffPropList
VALUES { ' B 0 0 3 ' , ' S G 5 ' , ' P G 1 9 ' ) ;

, PropertyForRent ,
( postcode staffNo)
NULL (. 6.1). StaffPropList PropertyForRent, , .
ISO , , . ISO
, :
DISTINCT, .. ;
SELECT
{ , ),
;
FROM , ..
, .
,
.
, , (UNION), (INTERSECT) (EXCEPT) ;
WHERE -
SELECT, , FROM;
GROUP BY HAVING.
, , ,
,
. ,
,
, NULL.
NOT NULL,
. , , .
. S ,
- .
238

II.

6.4.6. WITH CHECK OPTION


, WHERE .
, ,
. , ,
,
WHERE. , , .
WITH CHECK OPTION CREATE VIEW. LOCAL/CASCADED , .. . WITH LOCAL CHECK OPTION,
, ,
,
, ,
. WITH CASCADED CHECK OPTION
( )
,
,
.
, , . , INSERT UPDATE ,
WHERE , .
, . , WITH CHECK OPTION , .

6.6. WITH CHECK OPTION


, 6,3:
CREATE VIEW Manager3Staff
AS SELECT *
FROM Staff
WHERE branchNo = ' B 0 0 3 '
WITH CHECK OPTION;
. 6.3. ' 1 ' B O O S 1 , , i'^ :
UPDATE Manager3Staff
SET branchNo = 'BOOS 1
WHERE staffNo = 'SG37';
WITH CHECK
OPTION, , .
, :
6. SQL:

239

INSERT INTO Manager3Staff


VALUES('SL15', ' M a r y ' , 'Black', 'Assistant 1 , ' F ' ,
DATE '1967-06-21',8000, ' B O Q 2 ' ) ;
WITH CHECK
OPTION, ,
Staf ( ' 0 0 2 ' ).
, Staff
Staff, ,
.
CREATE VIEW LowSalary
AS SELECT *
FROM Staff
WHERE salary > 9000;
CREATE VIEW Manager3Staff
AS SELECT *
FROM HighSalary
WHERE branchNo = ' B 0 0 3 1 ;

CREATE VIEW HighSalary


AS SELECT *
FROM LowSalary
WHERE salary > 10000
WITH LOCAL CHECK OPTION;,

Manager3Staf f :
UPDATE Managers Staff
SET salary = 9500
WHERE staffNo = 'SG371;
. ,
HighSalary, LowSalary,
HighSalary.
8 000 , ,
LowSalary. HighSalary WITH CASCADED CHECK OPTION,
( 9 500, 8 000 )
,
HighSalary. ,
,
, H;J
WITH CASCADED CHECK OPTION.

6.4.7.

, , .
SQL .
, , SQL. . 6.7.
240

II.

6.7. SQL

.

. .

,
, (, ,
, , ).
,
, .
,
, . , , , .
. , Client :
Client (clientNo, fName, IName, address, telNo, prefType, maxRent)

,
, ClientDetails ClientReqts:
ClientDetails (clientNo, fName, IName, telNo)
ClientReqts (clientNo, prefType, maxRent)

-
,
Client, ClientDetails
ClientReqts, clientNo:
CREATE VIEW Client
AS SELECT cd.clientNo, fName, IName, telNo, prefType, maxRent
FROM ClientDetails cd, ClientReqts cr
WHERE cd.clientNo = cr.clientNo;
\

6. SQL:

241


, , .


,
, .
.

, .

.


, ,
. ; , .

,
. .

CREATE VIEW ' WITH CHECK
OPTION, . , , WHERE ..
.

, SQL .

6.4.5 , , .

. SELECT * PROM..., *
, .
, ,
.
242

II.


. , . , , , ,

, .
.
, .

6.4.8.
, ,
6.4.3. .

, . , .
, , ,
. , .
, , , . .
.
.
,
, . , , :
CR3ATE VIEW StaffPropRent ( s t a f f N o )
AS
SELECT DISTINCT S t a f f N o

FROM PropertyForRent
WHERE branchNo = ' B 0 0 3 ' AND rent > 4 0 0 ;
,
, . 6.8. PropertyForRent
, rent ^ 400, . PropertyForRent
( ' P G 2 4 ' , . . . , 550, ' 0 4 0 ' , ' S G 1 9 1 , ' '),
. ,
( ' P G 5 4 ' , . . . , 4 5 0 ,
'039', 'SG37',
' ' )
6. SQL:

243

PropertyForRent , SG37. ,
, , PropertyForRent,
6.8. Staff PropRent
staffNo
SG37

SG14

PropertyForRent 1
( ' P G 2 4 , . . . , 550, ' 0 4 0 ' , 'SG19', ' ' ) ,
.
PropertyForRent
( ' PG5 4 ' , . . . , 450, ' 08 9 ' , ' i!G3 7 ' , ' 3 ' ) , , SG37, , , PG21.
, , PropertyForRent.
[146].

6.5.

ISO , COMMIT ROLLBACK.


SQL ( ) ,
DB2 IBM.
,
SQL, .
, SQL
SQL,
(, SELECT, INSERT UPDATE). ,
,
,
.
.
COMMIT .

. COMMIT
.
ROLLBACK , ,
. ROLLBACK

.
244

II.

SQL (. 21)
, COMMIT
.
SQL
,
.
SQL (.
19.4). SET TRANSACTION
.
:
.SET' TRANSACTION
:
." [READ ONLY \ READ WRITS} |'
[ISOLATION LEVEL READ UNCOMMITTED
REPEATABLE READ SERIALIZABLE3 :

READ COMMITTED

READ ONLY READ WRITE , . READ WRITE (


READ UNCOMMITTED). ,
, READ ONLY
INSERT, UPDATE DELETE ( ).

, .
( )

. 6.9.
6.9. ,

HEAD
UNCOMMITTED
READ COMMITTED

REPEATABLE READ
SERIALISABLE

SERIALIZABLE,
. , , . , 19.
.

6. SQL:

245

6.5.1.

SQL, .
INITIALLY IMMEDIATE INITIALLY DEFERRED.
, ,
[NO"] DEFERRABLE.
INITIALLY IMMEDIATE.
SET CONSTRAINTS
.
:
;''SET .CONSTRAINTS
, {ALL i constraintName [, ... ]}.{DEFERRED V]'IMMEDIATE}

6.6.
2.4 , , ,
, . SQL
GRANT REVOKE,
. , ,



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

AUTHORIZATION , (. 6.3.1),

.

,
.
ISO :
246

II.

SELECT ;
INSERT ;
UPDATE ;
DELETE ;
REFERENCES ;
USAGE , , . , . , [45].
INSERT UPDATE ;
, .
, REFERENCES
, (,
CHECK FOREIGN KEY), , .
CREATE TABLE ,
.
- . , , GRANT.
CREATE
VIEW, , .
SELECT
REFERENCES
, .
INSERT, UPDATE DELETE
, .

6.6.1.
( GRANT)
GRANT
.

. GRANT :
?

GRANT
VON

-{PrivilegeLisfl ALL PRIVILEGES}


ObjectName

: TO
{AuthorizationldList \ PUBLIC}
"[WITH GRANT OPTION]

PrivilegeList ,
, :
SELECT
DELETE
6. SQL;

247

INSERT [(columntfame [, . . . ] ) ]
UPDATE [(columnWame [, . . . ] ) ]
REFERENCES [(columntfame [, ...
USAGE

])]

, GRANT
ALL PRIVILEGES,
. PUBLIC, ^
,
, .
ObjectName ,
, , , .
WITH GRANT OPTION AuthorizationldList
.

WITH GRANT OPTION, , ,
.
,
. , ,
.

I 6.7.
Manager
staff.
GRANT ALL PRIVILEGES
ON Staff
TO Manager WITH GRANT OPTION;
Manager
S t a f f , ,
. , Manager
Staff , . WITH GRANT OPTION,
Manager
.

6.8.
Personnel Director SELECTn UPDATE
salary- staff.
GRANT SELECT, UPDATE (salary)
ON S t a f f
TO Personnel, Director;
WITH GRANT OPTION
, Personnel Director
.
248

II.

6.9.
PUBLIC
Branch.

GRANT SELECT
ON Branch
TO PUBLIC;
PUBLIC ,
( , ,
) ,
Branch. , WITH GRANT OPTION, .

6.6.2.
( REVOKE)
SQL GRANT REVOKE. ,
. REVOKE :
^REVOKE {GRANT OPTION FOR] {PrivilegeList \ ALL PRIVILEGES}''
; ON
ObjectWame
"PROM . . {AuthorizationldList \,PUBLIC} [RESTRICT |. \CASCADE] =
i'V - ' . ' - -

.'' " '

'

"

" -

-:

ALL PRIVILEGES ,
, , . GRANT OPTION FOR
, GRANT WITH GRANT OPTION,
.
RESTRICT CASCADE ,
DROP TABLE, 6.3.3.
, ,
( , , ). REVOKE ,
(, ), CASCADE. CASCADE, (,
, ),
REVOKE, DROP.
,
, REVOKE. , , . , . 6.1 ,
INSERT S t a f f ,
6. SQL:

249

WITH : OPTION ( 1).


( 2).
( 3). D ( 4).
INSERT ( 5),
, . , D.

REVOKE INSERT I GRANT INSIERT

GRANT INSERT
ON Staff
WITH GRANT OPTION

. 6.1. REVOKE

6.10. ,

SELECT,
Branch.
REVOKE SELECT
ON Branch
FROM PUBLIC;

6.11. ,

,
Director staff.
REVOKE ALL PRIVILEGES
ON Staff
FROM Director;

250

II.

REVOKE
SELECT ..., Director
.

ISO :
, , , / , .
SQL DDL . CREATE DROP SCHEMA . CREATE, ALTER DROP TABLE , . CREATE DROP INDEX
.
ISO SQL CREATE
TABLE ALTER TABLE , , ; ;
; (-) .
NOT
NULL. CHECK,
CREATE DOMAIN. PRIMARY KEY,
NOT NULL UNIQUE.
FOREIGN KEY,
ON UPDATE ON
DELETE. - CHECK UNIQUE. , ,
CREATE ASSERTION.
,
/ , / , . CREATE VIEW .
,
.

. , / .
.
, ; ().
. ,
, , -

. SQL:

251

. , .. , .
.
COMMIT , . ROLLBACK ,
,
.
SQL
, .
() . SQL . ,
G^ANT.
REVOKE.
USAGE, SELECT, DELETE, INSERT, UPDATE
REFERENCES,
. , WITH GRANT OPTION. GRANT OPTION FOR REVOKE.
(
6.1.
6.2.
6.3.
6.4.
6.5.
6.6.


.
, .
.
, ?

?
, SQL.

,
, 3.
6.7.
Hotel
SQL.
6.8.
Room, Booking Guest SQL :
) Single, Double
Family;
252

II.

6.9.

6.10.
6.11.
6.12.
6.13.
6.14.

) 10 100
;
) roomNo 1 100;
) dateFrom dateTo
;
) ;
) .
,
Booking, .
INSERT Book:, 3 , ,
1 2000 . Booking,
, , .
, Grosuenor.
Manager Director
,
.
Accounts SELECT.
.
, Hotel:
CREATE VIEW HotelBookingCount (hotelNo, bookingCount)
AS SELECT h.hotelNo, COUNTf*)
FROM Hotel h., Room r, Booking b
WHERE h.hotelNo = r.hotelNo AND r.roomNo = b.roomNo
GROUP BY h.hotelNo;
, , ,
.
a)SELECT *
FROM Hot e1Book ingCount;
) SELECT hotelNo
FROM HotelBookingCount
WHERE hotelNo = 'H001';
) SELECT WIN(bookingCount}
FROM HotelBookingCount;
r) SELECT COUNT(*)
FROM HotelBookingCount;
)SELECT hotelNo
FROM HotelBookingCount
WHERE bookingCount > 1000;
e) SELECT hotelNo
FROM HotelBookingCount
ORDER BY bookingCount;

6. SQL:

253


6.15.

:
Part

(partHo,

contract

partCost)

Part,
(
).
ExpensiveParts, ,
1000 :
CREATE VIEW ExpensiveParts
AS SELECT DISTINCT partNo
FROM Part
WHERE parCCost > 1000;

(partNo)


, Part.
6.16. , :
Supplier

(supplierNo,

partNo,

price)

, SupplierParts, , , , ;
CREATE VIEW SupplierParts (partNo}
AS SELECT DISTINCT partNo
FROM Supplier s. P a r t p
WHERE s . p a r t N o = p . p a r t N o ;

6.17.

6.18.
6.19.
6.20.

254

,
Part Supplier.
SQL , . ,
DDL ISO. , . ?
DreamHome,
3.2.6, ,
. 3.3-3.9.
, , SQL, 5.
Hotel,
3, ,
SQL, 5.7-5.28.

II.

...

(Query-by-Example QBE).
, QBE Microsoft Access.
QBE .
QBE .
QBE.
QBE,
, , ,
,
.
QBE
.
QBE
(Query-by-Example )
Microsoft Access 2000. QBE
, [331]. QBE
, , , .
QBE IBM 1970-
, .
,
, Microsoft Access. QBE Microsoft Access
. QBE
,
, ,
.

, . ,
QBE , , ,

.
.
3.3-3.9
DreamHome, 10.4 .
Microsoft Access QBE
SQL,
, SQL , . , SQL,
5 6. QBE, , SQL
Microsoft Access. SQL , 5 6.
QBE
Microsoft Access, Microsoft Access 2000
8. , 16 17
,
Microsoft Access.

.:.:.
,,,
. .
. . .

1119^19^^0*1

7.1 QBE, Microsoft Access. 7.2


QBE. 7.3
QBE (, ). ,
7.4 ( , ).

7.1.
Microsoft Access
Microsoft Access
(, , )
Database ( ). DreamHome
, , . 7.1.

, , .
, .
, , . Microsoft Access (dynaset).
, , . , . , , , .
256

II.

, Microsoft Access . . 7,1 , Access 2000.



. ,
SQL, QBE.

, *: ^ ; ^ J <

1 aP DreamHome : ( Access 2000}


- lz~ ftti !
,
j ] ; !
^

0]

, |jfp
(3

=; '

Branch

Client

PrivateOwner

PropertyForRent

Registration

Staff

Viewing
;

sjjj

.:

. 7.1. Database ( ) Microsoft Access


DreamHome
7.1. , Microsoft Access

7. QBE

257

. 7.1


(
, ,

)


. ,
,


SQL (
,
,
,
)



.
SQL, , ,
' (. 5 6),
.
, SQL,
SQL Server Microsoft Sybase

Microsoft Access
New Query ( ), . 7.2.

( Design View
()),
Access, .

. ,

.
.

KOHCTDVKTOC



_ -

. 7.2. New Query ( ) Microsoft Access


258

II.

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

7.2. QBE

.
, ( ). , . ,
, ,
.
, ,
, . 7.2.
Design View ,
- . , .
Select
Query ( ) , ,
Dream-Home.
/ , .
Select Query QBE.
.
,
. ,
, QBE.
QBE Microsoft Access
SQL. SQL SQL.
SQL , QBE
. ,
SQL, Microsoft Access,
SQL, 5 6.

7.2.1.
, , . , PropertyForRent (propertyNo),
(city), (type) (rent) QBE
?.

259

, . 7.3, . ,
PropertyForRent (. 7.3, ). SQL . 7.3, .
, . 7.3, Select Query
( ) (
PropertyForRent), QBE.
QBE,
() , .
, , , 7.3, ,
, , , .. ,
)


PropertyForRent

' *? ;

I |gl 1 :

prcpertyNo ___
street
city
:ostcode
]

QBE

<U
: propertyNo
: Prcp*rtyFoiRent
:
:

*:
:
:
:

city
ProoertvForRent

;
E

type
PiocertyForRenL

rent
Proper tyForfler*

._

rU
rl.1

propertyNt ), city, type rent

';

,,

[ 1 ! :
propertyNo

city

type

renl

'^~>

_PA14

Aberdeen

House

6501

PL94
I PG4

London
Glasgow

Flat
Flat

400
350J

PG36

Gla sgow

PG21
PG16

Gla sgow
Gla sgow

Flat
House

375
600!

III
&: "

' 'I

Flat

d.nMj " -

450
;

;;

;"

SELECT PropertyForRent.propertyNo, PropertyForRent.city,


PropertyForRent.type, PropertyForRent.rent
FROM PropertyForRent;

. 7.3. : ) QBE propertyNo,


city, type rent PropertyForRent; ) ; ) SQL

260

II.

, city 'Glasgow 1 .
QBE Criteria city. ,
.
Criteria, Access , AND () OR
().
QBE, Access AND. , , . QBE, Microsoft Access OR.
, .
,
, 350
450 , 'Glasgow'
Criteria ( ) city 'Between 350 And
4 5 0 ' Criteria rent. QBE . 7.4, .
, , , . 7.4, . SQL
. 7.4, ,
, , , ,
. 'Aberdeen'
or ' Glasgow' city. QBE
. 7.5, .
, , (. 7.5, ). SQL
. 7.5, . , , city 'Glasgow' ( And) rent 350 450 , ( Or) ,
city 'Aberdeen 1 ( rent).
, ,
LIKE.
. , ,
, ,
.
LIKE
Criteria city 'LIKE Glasgo 1 . 'Glasg*', . (*) . ,
, 'Glasg??'. (?) .
?.

261

7.2.2.
. , ,
.
,
; , QBE.
,
, , , ,
. 7.6, . ( :
PrivateOwner PropertyForRent) QBE.

propwtyTJo
street

'*
postcode

*:
: FropartyFcrRefit
:
;
:
:

QBE

ProoertvfprRent

ProPertvFoiRent

"Glasgow"

Between 350 Am] 450

,
And

And

SELECT PropertyForRent.propertyNo, PropertyForRent.city,


PropertyForRent.type, PropartyForRent.rent
FROM PropertyForRent
WHERE (((PropertyForRent.city)="Gl3sgow") AND ((PropertyForRent.rent) Between 350 And450));

. 7.4. : ) QBE , - ,
350 450 ; )
; ) SQL

262

II.

IBS? 3.j(i[nwt

a-irijitji: , i

H !] 3 1 1^

KM

sropettyNo j;
street

postcode

QBE

'

*]

. .rtwie: orocertvUo
: PropertyforRent
:
I ;
0
i:
:

uty
'rooeiCvForRent

tvoe
PropertyFotflent

rent
ProMrtyForfler*

_a

BMWen 350 And 0

"Glasgow"
"Abwdeenf-'s-

,

Or

,

And

^
^

Hja;11 .!. 114111. 1

:j,ni|i 1C

properiyNo

_ pA14
; Pb4
i PG36

_i.

PG1

-^

(
'

ly

Ctty : ='
Aberdeen

House

Glasgow
Glasgow
Glasgow

Flat
Flat
Flat

5 1*15

660
350
375
450

SELECT PropertyForRent.propertyNo, PropertyForRent.city, PropertyForRent.type, PropertyForRent.rent


FROM PropertyForRent
WHERE (({PropertyForRent.city)="Glasgow") AND ((PropertyForRent.rent) Between 350 And 450)) OR
(((PropertyForRent. city )="Aberdeen"));

. 7.5. : ) QBE
, 350 450 , , ; ) ;
) SQL
PrivateOwner fName INarae, PropertyForRent property-No city.
, ,
, . 7.6, 6. SQL . 7.6, .
(. 7.6),
() .
4.1.3 5.3.7.

?.

263

,
1:


PropertyForRent


PrivateQwner

Li? -.>[:1 ;

- ,
1 fName
Name
, address
telNo

LIJ
QBE grid

, 1 postcode
-I* type
\
rooms

HwEj^^^B

-1

:
,*J

~l

rent

&

ownerNc '
staffwo
\

F
; i 1
: ' TivateOwrier
;
;

:
.

- IName
PrlvateOwrief

D'opertyl^o
3
rooertvFwRfnt

dtv
PrjoertyForRenC

PropertyForRent

PrivateOwner

i.
| 1 :

fName

Joe
Carol
Tna
Tony
Carol
Tony

INarre
Keogh
Panel
Murphy
Shaw
Parrel
Shaw

.. : JiijJl"

''
properlyNo
! 14
F L94
;F G36
F G21
i G16

7 j.J.hjbj-Jto 7

'

t fl^^^v^^^^^^H

- city
Aberdeen
London
.Glasgow
Glasgow
Glasaow

^
jj

SELECT PrivateOwn erf Name, PrivateOwner.lName, Property ForRent. pro pertyN , Prop ertyForRent. city
FROM PrivateOwner INNER JOIN PropertyForRent ON PrivateOwner.ownerNo =
Property ForRent. ownerNo;

. 7.6. : ) QBE ,
,
; ) ; ) SQL
, , , .. Microsoft Access ,
. , . 7.6, Access 1, " ". -

264

, .
, , .
Access - ,
. , , QBE.
, . , . 7.6, ownerNo
( ) PrivateOwner
PropertyForRent. ,
.
Microsoft Access ,
.
QBE.

7.2.3.

. , ? ? ?

( ). Microsoft Access , (Sum),
(Avg), (Min) () , (Count). ,
Totals (), QBE Total ( ).
, , .
,
. , ,
,
. city,
Group By,
Count. QBE
. 7.7, ; . 7.7, ; SQL . 7.7, .
. , , ,
PropertyForRent,
(propertyNo), (city) (type).

(12).
QBE ' Yearly rent:

?.

265

[rent] *12', . 7.8, . ' Yearly rent:'


, (' [rent]*12')

rent 12.
. 7.8, . SQL . 7.8, .

7.3. QBE
Microsoft Access .
, :
;
;
;
, .
)

') :

;;:

prcpert>*to
street

tty
Bostcode

jj

QBE

PropiftyForRent

city,
,

propertyMo
PropertvFgrRent

propertyNo.
,

tjj5 1 : H.I (*

HHE3I

Count-prgpertyNo

Glasgow

4|

Londcn

: llljj'l

I _tMk! 3

SELECT PropertyForRent.city, Count(PropertyForRent.propertyNo} AS CountOfpropertyNo


FROM PropertyForRent
GROUP BY PropertyForRent.city;

. 7.7. : ) QBE ,
, ; ) ; ) SQL

266

II.

a)

IB" ! 3iipur M.I

^!
= '
Yearly Rent

; proportytto
sweet
:
f; city
, - >_ postcode
TI

Lu

2
. : ofODWtvNo
: propertvForfient
!
w :

:.;

otv
ProoertyforRent

tvoe
ProoectyForRent

Yearly Rent; FrentP

'

propertyNo,
city type


Yearly Rent

IV,
14
PG16
PG21
PG36
PG4

PL94

Aberdeen
.Glasgow
Glasgow
Glasgow
Glasgow
London

House
Flat
House

Flal
Flat
Flal

: _

7800
5400
7200
4500 j
4200
4800

) SELECT Property ForRent.property No, PropertyForRent.city,


PropertyForRent.type, [rent]' 12 AS [Yearly Rent]
FROM PropertyForRent;

, 7.8. : ) QBE ,
; ) ; ) SQL

7.3.1.
,
().
Criteria (
) , .
,
. , , , . 7.6, , ,
. QBE . 7.9, .
, 7.

' Carol Parrel',


, . 7.9, .

. 7.9, , SQL . 7.9, .
s? ! ;

owneitto
FName
Name
" J
address
jj

LJ

HlliiEil

. - '

=1

prcpertyNo
street
city
postcode
_^J

LZ__I
Done: :Name
Name
orocertyNo
: PrivateQwnet
PrivateOwner
PrceertyForRent
:
:
0
: ^Enter Owner's Frst Dams] [Enter Owner's Last name]
;

city
Proper tyForRent
:



f Name



IName

(d)

SELECT PrivateOwner. fName, PriuateOwner.lName, PropertyForRent. property No. PropertyForRent.city


FROM PrivateOwner INNER JOIN PropurtyForRcnt ON Privatedwner.ownerNo = PropetlyForRent.ownerNo
WHERE(((PrivateOwner.fName)=[Entei'Owner's First Name]) AND ({PrivateOwner.INameHEnter .
Owner's Last Name]));

. 7.9. : ) QBE ;
) ; ) , ; ) SQL

268

II.

7.3.2.

.

.
. CrossTab Query
Wizard ( )
QBE. , , , ,
.
, ,
, ,
. PropertyForRent .
, . 7.10, . ,
. 7.10, ; SQL . 7.10, .

.
Crosstab (),
QBE Crosstab ( ).
,
.
. 7.11, .
(. 7.11, ]. . SQL . 7.11, . ,
TRANSFORM SQL Microsoft Access SQL.

7.3.3.
Find Duplicates ( )
, ,
. ,
,
.

?.

269

I? 3iiipoc1 : *

,
-y

\
I .
L_
_^j
pjQ

Name
Warn*
position

;>:|

property) ^J
street
|
y
postcode
type
H
'r
_j

liLJ
'(Tow


CQOfHpOBKf

;.-.;

FName
Staff

IName
Staff

type
PropwtvForRerit

LI 1

-5
Ann
Ann

propertyNo,
,

type
Bungalow
Cottage
Flal

Bee:h

Mid-Terrace

Ann

Beech

Semi-Detached

David

Ford

David
David
David

Ford
Ford
Forrj

Bungalow
Cottage
Flat
Semi-Detached

Mary

Howe

Bungalow

Mary

Howe

Cottage

Mary
Mary

Howe
Howe

Flat
Mid-Terrace

Mary

Howe

Serni-Delached

>J >Ut*l ro 14

j^^^^^^^^^^^^H
Count-prQpertyNo ]

Ann

; .1 ill

Beech
Seech
:
Bee:h

fName, IName type,


,

1 11)1 'i>iiii>ui,l :
fName
- IName

prooertyNo
FrooettyForRent
Count

43
4
45
26
33
7
2
14
42
45
4
31
2
7

'"

SELECT Staff.fName, Staff.lName PropertyForRent.type, Count(PropertyForRent.propertyNo) AS


CounlOf propertyNo
FROM Slaff INNER JOIN PropertyForRent ON Staff.staffNo = PropertyForRent.staffN
GROUP BY Staff.fName, Staff.lName, PropertyForRent.type;

. 7.10. : ) QBE, ; ) ; )
SQL

270

II.

"

1 IS* 1
. |*^~'
stafffta
fNetne
Warne
position

,
prapertvfto -^J
\nreat
rty
-J
'
postcode
..*j
type
^J

propertyNo
;

1LJ
.
. .
'

IName
Staff

Name
Staff

fName IName

tyoe
PropertyFotRent

:=

Drccei (yNo
ProcertyFotRent
Count

type

TRANSFORM Count(PropertyForRent.propertyNo} AS CountOfpropertyNo


SELECT Staff .fName, Staff.lName
FROM Staff INNER JOIN PropertyForRent ON Staff.staffNo = PropertyForRent.staffNo
GROUP BY Staff .fName, Staff.lName
PIVOT PropertyForRent.type;

. 7.11. : ) QBE ; ) ; ) SQL


city, , . , -
'Carol Parrel 1 ,
. , .

, Find Duplicates Query Wizard
( ), , . 7.2. ( fName IName). ,
, . ,
QBE , . 7.12, . , 'Carol Parrel 1 ,
. 7.12, ff, SQL . 7.12, .
?.

271

, SQL ,
SQL SELECT, Criteria ( )
fName QBE . 7.12, .

7.3.4. ,

Find Unmatched Query Wizard ( ),


, . 7.2,
,
. , , - , Client Viewing.
.
, ,
QBE, . 7.13, . ? ! .

_|

ovmeftio
(Name
IName
address
teWo

*j

0 leparop SELECT SQL


)

j
3

LLJ
:
(*| ;
:
1 :

fName
PriveteO iner

;;

IName
PrivateOviner
<

ounerNo
PrivateOwner

adCreii
PrivateOwner

telNo
Prival.eOwner

In (SELECT [fName] FR

,. 1


fName IName

||3 ! :
ft'Jame

Parrel

Carol

Farrel

*
: ..1

IName

^
ownerNc

address

097
C087

I
telNoI

6 Achray St, Gl 0141-357-7419


6 Achray St, Gl 0141-357-7419

1 >..].H.| _*Jn=2 - .,

,.. .- -

SELECT PrivateOwner.fName, PrivateOwner.lName, PrivateOwner.ownerNo. PrivateOwner.address.


PrivateQwner. telNo
FROM PrivaleOwner
WHERE (((PrivateOwner.(Name) In
(SELECT [fName]
FROM [PrivateOwner] As Imp
^ GROUP BY [fName],[IName]
HAVING Count(')>1 And [IName] = [PrivateOwner].[IName])))
ORDER BYPrivateOwner.fName, PrivateOwner.(Name;

. 7.12. : ) QBE ;
) ; ) SQL

272

II. .

. 7.13, . ,
Client , Viewing
. 'Mike Ritchie '.
, Show box clientNo QBE
, . SQL . 7.13, .
, , , 4.1.3 5.3.7.

7.3.5.
.
, , Microsoft Access , . , , a) [i|ij? ! :

gSi;;,,,

(;; >;<:.- '


clientNc
." fName
; iName
telNo

- |'^!

- * clentNo
DropertyNo
viewDate
_^j
comment

: clientNo
. : Client
:
:
:

,,"->

,^, -

fMame
Client
3

IName
Client
El

"

3^fj

.
tdNo
Client

^j
clientNo
Viewina

ElNul


clientNo, fName, IName telNo

6)

! :
client No
fName
IName
Ritchie
jJcR74(_
Mike
: 1 ' i *
i .>..1

Client,

foi* !,:
tetNo
Viewing
1

01 475-3921 78

SELECT Client.clientNo, Client.fName, Client.IName, Client.teINo


FROM Client LEFT JOIN Viewing ON Client.clientNo = Viewing.clientNo
WHERE {({Viewing.clientNo} Is Null));

. 7.13. : ) QBE ,
; ) ; )
SQL
?.

273

( staf fNo),
PropertyForRent Staff,

.
, .
QBE
, " ",
, . , . , ,
PropertyForRent Staff, staffNo ( )
PropertyForRent. QBE
. 7.14, . . 7.14, , , , .
,
(, ' SA9). , Microsoft
Access Staff ,
Mary Howe. SQL
. 7.14, .

7.4.

Microsoft Access , Query ( ) . .
, ,
, , .
, , . .
: , , .

7.4.1.

.
. ,
,
. . , , ,
, .

274

II.

]
type

gOM

staff No ( )
PropertyForRent

turn

rent
owner Ivo
staff Mo

.:' 'I.,

JJ
ProBHtyForRsnt
:
t-a !
> :
' :

street
(Tojertvfnrftent

PTOIMrtvFC'RWlt

slaffNa
SrcDertvFarRHV

ctY

Staff

^~

.1

'-

PropertyForRent,

6)

"Wffl

'Man*
Staff

1 1 :

proper! 'No
| PA14
I PL94
PG36
PG21
PG16
./ PG97

street
16 Halhead
Argyll St
2 Manor Rd
18 Dale Rd
5 Novar Dr
Muir Drive

Staff,

city
Aberdeen
London
Glasgow
Glasgow
Glasgow
Aberdeen

staffNo
SA9
SL41
SG37
SG37
SGH
5H3

^ Six

fNa me
Mary
Julie
Ann
Ann
David
Mary

IName
Howe

Lee
Beech
Beech
Ford
Howe

Ban*;' JiL J I j ^ ' 6 > .;|H in>t MS 6


:

1 L



staffNo
fName IName ,
'SA91
'SA9'
staffNo

SELECT PropertyForRent.propertyN'o, PropertyForRent.street, PropertyForRent.city.


PropertyForRent. staff No, Staff. (Name, Staff.lName
FROM Staff INNER JOIN PropertyForRem ON Staff.staffNo= PropertyForRent. staff No;

. 7.14. : ) QBE ;
) ; ) SQL
, S t a f f C u t ,
staffNo, fName, IName, position salary, Staff. , s t a f f . Design View Make Table (
...), ,
. 7.15, . . . 7.15, QBE .
, .
. 7.15, . , StaffCut, , 7.15, . SQL . 7.15, .
?.

275

f fiase

31

1 :

Name
position

00

sabry

^J

'

jj

ULJ
: staff
^' 5WFF
:
'
:

3Biin:
:
/
:
;
:

No

IName
Staff

Staf-

0
0

1^1

jx^tipn
Staff

1-1

salary
Staff

L_

___

(3

;T

Staff, Staff Cut

) ) " : 6.
'__ S

""
- .

..

SG37

StaffCut

1^^^^
^^|
slaflNo
INama

SL21

ZSAS

sG5

VJ

John
Arm
David

tName-

White
Baech
Ford

posttiorv

salary

Manager

30000
12000
16000
9000
240
9000

Mary

Howe

Assistant
Supervisor
AssislariT

Susan
Julie

Brand
Ue

Manager
Assistant

, Staff

SELECT Staff .statINo, Staff .fName, Staff.IName, Staff, posit ion, Staff .salary INTO StaffCut
FROM Staff;

Puc. 7.15. : ) Make Table ( );


) QBE ; ) ; ) , ; )
SQL

276

II.

7.4.2.
. ; ,
" "; ,
" ", , .
, , , , .
PropertyForRent. Design View
Delete (). QBE . 7.16, . PropertyForRent Viewing
" ", Cascade Delete Related records, Viewing, ,
. ,
.
. 7.16, . , PropertyForRent, ,
Viewing,
. 7.16, . SQL . 7.16, .

7.4.3.

. , ,
10%. ProperyForRent. Design View
Update (). Update To ()
rent ' [rent]*!.!',
. 7.17, . (. 7.17, ), .
, rent PropertyForRent
(. 7,17, ). SQL . 7.17, .

7.4.4.

. ,
.
( ) ,
. , ,
PrivateOwner
7. QBE

277

, . ,
NewOwner, ownerNo, fName, IName address. , PrivateOwner ,
. PrivateOwner , NewOwner .
,
, NewOwner.
Append (),
(. 7.18, ),
.
QBE
. 7.18, . (. 7.18, ).
.
, PrivateOwner
, NewOwner (. 7.18, ).
SQL . 7.18, .

7.1.

7.2.

278

DreamHome,
. 3.3-3.9,
, QBE,
, .
QBE
DreamHome,
QBE, , :
)
;
) , , '03 ';
) ,
;
)
25 ;
) , , , ;
) ;
) , , .

1|:1 :

propertyNo
street
city
postcode
^j

QBE

: ProoertyForRent.*
tfm> : PropertyFcrfient
:
:
;

.11..

-"

dty

PrODertyFotRent

"Glasgow"

---'

; ; _.

! Miciosolt Access
! ; 4.
'' mnei lei am .
.

;.'' ')''',

,-

HW I

Propef tyFoi Rent :

>

|
1

properlyNo

* PG37
* PL94

: Jijjjj

street
16 Holhead
Muir Drive
Argyll St

city
Aberdeen
Aberdeen
London

postcode
AB75SU

HW2

; ;

> JHJn

^jj


PropertyForRent,


(
)



,



Viewing :

chentNo
B?ag
CR62

propertyNo
vipwOale
PA14
24-May-01
PA14
14-May-01

IF? ( 531
:

commsnl j
too small
no dining room

Viewing,


ri

(
(c

DELETE PropertyForRent/, PropertyForRent.city


FROM PropertyForRent '
WHERE (({PropertyForRentcityKGIasgow"));

. 7.16. : ) QBE ;
) ; ) PropertyForRent
Viewing ; ) SQL

?.

279

If J 1 sanooc Ri*!E3l|

&^!^">' .' "

postcode

Zj

property!*
street


^1

.1LJ

QBE

: rent
: ProoertvForRent

:
1

iMicmsnft Access

^
I
H ^

,

rent

10%

HHtxl

: 6.
i\ \ "" * .
- ' ,

r:::.At:..,_ii
'

HST

yp :1 :
properlyNo
\ 1

PG16
PG21
PG36

PG4

PL94

: J* | ill

street

16Holiead
5 Novar Dr
18 Dale Rd
2 MamrRd
6 Lawience St
6 Argyll St

city

rent

715
495
EGO
412
365
440

Aberdeen
Glasgow
Glasgow
Glasgow
Glasgow
London

I JULtli^],

.-1*

. -:. .-

rent,
10%

UPDATE PrapertyForRent SET PropertyForRent.rent = [rent]*1.1;

. 7.1 7. : ) QBE ; ) ; ) ; ) SQL

280

II.

j
:, [^^

WO

'. I .V

-lU

: -

>

QBE


(] NewQwner

.

: 2 "" on
^ *

0121
0123
0125

121

Anne
Dave
Annel

Andrew
Arme
Tina

C046
C087

Jce

C037

Carol

Carol
'

..

Barnelscr
MacGregoi
Sinclair
Nollirigham

.Barnatson
MacGreg
.Murphy
Keogh
Parrel
Shaw
Parrel

9 Long Road, Gta^af/ G46 6WQ


34 Jordanhiil A.enue, Glasgow G1D 7
lATuiberry Road, Aberdeen 7
12 Spey Drhe, Edinburgh EH6 8JH

I

.
,

PrivateOwner

944 Long Road, Glasgow G45 BWO


34 JO'Oanhill Avenue. Glasgow 61D 7GH
63 Well St. Glasgow G42
2 Fergus Dr. Aberdeen AB2 7SX
6 Achray St, Glasgow G3290X
12 Park PI. Glasgow G4 OUR
6 Achray St. Glasgow G329DX

INSERT INTO PrivaleOwner (ownerNo.fName, INarne. address)


SELECT NewOwner.ownerNo, NewOwner.fName, NewOwner.lName, NewQwner.address
FROM NewOwner
WHERE (((NewOwner.address] Like '"Glasgow"));

Puc. 7.18. : ) Append; ) QBE


; ) ;
) Wen/Owner PrivateOwner ;
) , SQL

7. QBE

281

7.3.

7.4.

QBE
DreamHome, QBE, ,
:
) , ,
;
) ,
, ; ;
) PropertyForRent, , 'Carol Parrel' '
Shaw' .
, , . ,

,
;
) Staff: , 1
'David Ford .

;
) , , ,
;
) ,
PropertyForRent
,
.
DreamHome,
QBE,
, :
) PropertyForRent PropertyGlasgow, propertyNo,
street, postcode type
, ;
) Viewing
Comment;

7.5.

282

) 12,5% , ;
) NewClient,
; Client.
DreamHome, QBE SQL,
5.

II.


:
ACCESS ORACLE
...

Microsoft Access:
;
;
;
;
().
Oracle:
;
;
;
PL/SQL;
;
.

3,
.
15-20
( 50 ),
25%. .
.
, .
: Microsoft Access Oracle. (
, 3).

Microsoft Access 2000


Microsoft Access Microsoft
Windows , Microsoft Access , ,
. Access , ,

(Graphical
User Interface GUI); , Microsoft Access
VBA (Microsoft Visual Basic for Applications). ,
Access , (Wizards),
, - .
Access (Builders),
, SQL. Access SQL, 5 6,
Microsoft ODBC (Open Database Connectivity
), SQL, Oracle Informix.
ODBC 21.3. Microsoft Access , .

8.1.1.
Microsoft Access , .
, . Microsoft ( )
( }.
,
. ,
. .
,
.
.
( ) Web, (
Microsoft Access Microsoft SQL Server)
Internet ( ).
,
Microsoft Excel.
, , . , .
VBA,
.
, Microsoft Access.

8.1.2. Microsoft Access


Microsoft Access ,
284

II.

Access 2000 (data


engines): Jet Microsoft
Data Engine (MSDE), Microsoft BackOffice SQL Server
( Microsoft ). Jet ,
, , , ,
,mdb, ISAM (Indexed
Sequential Access Method - - ) (.
). MSDE ,
Microsoft SQL Server, Windows 95, ( ), Windows
2000 Server. MSDE
, SQL Server. SQL Server 7.0 MSDE
2 .
Microsoft Access, SQL Server, , , 2 ,
DOS.
.
, Memo ( ) OLE
. Access
. , .

. :
. , , , .
,
( ISAM),
.. ,
.


Microsoft Access .
/. Access
, . Access.
/. Access ,
ODBC , SQL
Server. Access 2000 . adp
(Access Project File), , ,
VBA
SQL Server, OLE DB
, , 8. : Access Oracle

285

. , MSDE.
.
Access . .
,
(replica) , (Design Master). (replica set).
. ,
. 23.6.
Web. (
) ,
Access SQL Server. Internet Explorer 5 . 28.10.5.
,
.
Jet . Idb ( locking
database file ),
, . , . 19.2.

8.1.3.
Microsoft Access () .
Database Wizard ( ) , ,
. Database Wizard ,
, .
Table Wizard ( )
, , , .
(
datasheet).
Access
.
Design View () .
CREATE TABLE ( )
SQL View.
286

II,

Microsoft Access
SQL
6.3.2 SQL CREATE TABLE, . Microsoft Access 2000
SQL, CREATE TABLE Access DEFAULT CHECK. , SQL, . , . 8.1, Access SQL. 6.1 6 ,
PropertyForRent SQL. . 8.1 SQL View Access.
8.1. Microsoft Access

(text)

/, ,
, .
(character)
SQL (. 6.1.2)

255

(memo)

64000

(number)

,
,
, (
(currency)).
(exact numeric)
(approximate numeric)
SQL (. 6.1.2)

1, 2,4 8 (16
ID )

/
(Date/Time)

.
(datetime) SQL(CM. 6.1.2)

(currency)


(autonumber) ( 1) ,

4 (16
ID )

/
(Yes/No)

,
, / (Yes/No), /
(True/False), / (On/Of f).
(bit) SQL
(, 6.1.2)

OLE

( Microsoft Word,
Microsoft Excel, ,
),
, OLE,
Microsoft
Access

64000

8. : Access Oracle

287

. 8.1

Lookup Wizard
,
(

)

(combo box).
Lookup Wizard,
,

,

,


( 4
)

! ! :
CREATE TABLE PropertyForRent(propertyNo VARCHAR(S), street VARCHAR(25) NOT NULL, city VARCHAR(IS) NOT NULL,
postcode VARCHAR(8), type CHAR NOT NULL, room-; 5MALLINT NOT NULL, rent NUMBER NOT NULL,
owner* VARCHAR(S) NOT NULL, staff No VARCHAR(S), branchNo CHAR{4) NOT NULL,
CONSTRAINT pkl PRIMARY KEY (propertyNo),
:ON5TRAINT fkpfrl FOREIGN KEY (ownerNo) REFERENCES Owner (owner No),
CONSTRAINT fkpff2 FOREIGN KEV (staff No) REFERENCES Staff (staff No),
CONSTRAINT fkpfr3 FOREIGN KEY (branchNo) REFERENCES ranch (branchNo));

. 8.1. PropertyForRent SQL View


( SOL)

Microsoft Access
Design View
. 8.2 PropertyForRent Design View (). , , Design View , ,
.

IvJpropertyNo
Lljitreet
LJcit
postcode

SktCTiebti

^lype

:
*

.
i 100

_X rent
ounenNo

_ staff*
LJbfar*4*i

rooms

1 15

1

. .
-*!*

-
^ raff .'

'

!
*

;
' -
1
',

, 1
;> )


! ,
Hontp , so on lepe

S
.!_'

:
4
--lind^-LS

t * - 1 15
hei
he

' ^ -t
.
/ fl ,

. 8.2. PropertyForRent Design View

288

II.

Microsoft Access
Field Properties ( )
Design View. ,
, . ,
, , Field Size ( ). ,
. Design View , .
.
Field Size
Field Size , (Text), (Number)
(AutoNumber). , . 8.2,
Field Size propertyNo 5 , Field Size rooms ,
0 255. ,
:
Integer ( ) 16- ( -32768
32767);
Long integer ( ) 32- ;
Single ( ) ,
32- ;
Double ( ) ,
64- ;
ID () - - 128- , , .
Format
Format ( )
, , . Microsoft Access . ,
/ (Date/Time) , (Short Date), (Medium
Date) (Long Date). 1 1933 01/11/33 (Short Date), Ol-Nov-33 (Medium Date) 1 November
1933 (Long Date).
Decimal Places
Decimal Places ( ) (
, ).
Input Mask
Input Mask ( ) ,
, . , .


8. : Access Oracle

289

. Microsoft Access
. , ,
propertyNo, : ' 1
, ( Property),
, , . (, 9, PG21, PL306).
' \P>L099 ':
' V , , ,
(, \ );
' >L' , , ,
;
' ' , , ' 9 ' .
Caption
Caption ()

. ,
1
Property Number' ( ) Caption
propertyNo, Datasheet View Property Number, , 'propertyNo 1 .
Default Value
Default Value ( )
,
. , . 8.2, , rooms 4.
Validation Rule/Validation Text
Validation Rule ( )
, . , , Validation Text
( ) . . , .
, 1
15. rooms . 8.2.
Required
Required ( ) . ' Y e s ' , , (NULL). Required
NOT NULL SQL (. 6.2.1).
.
290

II.

Allow Zero Length


Allow Zero Length ( ) , ,
("") (
). , Microsoft Access
(NULL) ,
, Allow Zero Length
Required ' Y e s ' . Allow Zero Length
Required. Required , . Allow Zero Length
' Y e s 1 ,
Required.
Indexed
Indexed ( )
. ,
(
). , .
Indexed :
No
(Duplicates OK)
( Duplicates)

( )

16 5.3 , DreamHome
.

8.1.4.
. 8.1, Microsoft Access
CREATE TABLE SQL. Relationships ( ).
, , . Access .
. 8.3, , " " (1:*) S t a f f
Manages PropertyForRent, . 8.3,
Relationships . Microsoft Access .
1, " " (1:*) ,
; " " (1:1) , .
2.
, NO ACTION
CASCADE (. 6.2.4). , ,
, Access, .
8. : Access Oracle

291

.
.! /
S I


/;

VWc

,


,

ON UPDATE CASCADE

X/
/

/satpoT,

_iJ staffNo

* j
7 jjTac )
~
w ;

! -->

1-

31

*-

tropettyNo
street
City
postcode
type
rooms
rent
owner No

3
.1.111..
IName
position
sen

salary
branchMo

branchlJo

LLJ.

___

'

Puc. 5.3. : )

, "
"
Staff
Manages
PropertyForRent ( ,
); )
" " Staff Manages PropertyForRent

8.1.5.
Microsoft Access , ,
;
;
Visual Basic for Applications (VBA).
8.1.3 .
.


. ,
. , -

292

II.

. , DreamHome : 90 1 .
Lease (),
:
[dateFinish]-[dateStart] Between 90 and 365
. 8.4 Table Properties ( ) Lease.
if]*

I
,.,,,,,...,.,
.
. . . .
; ,...
. . . . . . . . . .
.....
' ,
, ^ . . . . . .
; , . . , , . , ,
^
-. .
,

^
;
|{rentfinish]-[rentS(:art] Between 90 And 365
I

. 8.4. Microsoft Access

VBA
DreamHome , 100 . , ,
.
Access . , . Microsoft Access , , ,
. .
(. 8.1.8),
, ,
. 8.1
BeforeUpdate,
.
8.1. VBA ,
100
Private Sub Form_BeforeUpdate(Cancel As Integer)
Dim MyDB As Database
Dim MySet As Recordset
8. : Access Oracle

293

Dim MyQuery As String


1

,
. staffNoFieud -
MyQuery= "SELECT staffNo FROM PropertyPorRent WHERE staffNo = '" + _
staffNoField +
1

Set MyDB= DBEngine.Workspaces(0).Databases(0)
Set MySet = MyDB.OpenRecordset; (MyQuery)
1

, >- ,
RecordCount
If {NOT MySet.EOF) Then
MySet.MoveLast
1
100,
1

If (MySet.RecordCount = 100) Then
MsgBox " 100 "
Me.Undo
1

End If
End If

MySet.Close
MyDB.Close
End Sub

-
,
, 8.1,
VBA. , , .

8.1.6.
Microsoft Access , , .
, (controls)
(control objects). , , (text boxes) , (labels) ,
(command buttons) . . ,
,
Access Control Wizard,
, .
(Form Header). , , (title).
(Detail).
.
(Form Footer), , , (total).
294

II.

, ,
(subforms). , , ( )
( ). , ( "
" Branch Has Staff).
: Design View (), Form View
( ) Datasheet View ( ). . 8.5 Design View, ,
(toolbox)
, . Datasheet View
, Form View . . 8.6
Datasheet View, Form View.
l a i 'i'ui)M.ii : 1)(,1

(*12

, i .i . , .. i .. i .4 i i.

1*

'

i ' 9 - ' W i 11 ^1


[]

~3

i
J

* *
branet No"

stmet

Cttji

i
3

poslco de

| branchNo

_J

,

,

stieel
dtv

poslcdde

^56 i

-:

- . -i

. 8.5. Design View

Access
, . Access
(Form Wizard),
, :
;
, ;
(, ,
);
, ;
.

8.1.7.
Microsoft Access Reports ,
, .
. , Access Reports
8. ; Access Oracle

295

;
;
;
.
, Report's Design View
, .
(Report Header). ,
, , (title).
' (Page Header) ,
,
(column headings).
(Detail) ,
.
(Page Footer) , , .
(Report Footer) , , , .
, ,
,
. .
(Group Header) ,
, ,
.
(Group Footer) , , .
Datasheet View,
Design View, (Print
Preview) (Layout Preview). . 8.7 Design View, , . . 8.8
Print Preview. Layout Preview Print Preview,
, .
IBB !

"

>
002
BOQ3
005
007

56 Clover Dr
163 Main St
32'ManseRd
22 Deet RA
16 Argyll St

London
Glasgow
Bristol
London
Aberdeen

NW10 5EU
011
BS913 1WZ
SW1 4EH
AB23SU

branch No

street

66 Clover Dr

city

London

ooslcode

NW106EU

: JjLLUI

>'

>*! HJ 5

. 8.6. : ) Datasheet
View; ) . Form View

296

I E .

' e i / i ! i ' i *( --



Report Header,

Page Header,


Group Header,

branchNo
Detail,

Group Footer
branchNo,

rent
Page Footer,


Report Footer,


rent no

. 8.7. Design View

;' Pt opertyf tf Rent


braucANo

Property M Type

No ofRoaias

Rent

~SG
PG16

PG3P

PG4

PG21

Summary for BO&3

450.00
600.00
375.00
350.00

1/75.00

BOOS

PL94

Summary for SOOS

400.00 ,
400.00

B007
PAH
Sa.mm aryfor B6&7

550.00
850.00

. 8.8. PropertyForRent
, branchNo,
Print Preview

8. : Access Oracle

297

Access
. Access (Report
Wizard), , :
;
, ;
, , ;
, ;
;
, ;
.

8.1.8.
, Microsoft Access
. Access
:
, , , , ;
, , , ,
;
, (
, ,
..), , (
);
, , ,
.
Access , .
8.1,5,
.

, . ,
Access. , Print
(), Close (), Applyl r ilter ( ).
, SelectObject,
,
. ,
, , (action arguments), ,
. ,
SetValue, , , , , ,
. , (pop-up message box), .
298

II.

. 8.9 , ,
.
, ;
100.
, VBA
(. 8.1). ,
, PropertyForRent (Forms ! PropertyForRerit " s t a f f No). 100, RunCommand Save ( ),
StopMacro. MsgBox, , CancelEvent, .
DCOUNT
SELECT COUNT ( * ) ;

( . . . ) Condition , .
SetWarnings, RunCommand StopMacro,

D C O U N T ( " * " , "PropertyForRent", " [ s t a f f N o ] =
Forms 1 P r o p e r t y F o r R e n t J s t a f f N o " ) < 100

MsgBox CancelEvent.

8.2. Oracle 8/8i


Oracle
. Oracle .
10 , -

cmdAddjdfck

[)^"^^

SstWamincg:
- Run Command
StopMeero

Cance vent

Add Staff Record Check

. 8.9. , , 100

8. : Access Oracle

299

145 . Oracle . 80% 400


Oracle
(e-Business) [242].
Oracle Applications
, (e-Commerce), , (, ), ,
Internet, , , , , ,
, , , .
1970-, , Oracle , 1997 Oracle 8 ,
. 1999 Oracle 8i
Internet. Oracle 8i , . 8.2.
8.2. Oracle 8i

Oracle 8i

Oracle

Oracle,8i Enterprise Edition

Oracle
, ,
;
OLTP (Online Transaction Processing
)

Oracle 8f Personal
Edition

Oracle,
, Oracle Si/Oracle 8i Enterprise
Etfition

Oracle 8i Lite


()

Oracle , .
Oracle (Oracle Parallel Server).
, , , (Symmetrical Multiprocessing SMP).

. Oracle
Parallel Server SMP,
.
Oracle (Oracle Application Server). Web, Web-, . Oracle Application Server 28.
300

II.

Oracle JServer. Oracle


Java Oracle 8i. Java,
Java,
CORBA (Common Object Request Broker
Architecture ), Enterprise
JavaBeans (EJB), Java JavaServer Page (JSP). JServer Internet (Internet
Inter-Object Protocol HOP) (HyperText
Transfer Protocol HTTP). Oracle
JDeveloper, Java . JServer
28.
iFS. Internet Oracle (Oracle Internet File System -~ iFS)
Oracle 8i
,
, , ,
,
mferMEDIA, Oracle 8i , ,
, , (locator).
interMEDIA Web-,
Web, Web- () (streaming media servers).
(Visual Information Retrieval). ,
, , .
(Time Series). .
, .
(Spatial). , .
WebDB. HTML (HyperText Markup
Language), Web- Web-.
(Distributed database features).
. ,
.
Oracle 22 23.
(Data Warehousing), , , ,
,
.
Oracle 30 31.

8.2.1.
Oracle , , .
8. : Access Oracle

301

(Tables). , .
Oracle .
(tablespace)
(. 8.2.2).
(Objects). ;
Oracle. 6.1, SQL
: , .
, .
- Oracle 27.
(Clusters). , .
, , ,
.
. , 5.2 16.
(Indexes). . Oracle 8 ,
(index-only table), , .
, 5.3 16.
(Views). ,
,
(. 6.4).
(Synonyms). .
(Sequences). Oracle
.
, , ,
,
, .
(Functions).
SQL PL/SQL,
.
(Procedures).
, , ,
. SQL , SQL,
.
(Packages). , ,
SQL,
.
(Triggers). (),
() ,
.

, Oracle.

302

If.

8.2.2. Oracle
Oracle /, 2.6.3. Oracle ( ,
) (instance)
( , ). .
, ,
, ,
Oracle. , .

Oracle
Oracle
(tablespaces), (schemas), (data blocks) /
(extents/segments).

Oracle , . . ,
.
Oracle SYSTEM, .
SYSTEM ( Oracle
) .
SYSTEM. , ,

(. . 16.1 16.2 16).
. 8.10 Oracle,
SYSTEM USER_DATA.

CREATE TABLESPACE, :
CREATE TABLESPACE user_data
DATAFILE 'DATA3.ORA' SIZE 100K;

CREATE TABLE ALTER TABLE, :
CREATE TABLE PropertyForRent
TABLESPACE user_data;

(propertyNo VARCHAR2(5) NOT NULL,...)


, ,
,
(user account). 18.4 , .

8. : Access Oracle

303

,
{
(user) ( username) ,
,
. ,
, , ,
.
() .

( Oracle Forms SQL*Plus) ,
username, .

. , ,
, .
, . ( ,
:
, .)
,
(data block) ,
Oracle .
.

Oracle

, 8.10. ,
Oracle

304

II.

Oracle
. ( ) .
.
(Header). ,

(Table directory). ,
.
(Row directory).
.
(Row data). . .
(Free space). , . , , PCTFREE PCTUSED,
.
,
Oracle, .
(extent). , .
(segment). , . ,
, . . 8.11 , . Oracle , . ,
.

Oracle
Oracle
(datafiles), (redo log files)
(control files).

2

8 ,

4

32 ,.

8 24

. 8.11. , Oracle

8. : Access Oracle

305


Oracle
.
( ).
. 8.10, .
Oracle
. , , , .

Oracle
,
.
, . 19.3.

Oracle ,
, , . , (
).
.

PCTFREE PCTUSED
, PCTFREE PCTUSED,

. ( ).
PCTFREE ( ).
.
PCTFREE. , , : ( 10).
PCTUSED. ,
, , Oracle
( 40).
, PCTFREE,
Oracle ,
PCTUSED. , Oracle
,
.
PCTFREE
. ,
,
306

II.

/ . PCTUSED
,
/.
, PCTFREE PCTUSED 100.
100, ,
, , 100%
, . , 2048 100 , 390
( 20% ),

PCTFREE PCTUSED, 80%. , 100%, Oracle
, PCTFREE, . PCTFREE PCTUSED . 8.12.

Oracle
Oracle Oracle (shared memory), . Oracle,
,
. 8.13. , Oracle ,
.
, (System Global Area SGA) (Program
Global Area PGA).
. SGA
, Oracle. SGA Oracle Oracle.
SGA , .

PCTFREE 20% PCTUSED 40%



80%,
PCTFREE ,
20%
,




,
.


,

40%

. 8.12. PCTFREE PCTUSED,


PCTFREE 20%, a PCTUSED 40%

8. : Access Oracle

307

(Database buffer cache). .


, ( ); ,
, ,
( ).
-
, ,
.
19.3.2.
(Redo log buffer).
,
(. 19.3).
(Shared pool). ,
SQL
. SQL. SQL, SQL
, . 20.
(Program global area). PGA
,
Oracle. PGA Oracle.
(User processes).
Oracle
(, SQL*Plus Oracle Forms). ,
Oracle, , ,
, ,
.
Oracle. Oracle ( ) . Oracle
: (
)
( -
). . 8.13 .
(Database Writer DBWR).
DBWR () SGA (datafiles) . Oracle DBWR DBWODBW9 - . Oracle , " " (. 19.3.4) , DBWR
, ,
.
308

(Log Writer LGWR). LGWR .


(Checkpoint ). , DBWR (. 19.3.3). DBWR , , ,
..
. , , LGWR.
(System Monitor SMON). SMON
Oracle
, ,
- . ,
SMON ,
.
(Process Monitor PMON). PMON
, , .
,
(, ), ,
.
(Archiver ARCH). ARCH
.
ARCH, ARCO-ARC9.
LWGR
.
(Recoverer RECO). RECO
,
(. 23.4).
(Dispatchers ttnnn). Dnnn

. ,
(Multi Threaded Server MTS), ,
, Dnnn .
(Lock LCKO). LCKO , , " Oracle" (Oracle Parallel Server).
(process)
. .

,
, Oracle , ,
8. : Access Oracle

309

, .
Oracle (communication program) NetS, .
NetS , TCP/IP, LU6.2. DECnet
SPX/IPX, , ,
, , .

LCKO
RECO
PMON
SMON

ARCO
DBWO
LGWR

. 8.13. Oracle ( Oracle)

310

II.

1.
. , Net8.
2.
() .
3. SQL, ,
.
4. SQL, SQL. SQL
,
() ,
SQL ;
, SQL .
5.
() ,
SGA.
6. SGA. DBWR
.
LGWR .
7.
.
8. , , . , Oracle

, .

8.2.3.
6.3,2 CREATE TABLE SQL.
Oracle 8 CREATE TABLE SQL, :
(primary keys), PRIMARY KEY;
(alternate keys), UNIQUE;
(default values), DEFAULT;
(not null attributes), NOT
NULL;
(foreign keys), FOREIGN KEY;
,
CHECK CONSTRAINT.
27.6, Oracle 8 , . , . 8.3,
SQL.

" 8. : Access Oracle

311

8.3. Oracle

char(size)

(
1}

2000
.

nchar(size)

, char (size),
,
(,
,
- )

varchar2(size)

nvarchar2(size)

, varchar2,
, nchar

varchar

, char.
varchar2,
^

number(I, d)


, 1 , a d .
, number (5, 2)
, 9 9 9 . 9 9

4000

2000

1.0-130..
9.99125

decimal(1, d) ,
dec (1, d)
numeric^, d)

, number.
SQL

integer, int
smallint


SQL. number (38)

Date

1 Jan 4712 ( . .) 31
Dec 4712 AD (b. .)

blob

clob

raw(size)

,
,

2000

, Microsoft Access
Autonumber,
. Oracle ,
, ()
CREATE SEQUENCE SQL. ,
.
CREATE SEQUENCE appNoSeq
START WITH 1 INCREMENT BY 1 CACHE 3 0 ;
appNoSeq,
1 1. CACHE 30 ,

312

II.

Oracle 30 . SQL,
.
CURRVAL. .
NEXTVAL. 1 .
SQL.
INSERT INTO Appointment(appNo, aDate, aTime, clientNo)
VALUES (appNoSeq.nextval, SYSDATE, ' 1 2 . 0 0 ' , ' C R 7 6 ' ) ;

Appointmer.t
() appNo ( ), .
, PropertyForRent Oracle 8 (), 6.1.

SQL*Plus
Oracle 8
SQL*Plus , Oracle. SQL*Plus
, SQL Oracle. . 8.14 PropertyForRent
Oracle CREATE TABLE SQL.
Oracle ON DELETE NO ACTIGI,
ON UPDATE NO ACTION .
Oracle . ON DELETE
CASCADE . , * Oiecle SQL-Plus

( Copyright 1999 Oracle Corporation, fill rights reserved.

Connected to:
Oraclpel Enterprise Edition Reipase 8.1.5.0.8 - Production
Witn the Partitioning and Jaua options

PL/SDL Release 8.1.5.0.0 - Production

SQL>
2
3
:
4
5

; 7
1
S
:
1H
11
12

TflBLE PropertyForRent<propertyNo (JflRCHflR2(5) HOT NULL,


Street UflRCHJW2(25> HOT NULL, city Ufi!IUHnil2( 1^) HOT NULL,
postcode UeRCUAfl2(B}, type DEFfiULT T ' HOT HULL,
rooms SMflLLItn DEFflULT NULLh
rent NUM8ER(o,2) DEFfiULT NOT HULL,
DunerNo UftRCHflR2(5) HOT HULL,
<itaffNn UftHCHftHJ-C;},
brancnNo CHflR(t) HOT HULL,
PRIHfiRV KEV <propertyHo),
FORF.1GH K L V (StafFHo) REFEREHCES S t a f f (staFFHo),
FOREIGN KEV (OunerNo) REFEREHCES Owner<ounerHo),
FOREIGN KEV (branctiHo) REFERENCES eraflChtbranchNo)};

Table created.

SQL)

. 8.14. PropertyForRent
Oracle SQL*Plus
CREATE TABLE SQL

8. : Access Oracle

313

, . Oracle
ON UPDATE CASCADE SET DEFAULT SET
NULL. ,
.
8.2.7.

Create Table Wizard


Oracle 8
(Create Table Wizard),
(Schema Manager). Create Table Wizard,
,
, , / . . 8.15
Create Table Wizard,
PropertyForRent.

Final Keviei*

rU*mw*t
*

4
USft.OATA

irColuwis!

it Up Oi
ptonefyMc
city
poilcod.
( "
loams

VARCHAR2I5)

VAriCHAR2li5) ""
2||
" "CHAR|il"
NUMBER

LL ij ^^'

Puc. 8.15. Create Table Wizard


Oracle PropertyForRent

8.2.4.
Oracle
, ,
SQL, CHECK CONSTRAINT
CREATE ALTER TABLE;
;
;
.
6.1.
- 27. ,
Oracle PL/SQL (Programming Language/SQL).

314

II.

8.2.5. PL/SQL
PL/SQL Oracle SQL.
PL/SQL; Oracle,
,
Oracle. , , ,
PL/SQL Oracle ,

(, PL/SQL Oracle Forms).


PL/SQL ; ,
, . PL/SQL : . ,
PL/SQL, ,
() . . 8.16, PL/SQL
:
(declarative part), , , , ,
;
(execution part), ;

(exception part) , .

[DECLARE '
-- ]

BEGIN
--

{EXCEPTION

- .; -- ]

END;

, 8.16. PL/SQL

,
, . . 8.3. .
vStaffNo VARCHAR2(5);
vRent NUMBER(6, 2) NOT NULL := 600;
yAX_PROPERTIES CONSTANT NUMBER := 100;

, NOT
NULL, .
8. : Access Oracle

315

%TYPE ,
, . , , vStaf fNc
, st.affNo Staff, :
vStaffNo
vStaffNol

Staff.staffNofcTYPE;
vStaffNo%TYPE;

%ROWTYPE, , , . . , , vStaf f Rec


, Staff, :
VStaffRec

Staff%ROWTYPE;


PL/SQL : (:=)
SELECT FETCH SQL. :
vStaffNo:= "SG14";
vRent:= 500;
SELECT COUNT (*) INTO x FROM PropertyForRent WHERE staffNo =
vStaffNo;

SELECT ( ,
SG14).


PL/SQL , :
IF-THEN-ELSE-END IF;
LOOP-EXIT WHEN-END LOOP, FOR-END LOOP WHILE-END LOOP;
GOTO.


(exception) PL/SQL , .
,
. Oracle, ,
NO_DATA_FOUND , SELECT . , RAISE.
,
(exception handlers).

316

II.

, PL/SQL. , , .
PL/SQL, 8.2 . Oracle DBMS_OUTPUT,
PL/SQL. put_line SGA, , get_line
SERVEROUTPUT ON SQL*Plus.

SELECT , . , (.. , ),
PL/SQL (cursors). . ,
. 1.
, . , FETCH,
SELECT. ( 21 , SQL
, .)
8.3
, SG14,

. .
DECLARE property-Cursor.
. , SELECT,
CURSOR, ,
( ), . , , PL/SQL .


FETCH INTO. ,
FETCH
.
, -
(propertyCursor%NOTFOUND), , (EXIT WHEN). DBMS_OUTPUT .
.
8. : Access Oracle

317

.
%NOTFOUND, ,
, .
%FOUND. , (.. , %NOTFOUND).
%ISOPEN. , .
%ROWCOUNT. , .
8.2. PL/SQL
DECLARE
X
NUMBER;
vStaf f No PropertyForRent. Eitaf fNo%TYPE : = ' SG14 ' ,--
-- ,
-- 100
e_too_many_properties EXCEPTION;
PRAGMA EXCEPTION INIT(e_too_many_properties, -20000);
BEGIN

SELECT COUNT;*) INTO x

FROM PropertyForRent
WHERE staffNo = vStaffNo;
IF x=100
-- , ,
--
RAISE e_too_many_properties;
END IF;
UPDATE PropertyForRent SET staffNo = vStaffNo WHERE propertyNo
= 'PG4';
EXCEPTION
--
--
WHEN e__too_many__propertiei3 THEN
dbms_output.put__line(' ' |\ staffNo
1
100 ');
END;

8.3. PL/SQL
DECLARE
vPropertyNo
PropertyForRent.propertyNo%TYPE;
vStreet
ProperiyForRent.street%TYPE;
vCity
Proper-yForRent.city%TYPE;
vPostcode
Proper'iyForRent. postcode%TYPE ;
CURSOR propertyCursor IS
SELECT propertyNo, street, city, postcode
FROM PropertyForRent:
318

II.

WHERE staffNo = 'SG14'


ORDER by propertyNo
BEGIN
-- , ,
--
OPEN propertyCursor;
LOOP ;
--
FETCH propertyCursor;
INTO vPropertyNo,vStreet, vCity, vPostcode;
EXIT WHEN propertyCursor%NOTFOUND;
--
dbms_output.put_line(' :
vPropertyNo);
dbras_output.put_line(':
vStreet) ,dbms_output .put__line (':
vCity);
IF postcode IS NOT NULL THEN
dbms_output.put_line(' : ' || vPostcode);
ELSE
dbms_output. put__l ine (' :
NULL ') ;
END IF;
END LOOP;
IF propertyCursor%ISOPEN THEN CLOSE propertyCursor END IF;
-- -
EXCEPTION
WHEN OTHERS THEN,
dbms__output ,put_line {' ');
IF propertyCursor%ISOPEN THEN CLOSE propertyCursor END IF;
END;


PL/SQL
, . , , , , :
CURSOR propertyCursor (vStaffNo VARCHAR2) IS
SELECT propertyNo, street, city, postcode
FROM PropertyForRent
WHERE staffNo = vStaffNo
ORDER BY propertyNo;
, , :
vStaffNol PropertyForRent.staffNo%TYPE:='SG14';
OPEN propertyCursor('SG14');
OPEN propertyCursor('SA9'};
OPEN propertyCursor(vStaffNol);

8. : Access Oracle

319


. , , , ,
, FOR UPDATE.
- ,
( 19).
, , SG14, SG37, :
CURSOR propertyCursor IS

SELECT propertyNo, street, city, postcode


FROM PropertyForRent
WHERE s t a f f N o = 'SG14'
ORDER BY propertyNo
FOR UPDATE NOWAIT;

, Oracle , SELECT FOR UPDATE,


. , NOWAIT , .
UPDATE DELETE SQL WHERE
CURRENT OF , . :
UPDATE PropertyForRent
SET s t a f f N o = ' S G 3 7 '

WHERE CURRENT OF propertyCursor;


COMMIT;

8.2.6. , ,

PL/SQL,
. PL/SQL , () .
, , . , , .
, , .
, , .
PL/SQL
: , 320

II.

,
,
. , .
IN. .
OUT. .
IN OUT. , .
, PL/SQL,
8.3, , :
CREATE OR REPLACE PROCEDURE PropertiesForStaff
(IN v S t a f f N o VARCHAR2)
AS. . .


SQL*Plus :
SQL>SET SERVEROUTPUT ON;
SQL>EXECUTE PropertiesForStaff('SG14');

, ,
SQL, . : . (public constructs)
, (
(private)) , .
.
Oracle .
.
.

.

:
CREATE OR REPLACE PACKAGE StaffPropertiesPackage AS
procedure P r o p e r t i e s F o r S t a f f ( v S t a f f N o VARCHAR2);
END StaffPropertiesPackage;

(.. ) :
CREATE OR REPLACE PACKAGE BODY StaffPropertiesPackage
AS
END StaffPropertiesPackage;
, ,
(dot notation). ,
PropertiesForStaf f :
StaffPropertiesPackage.PropertiesForStaff('SG14'};

8. : Access Oracle

321

8.2.7.
, . , . , ,
PL/SQL, Java
, "--" (EventCondition-Action EGA),
( ),
Oracle,
INSERT, UPDATE DELETE, (, , );
CREATE, ALT3R DROP,
;
Oracle; ;
.
,
.
, , . , ,
, .
, . SQL , ,
.
: (row-level triggers),
, (statement-level triggers),
, . Oracle INSTEAD-OF,
, SQL DML (INSERT, UPDATE
DELETE). INSTEAD-OF, , , Oracle
(instead-of) SQL.
. ,
, , , , .
, DreamHome ,
100 . , 8.4,
. ,
PropertyForRent
. 100
, .
.
322

II.

BEFORE , ,
PropertyForRent.
FOR EACH ROW ,
,

PropertyForRent, .
new .
( old,
.)
8.4. ,
100

CREATE TRIGGER StaffNotHandlingTooMuch
BEFORE INSERT OR UPDATE ON PropertyForRent
FOR EACH ROW
DECLARE
X
NUMBER;
BEGIN
SELECT COUNT(*) INTO x
FROM PropertyForRent
WHERE staffNo = :new.staffNo;
IF x=100
raise_application_error(-2QOOO,{' ' || :new.staffNo (|
1
100 1);
END IF,END;


8.2.3 , Oracle ON DELETE NO ACTION ON UPDATE NO ACTION
. Oracle ON DELETE CASCADE , .
ON UPDATE CASCADE SET DEFAULT SET NULL.
, . , 6.1 6 s t a f f N o PropertyForRent
ON UPDATE CASCADE. , 8.5.
1 (Property ForRent_Check_Bef ore)
, 8.5, , PropertyForRent staffNo. , , Staff.
Invalid_staf f , .

8. : Access Oracle

323

, Staff

, 8.6, ,
Staff s t a f f N o . updateSequence (public) updateSeq (
seqPackage). , PropertyForRent
updateid, ,
, .
2 (Cascade_StaffNo_Update1)

(statement-level)
s t a f f N o Staff , .
3 (Cascade_Staff No Up<late2)

() ,
PropertyForRent staffNo
(: old. staffNo) (: new. staffNo) .
4 (Caseade_StaffNo UpdateS)
() , .
.5. Oracle ON UPDATE CASCADE no
staffNo PropertyForRent,
staffNo Staff:
PropertyForRent
staffNo PropertyForRent
-- ,
-- Staff
CREATE TRIGGER PropertyForRent_Check_Before
,
BEFORE UPDATE OF staffNo ON PropertyForRent
-- FOR EACH ROW
-- new.staffNo IS NOT NULL
FOR EACH ROW WHEN (.staffNo IS NOT NULL)
DECLARE
dummy CHAR(5);
invalid_staff EXCEPTION;
valid_staff EXCEPTION;
mutating_table EXCEPTION;
PRAGMA EXCEPTION_INIT (mutating_table,-4091);
--
. FOR UPDATE OF
-- ,
--
CURSOR update_cursor {sn CHAR(5}) IS
SELECT StaffNo FROM Staff
WHERE staffNo = sn
FOR UPDATE OF staffNo;
324

II.

BEGIN
OPEN update_cursor(:new.staffNo);
FETCH update_cursor INTO dummy,-- .
--
-- NOTFOUND ,
-- staffNo
IF update_cursor%NOTFOUND THEN
RAISE invalid_staff;
ELSE
RAISE valid_staff;
END IF;
EXCEPTION
-- ,
-- staffNo
WHEN invalid_staff THEN
CLOSE update__cursor ,raise_application_error{-20000,' '
:new.staffNo;
WHEN valid_staff THEN
CLOSE update_cursor;
-- (mutating) - ,
-- INSERT, UPDATE DELETE; ,
--
-- DELETE CASCADE.
,
-- , ,
-- .
WHEN mutating_table THEN
NULL;
END;

8.6. Staff
--
-- UPDATESEQ

CREATE SEQUENCE updatesequence INCREMENT BY 1 MAXVALUE 500 CYCLE;


- seqpackage
--
CREATE PACKAGE seqpackage AS

updateseq NUMBER;
END seqpackage
CREATE or REPLACE PACKAGE BODY seqpackage AS END seqpackage;
-- PropertyForRent
-- .
--
- - PropertyForRent
ALTER TABLE PropertyForRent ADD updateid NUMBER;
-- Staff ,
--
-- UPDATESEQ
CREATE TRIGGER Cascade_StaffNoJJpdatel
-- ,

8. : Access Oracle

325

--

BEFORE UPDATE OF staffNo ON Staff


DECLARE
dummy NUMBER;
BEGIN
SELECT updatesequeaice.NEXTVAL --
INTO dummy FROM DUAL;
--
seqpackage.updatejeq:= dummy
--
END;
-- ,
-- PropertyForRenC.
,
--
CREATE TRIGGER Cascade_StaffNo_Update2
AFTER UPDATE OF staffNo ON Staff -- ,
FOR EACH ROW
--
BEGIN
--
-- PropertyForRent
--
UPDATE PropertyForRent SET staffNo=:new.staffNo,
updatfiid= seqpackage.updateseq;
WHERE staffNo = : O l d . s t a f f N o AND updated IS NULL;
END; "

--
CREATE TRIGGER Cascade_StaffNo_Update3
AFTER UPDATE OF staffNo ON Staff
-- ,
BEGIN
--
UPDATE PropertyForRent SET updated = NULL -- ,
WHERE updateid = seqpackacge.updateseq;
--
END;
--


( )
. 15-20
( 50
), 25%.
Microsoft Access Microsoft
Windows . Microsoft Access
, ,
. II Access , ,
(Graphical
User Interface GUI);
, Microsoft
Access VBA (Visual Basic for Applications).
Microsoft Access
, , , , , , .
( ) ( ).
,
326

II.

. , . ,
. . Web-,
{ Microsoft Access
Microsoft SQL Server) Internet
(intranet). , , .
VBA,
.
Microsoft Access . Access 2000 :
Jet Microsoft Data Engine
(MSDE), Microsoft BackOffice SQL Server.
Oracle
. 10 , ,
145 , Oracle . 400
80% Oracle .
Oracle ,
. Oracle ( ); (
Oracle); ( , , );
(, ); ( ); ( ); ( ); / ( SQL
PL/SQL, );
( , , SQL,
);
(, ()
, ).
Oracle / .
Oracle ( ,
) (
, ). .
, , , , Oracle.

8.1.
8.2.
8.3.

Microsoft Access?
Access ?
Access ?

8. : Access Oracle

327

8.4.
8.5.

8.13.

Access?
Access.
Oracle?
Oracle.
Oracle.
,
PCTFREE PCTUSED?
Oracle
.
Oracle.
Oracle.
PL/SQL?

328

8.6. .
8.7.
8.8.
8.9.
8.10.
8.11.
8.12.

,

""
"-"

331
367
397
429
447

"

...

.
.
: ,
.
CASE-
.
.
.

.

.
, .

,
. ,
. , ,
,
.
, ,
. , , , . , " ".
1960- ,
40 .
"
". -

(Organizational Aspects Special Interest Group OASIG) [228],


80-90%
.
80%
.
40%
.
40% .

25% .
10-20% .

:
;
;
, .
, (Information Systems Lifecycle), (Software Development LifeCycle SDLC). "
".
- > ' ' -

- _

' . : :

9.1 , . 9.2 .
9.3-9.13, 9.14 CASE-,
.
9.15, .

9.1.

. ', ,
, .
1970- ,
(Information System IS) . 332

III.

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

9.2.
,
.
,
. . 9.1.
, .
, , (feedback loops). , ,
.
, . 9.1 . ,
, . 9.1.

.
,
, . ,
.
,
.

9.,

333

^
( 9.


( 9.4) '


( 9.6)

.1

('
) ( 9;1

'-

1
( 9-S)"

'^
&
/.


( stranj
( 9.9) '";:

( 9-50).

.&^5

|
( 9.13)

. 9.1.

334

III.

9.1. ,


( )


( )

( )

, ,


. , ,
.

9.3.
i . , :~ .

. :
- ;
9.,

335


;
.
, ,
. [261].
.
. , , , (,
).

.
.
, .
, , ,
, ,
.
, , , , .
DreamHome 10.4.2,

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

(, ..).

9.4.
.
, .
, . 336

111.

, . . 10.10 ,
DreamHome. , , .

9.4.1.
.
1 { icneicrop) ( , ).

.
, ,
. ,
.

,
(.. ,
). . . 9.2

1-6).

, (13,
5 6) ( ),
4 .

9.5.
( . , , .

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

337

6 V.

:'!-.'(

. 92.

.
.
.
(
), . ,
.

, . - . (paralysis by analysis),
,
.

, . , , ,
(Structured Analysis and Design
SAD), (Data Flow Diagrams DFD)
"--" (Hierarchical Input Process Output HIPO),
. , -

338

III.

, , CASE-, .

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

9.5.1.
-

"," "'

' . ; ; ; / > ,

'

<

' / -

'

. .
,
. , , , , . (. 9.6)
, , , . , . . 9.3
1-3. ,
,
.

9.5.2.
.
, -,
. , ;;
^ ^ .
9. ,

339

1
ER-

. 9.3. 1-3


. (. 9.6)
. ,
, ,

. , .
. 9.4 1-3
. ,
, ,
,
. 3 15.

9.6.
. ,
.

. .
: , .
340

III.

2
,

. 9.4. 1-3

9.6.1.
:
.
(.. ),
, . 13 , .
,
.

.

, .
9. ,

341


, ,
. ,
, .

. , ,

, . "-". , . , PrivateQwner () PropertyForRent (
), PrivateOwner Owns
() PropertyForRent

, PrivateOwner
{ownerNo,
name,
address)

PropertyForRent (propertyNo, address). "" 11 12.



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

9.6.2.

() .

, .
, ,
. , .
,
.
,
, :
;
;
.
, .
, , .
342

III.


. , ,
"-" (Entity-Relationship model ER) 11 12.


, . 9.2 [116]. , . , ,
9.2.

, ..

-
, ,

9.6.3.
: , .


.
. ,

. . 9. ,

343

,
. , ,
, , , . 14 .
.

.


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

, , .
.
. , , ,
, . , , 13. ,
, ,
.


, , .
.
, , .

15.
344

III.


.
| ; - -.
|; , , >
$ , . .

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

, ;

, ;
.
.
.
, , , .
, , ,
, , .
, .
,
, .
.
, , ,
. .
,
9. ,

345


.
. ,
.
,
.
2 ANSI-SPARC, ,
. . 9.5
, .
16 17

. 9.5.
ANSI-SPARC

9.7.
. ,
!! .
,
(. . 9.1). , ,
, , , .
, ,
, , .
, , , ,

346

III.

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

9.7.1.
. 9.3.
9.3.


-


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

9. ,

347

,

, World Wide Web. ,
Web- , ( www.intelligententerprise.com). ,

Web- .


, (, ),
(, ). . 9.4 , : , , , , , .
9.4.

:
SQL2/SQL3 ODMG

348

III.

. 9.4

CASE-


Web

Internet

- "/"

XML

, . ,
.
, .
. 9.5
. , 10-
, ( ) .
. ,
9. ,

349

. 9.5 " " 4 0,25, 1,0. ,


. , " " 5
, , , " " ( , 0,05). "
" " " , .
9.5.
:
:
" "

0,15

1,2

0,2

1,2

0,25

1,0

0,15

0,9

0,15

0,9

0,05

0,35

0,05

0,2

0,00

0,00

41

1,0

5,75

5,75

0,25

1,44


. ,
.
, . 9.5 " "
5,75, 0,25.
, , ,
. .
, , , .
, - .

.
Transaction Processing Council
, www.tpc.org,
350

III.


,
.

9.8.
^ .
^ , .
. 9.1 ,
.
. ,
, .
, , , . , , .. .
, ,
. .

. , .
, ,
, . , , .

, .

9.8.1.
,
.
. . ,
; ( ),
:
.
, , , ,

9. ,

351

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

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

352

III.

9.8.2.

( ),
.
. 9.6 [275].
9.6.




.1










. , . ,
.


, , .


, /. /
. ,
9. ,

353


. , .


. , Sex () Gender,
.



, .


. ,
.
. ,
, ,
.


,
, . .


,
. , .

,
, .
,
<Backspace> .

. .


.
.
354

III.


,
(, )
.


, . ,
.

9.9.

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

. ,
, .

9.10.
!: . .
( ) , .
(DDL) , ,
9. ,

355

DDL . DDL .
.
. (DML)
, Visual Basic, Delphi, , C++, Java,
COBOL, Fortran, Ada Pascal. ,
, , . ,
, , , .
. DDL , , ,
, ,
, . , DDL DML SQL,
5 6.

9.11.
-

- ; .

- , -.

. -

-.--

...

.. -

-,

, -

.... ..-..

.. .

I .
; : . .
,
. . - , .
, . ,
,
.

9.12.
. .
,
.
, , . ,
,
356

111.

.
, , . , , , . ,
, -, , . ,
.
,
. , .
.
,
.

9.13.
*

.
^^ .
.
, .
.
.
, .
( )
.
.
, , .
,
. , ,
(
), .
()
(,
), , , .
,
9. ,

357

.
,
. , ,
,
. ,
, , ,

.
.
. , . , . ,
, , .

9.14. CASE-
, ..
, ,
CASE- (Computer-Aided Software Engineering).
"CASE-" . . CASE-
:
, ,
;
, ;
, ;
, .
. 9.6, CASE- : CASE- , CASE-
CASE-, CASE-
,
, CASE-
, ,
.
CASE- , CASE , .
358

II.



CASE-

-
!
/ ,;

15)&-::'|
: - j

. 9.6. CASE-

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

- .

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

359

CASE- , .
. CASE-
,
. , , .
. CASE-
(. 2.7), ,
.
, ,
.
.
. ,
,
. CASE .
. , CASE- ,
. CASE- . , , .
CASE-
[21], [120], [185].

9.15.

() () ,
, .
,
.
.

9.15.1.
. ,
, , , - ;
.
360

III.

,
.
,
.
, . , ,
. , , . 9.7.
9.7. ,


,
-






,



-
, , , , , ,


,

9.15.2.
. : , -;
; ! ,
^ ,
,
9. ,

361

, ,
. ^
, ,
. 9.8. , ,
.
. 9.8.
9.8.





1






, ,

,
^!?

9.15.3.


. .
. 9.9 ,
. , . , .
9.9. ,

362

III.

. 9.9

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


(, ),
( , , ).

,
, .
: , .
9. ,

363

, .
, .
,
-. , .

,
.
,
, .
.
, , ,
- ,
.

, ,

, , . ,
. .

,
,

.
?
.

,
, , .
CASE- (..
) , , . CASE-
: CASE- , CASE CASE-.
,
, ,
, . .

364

III.

,
, , .

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.

, .
, ,
, .
.
9.14.
, .
9.15. ,
. , , ,
, ,
, .

9. ,

365


...


.
,
.
,
.
.
,
.
DreamHome, .

.
9
. ,

.
, , ,
, , . .
1 . , 5 , .,
.
,', '
,^
|
:
.
, . . , DreamHome, , ,

. DreamHome
.


10,1 , . ( "
", , , . .) 10.2 ,

. 10.3
. 10.4 DreamHome , .
DreamHome. , : ,
, .
.

10.1.


, , , *:, . , , , , () . , ,
. ,
, ,
. (
) ,
: .
, , .
9,
(paralysis by analysis),
, .

10.2.
.
. 10.1 , .
9,
, 368

III,

(feedback loops). , . , , , , .
10.1. ,



(

)

/
(
ER-,
);

(

)

;

;

10.

369

10.3.
.
.
.
.
.
.
.
.

10.3.1.
:- , , , . , ,
. , , ,
, . , , . 10.2.
10.2. ,

, ,
, /
, .

,
- .
.
/.
.

- ,
.
.
.

10.3.2.

. . , ,
, ,
370

III.

, .

, , , , .
.
. 10.3.
: . ,
, , . , , ,
.
,
.
, ,
.

.
(open-ended questions) ,
.
: " ?" , (closed-ended questions), , .
: " ?" "
?" "" "".

,
.
10.3.

,


, ,

, ,


, ,

10.3.3.
. ,
10.

371

, . , ,
,
.
,
- , . , , :
" , ?" " , ?"
. 10,4.
10.4.


, ,

10.3.4.

. , Internet
( ) . ,
, .
. 10.5.
10.5.

372

III.

. 10.5

,

,

10.3.5.
. , , . ,
.
. 10.6.
, : (free-format questions) (fixed-format
questions).
. : "
?" " - ? , , ".
, ,
.

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

10.4.

DreamHome, a
. , , ,
, : , , .

10.

373

10.6.

<


; 5-10%

10.4.1. DreamHome
DreamHome , , 1992 .
. ,
.
. (Sally Mellweadows) ,
,
- . ,
,

DreamHome. , DreamHome,
DreamHome , ,
, DreamHome, .
DreamHome 2000
, 100 .
DreamHome
(DreamHome Staff Registration Form). . 10.1 ,
(Susan Brand).
, (Manager), (Supervisors),
(Assistants). ,
, . , , . 10.2.
,
. DreamHome, DreamHome.
. . 10,3.
374

III.

DreamHome
Staff Registration Form

Staff Number SG5

Branch Number 8003


Branch Address
DOB

J63 Main St. Glasgow

3-Jun-40

Telephone Number(s)
, 0141-339-2178 / 0141-339-4439
Position Manager
Salary 24000

Manager Start Date Q1-Jun-9U


Manager Bonus 2350

. 10.1. DreamHome

DreamHome
Staff Listing

Branch Number BOOS

Branch Address
163 Main St, Glasgow

Telephone Number(s)

G119QX

0141-339-2178 / 0141-339-4439

Staff Number

Name

SG5 .
SG14
SG37
- SG112
SGI 26
SG132

Susan Brand
David Ford
Ann Beech
Annet Longhorn
Chris Lawrence
Sofie Walters

Position
Manager ; , '"
Supervisor
Assistant .
Supervisor
Assistant -v- '4""
Assistant >,
Page!

. 10.2. , DreamHome

10.

375

DreamHome
Property Registration Form
Owner Number C093
(If known)

Property Number PGf6


Type Fiat

Rooms 4

Rent 450

Person/Business Name
Tony Shaw

Address

Address 12 Park PI,


SNovor Drive,

Glasgow G4OQR

Glasgow, G1 2 9AX
Tel No 0141-225-7025

Enter details where applicable

Type of business
Contact Name

Managed by staff

Registered at branch

David Ford

. 10.3.

DreamHome

153 Mam St. Glasgow

, DreamHome , ,
, , , DreamHome.
( ), ,
( ) . DreamHome , .
, ,
DreamHome DreamHome. ,
, . . 10.4
(Mike Ritchie).
, .
,
, . 10.5.
. , ,
. 10.6. ,
.
376

III.

DreamHome
Client Registration Form

Client Number CR74


(Enter If known)
Branch Address

Full Name

163 Main St, Glasgow

Mike Ritchie

Registered By
Ann Beech
Date Registered 16-Nov-99
Max Rent 750

. 10.4.
DreamHome

DreamHome
Property Listing for Week beginning 01/06/01

If you are interested in viewing or renting any of the properties in this


list please contact our branch office as soon as possible.
Branch Address
163 Main St, Glasgow

Telephone Number(s)
0141-339-2178 / 0141-339-4439

G119QX

Property No

Address

PG4
PG36

6 Lawrence St, Glasgow


2 Manor Rd, Glasgow
18 Dale Road, Glasgow
5 Novar Drive, Glasgow
100A Apple Lane, Glasgow
78 1 Greentree Dr, Glasgow

PG21

PG16
PG77
PG81

Type
Flat
Flat
House
Flat
House
Flat

Rooms

Rent

3
3

350
375
600
450
560
440

. 5
4
6
*='..

Page 1
. 10.5. DreamHome
,

10.

377

DreamHome
Property Viewing Report
Property Address
6 Lawrence St, Glasgow
Rent 350

Client No

Name

CR76
CR56
CR74
CR62

John Kay
Atine Stewart
Mike Ritchie
Mary Tregeor

Date

Comments

Too remote.
20/04/01
26/05/01
11/11/01
11/11/01 OK, but needs redeeoratfon throughout.

Page 1

. 10.6. DreamHome no

DreamHome Lease
Number 00345810
Client Number CR74
(Enter if known)
Full Name
Mike Ritchie
(Please print)

Property Number PG16


Property Address
;

SNovorDr, Glasgow

Client Signature

Rent Start 01/06/01


Rent Finish 31/05/02
Payment Method Cheque

Duration 1 year

Deposit Paid (Yor N)

. 10.7. DreamHome
,

378

III.

,
. . 10.7.
;
. .

10.4.2. DreamHome

(mission statement) , . (mission
objectives), ,
(. 9.3).


DreamHome

DreamHome , .
. .
" ?"
" , , ?"
" , ?"
,
DreamHome, .

?


, . , , ,
.
,

, , ?
,
, .
,
, . -

10.

379

,
.

,


,
?
lice, , , . ,
,
.
, .
, ?

" DreamHome ,

,
".

. 10.8. DreamHome


.
DreamHome . 10.8.
, DreamHome,
.


DreamHome

. , . ,
DreamHome. .
" ?"
" ?"
" ?"
" ?"
" ?"
" ?"
( ) DreamHome
: , .
, .

380

III.

?
.
.
,

?
,
DreamHome.
, ,
. ,

?
, , . ,
DreamHome,
,

,

?
, , .


, ,

"" ?

10.

381

382

. ,

?
,

,
.
,
,
.
.
,
-

?
, ,
, .
, ;
.
,
.
, , . ,
,
,
- . , , , .
, , , ,
, ,
.
, ,

.
,
- , , .
, ,

III.

?
,
, , . ,
,

?
. ,

.


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

?
. ,
, , , . , , , ,
,

?

,
,
. , , , .
, .



?

10.

383

, , ,
?
,
?
,
.
, .
.,

?
.

?
, . : " -
?"
. , ,
,
?

, .

?
,
.
?




?
, , "
; ?" "
?"


. Dream.Home . 10.9.

384

III.

10.4.3. DreamHome


. 9.4.1 , ( ) ( ) ,
.


DreamHome

, . , , 10.4.1. , ,
, . DreamHome 10.10.

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

, 10.9. DreamHome

10.

385

,
10,10. DreamHome


DreamHome

, .
: ,
.
DreamHome . 10.7.
10.7.
DreamHome

386

X
X
X

.
X

X
X

III.

. 10.7

'

10.

:<

387

10.4.4. DreamHome

1\

, , (users' requirements specification),


, ,
. .
: (systems specification),
, ,
, .

.

, .
, . 9.5, : (centralized)
, (view integration) . , .


DreamHome
,
, . , ( X), , .
" X?"
" X?"


?

, , ,
?
.
,
.
. ,
,

388

III.

,
. .


DreamHome

.
, , .
" ?"
" ?"
" ?"
" , ?"
" ?"
" ,
?"
" ?"
"
?"
" ?"
, .

?

,
,
.
, , ,
,

?
,
,
.
,

10.

389


?

, , ?
.
, , . ,

12 14 17 19

?
, ,

, , ,

, ,
. ,
, . , , ,
,

,

?
, ,
. ,
,

?

, ,

.

,
,

, . .

390

III.

?
, , ,

.
, ,
,
, 100 .


.
-

,
?
, .
,
, , . ,


. ?

. .


DreamHome
, ? ,
,
, . . 10.8 , ,
, DreamHome
( : , , , , , , ).
. 10.8 , ,
, .

. ,
,
10.

391

. ,
,
(
Branch)
(
S t a f f ) . , Branch Staff,
,
10.8.
,
DreamHome

branch ()

staff ()

property for rent (


)

owner ()

client ()

property viewing ( )
lease ( )

newspaper ( )

DreamHome, ,
, , 15 , .
, , , .
. ,
, , ,

(, , )
. 16
.
,
, , . ,
. Branch Staff DreamHome .
DreamHome.
392

III.

DreamHome
DreamHome. ,
,
;
;
;
;
;
;
;
.
DreamHome

1. 2000 100 .
20 40 .
2. 100 000
. 1000 3000
.
3. 60 000 , 600
1000 .
4. 100 000 . 1000 1500
.
5. 4 000 000 . 40 000 100 000 .
6. 400 000 .
40 000 10 000
.
7. 50 000 100 .

1. 500
200 .
2.
, .
100 .
3. 2 , . 100 .
4. 20 .
. 20 .

10.

393

5. 1000 .
2 , .
100 .
6. 5000 .
.
7. 1000 . .
8. 1000 .
.

1. 10 .
2. 20 .
3.
5000 ( ), 10 000
( ). 12.00 14.00 17.00
19.00 .
4. 100 .
5. 1000 ( ), 2000 ( ).
12.00 14.00 17.00 19.00 .
6. 2000
( ), 5000
( ). 12.00 14.00 17.00
19.00 .
7. 1000
( ), 2000 (
). 12.00 14.00 17.00 19.00 .


, DreamHome , . 2 3 .
.

1. , ,
1 .
5 .
2. , ,
5 .
10 .
394

III.

3. , ,
/ 1 . /
5 .

1. .
2. ()
,
: , , .
3. , ,
,

.

, . DreamHome
, ,
, .

10.4.5. DreamHome


Branch Staff
DreamHome. , . 14 16 DreamHome, ,
Dreamffome,
, .

,
, .
, , , .
, , , .
, ,
.
,
, .
10.

395

,
, , .

10.1. ?
10.2. ?
10.3. , .
10.4.
.
, ,
, .
.
10.5. .
10.6. ?
10.7.
?
,

?

10.9.

,
; ()
( ). ,
, . ,

,
10.10. ,
, . , , .
10.11.
, ,
.
10.12. , , , .
10.13.
, ,
.

396

III.

"-"
...

ER-
.
, "-" (EntityRelationship model, ER-).
ER-
UML.
ER-, "
".
ER- .
10
,
.
.

, , , , -.
,
, ,
.
, ,

.
"-"
(Entity-Relationship
model,

ER-).
ER
, , (entities), (relationships) ,
.
, , , (attributes), , , . ER- ,
; , .
ER-,
, -

, ,
.
, - UML
(Unified Modeling Language ) [35].
UML - , 1980-1990- . , OMG (Object
Management Group ), UML, , UML . UML ER-,
ER- - . ,
ER-.
,
ER-. ER-
"" , EER- (Enhanced
Entity-Relationship
"-"). 12 , EER, /, .
, ER-, . 11.1,
EER-, . 12.8.

11.1-11.3 "", , . ER ER- UML.


11.4 ,
11.5 , ,
. 11.6 , . , , 11.7 , ER-,
, .
ER- ER-, . 11.1.
,
Branch DreamHome, . , , ER. ,
, , , .

11.1.
;

. , v
.7

^ V.v,--: .... ..-,~- -- -.. -

398

=. -

.-".

' . - ':'

-- i

ER- (entity type), ,


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

. 11.1. "-" Branch


DreamHome

11. "-"

399

11.1.

. , .
, , (entity occurrence).
, ,
,

. , , .
, . 11.1 , S t a f f , Branch.,
PropertyForRent PrivateOwner.


; ]! . UML

(.
Staff

PropertyForRent). . 11.2
Staff Branch.

. 11.2,
S t a f f Branch

400

III.

11.2.
^ . .
(relationship type) (
) , .
, .
POwns ( )
PrivateOwner ( ) Proper tyForRent
( ), . 11.1.
,
" " " ".
. ,
.
, .
, , , , .
Has, Branch () Staff (), ,
Branch Has Staff ( ). Has Branch Staff. Has
.
,
. . 11.3
Has (
rl, 2 ).
Branch Staff. , Branch Staff. , rl
Branch SG37 S t a f f .
, . 11.3 Branch
Staff
(branchNo staffNo).
.

,
- .

"-" (ER-). ER- , , .
11. "-"

401

Branch
(branchNo)

Has*-

Staff
(staffNo)

. 11.3, ,

Has

" "

. 11.4. , Branch Has Staff


, . (, Supervises
() Manages ()) ,
(, LeasedBy ( )). . ER- .
, (,
Branch Has Staff ( ) ,
Staff Has Branch ( )).
,
,
(. Branch Has > Staff), . 11.4.

402

III.

11.2.1.
. , . , , .
(degree) . ,
, . (binary). Has, , 11.4, , Staff
Branch.
. 11.5 POwns
PrivateOwner PropertyForRene. . 11.1.
Has POwna,
. ,
, .. .
" "
POwns*-

. 11.5. POwns

(ternary). Registers ()
, Staff, Branch Client.
.
.


UML
. , , ,
. , . 11.6

.Registers. . 11.1 .

"

"

. 11.6. Registers

11. "-"

403

(quaternary). . 11.1 ,
. 11.7 Arranges , Buyer (), Solicitor (
), Financiallnstitution ( -) Bid ().
, ,
, .

11.2.2.
: . , , .
Supervises, , . , S t a f f Supervises :
, , .
(unary).

, .
, .
. 11.8 Supervises. Supervises Staff
Supervisor (), Supervisee (
).
, . , Staff Branch Manages Has. . 11.9,
. ,
Staff Manages Branch, ( Staff) Manager () ( Branch), Branch
O f f i c e ( ). Branch Has Staff
Branch O f f i c e , Member of Staff ( ).

",

, ''

. 11.7, Arranges
404

III.

" (Supervisor)

(Supervisee)"

Supervisee
. 11.8. Supervises
Supervisor Supervisee

' '

Manages
-Has

" "
. 11.9. ,
Manages Has,

, ,
, .

11.3.
. .
. ,
staff () staffNo (
), name (), position () salary (). , , .
11. "-"

405

, , , , ,
11.5. .
- . .
, .
,
; , (. 3.2). ,
1 15 . ,
rooms ( ) PropertyForRent
1 15.
. , address () Branch ( ), PrivateOwner ( ) BusinessOwner
( ) ,
. , . , address Branch ,
street, city postcode.
name () ,
. , ,
,
.
, ER-.
, , , .

11.3.1.
. ,
j .

. position () salary
() Staff. ,
* , ,
; .
, . , address
() Branch, ,
'163 Main St, Glasgow, Gil 9QX 1
street ('163 Main St'), city ('Glasgow 1 ) postcode ( ' G i l 9QX 1 ) address
street, city postcode , address
.
406

III.

11.3.2.
; . ,
^ .
. , Branch
(branchNo), , ' ' . branchNo .
>. . ,
; .
. , Branch
telNo ( ). , '' '0141-339-2178' '0141-3394 4 3 9 ' . , telNo .
(, ,
). , telNo . ,
.

11.3.3.
; . , ,
^ ,
j ( ) .
. , duration ( ) Lease (
) rentstart ( )
rentFinish ( ),
Lease. duration ,
rentstart rentFinish.
. , totalStaff
( ) staff
s t a f f .
. , deposit
() Lease. deposit
. , deposit Lease rent PropertyForRent.

11. "-"

407

11.3.4.
. ,
.
,
. , (branchNo)
Branch, Branch. ,
. , NULL
(. 3.2). , (, ' '), .
^;1^|^9^^|;91 ^^||3-11^^1^11^; '" ' '

. ,
|: .

!|

. ,
staf fKo,

(National Insurance Number NIN),
. , Staff
, .

, ,
. , (, ' SG14 ' )
, ,
(, ' WL2206S8D 1 ). , Staff staff No, NIN, .
. ,
.
, , , , . , Advert ( ) propertyNo, newspaperName, dateAdvert cost.
. propertyNo, newspaperName ( )
dateAdvert ( ). , Advert
( ) ,
propertyNo, newspaperName dateAdvert.



, , ,
. ,
408

III.

. , . 11.10 ER Staff Branch .


()
, . () () {} (
primary key). UML , , ,
(, address
telNo), , ,
{}
( partial primary key), , {}
( alternate key). . 11.10,
Staff staffNo,
Branch branchNo.

Manages *-

Staff /
f

staff No {PK}
name
position
salary
/totalStaff -*

Has

Branch

/
\- J
^"""

~~*^

branchNo {PK}
street
city
telNo [1..3]

~-"

. 11.10. Staff Branch,

ER-
.

, . ER- ,
{} .
,
. , . , . 11.10
address Branch, ,
, street, city postcode.
.
, telNo [1. .*] , ,
telNo . , 11. "-"

409

. , telNo , [1, . 3].


(/). , . 11.10 Staff
/totalStaff.

11.4.
.
. ,
- .
, . , . 11.1, S t a f f , Branch, PropertyForRent Client. , ()
. ,
staff No, S t a f f .
::: . / - .
.
Preference () . 11.11. ,
,
. , ,
Preference . ,
Preference
.
, ,

Client, : clientNo. Preference Client
,
.
, , , .

11.5.
11.3, .
Advertises
Newspaper PropertyForRent, . 11.1. ,
, .
410

111.

" "

States

. 11,11. Client
Preference

Advertises dateAdvert cost, Newspaper PropertyForRent.


, ,
, . , , , ,
() ,
. , . 11.12
Advertises dateAdvert cost.
. 11.1 Manages
mgrStartDate bonus.
" "
Newspaper
newspaperName

Advertises *
i
l
i
l
l
l

PropertyForRent
propertyNo

dateAdvert
cost
. 11.12. Advertises
daCeAdverC cost

,
,
. , dateAdvert cost
Advertises Advert (
).

11. "-"

411

11.6.
, ,
. , . ,

. ,
, .
= . ( )
, ,
.
. ( -), . ,
.
, . " "
(1:1), " " (1:*) " " (*:*),
:
(1:1);
,
(1:*);

(*:*)
11.6.1-11.6.3 ,
, ER-.
11.6.4 .
, ER-. , ER-
, .

11.6.1. " "


Manages, Staff
Branch. . 11.13
Manages ( rl 2). () Staff Branch. Staff Branch, : staffNo
branchNo.


, , . 412

111.


Staff (staffNo)

SG5

\
\


Manages

/
/


Branch (branchNo)

/
/"-..,:

* '--.
Sl.21

BOQ5

I
\

. 11.13. , S t a f f Manages Branch

, , ,
. , , , .
. 11.13, s t a f f No ( ) SG5 branchNo, , s t a f f N o SL21 branchNo B005,
staffNo SG37 . ,
, . , , , ,
" " (1:1).

1:1
. 11.14 ER- Staff Manages Branch.
,
, Branch
. .1. ,
, Staff
1. .1. ( , 1:1 , .)

11.6.2. " " (1 :*)


Oversees Staff PropertyForRent.
. 11.15
Staff Oversees PropertyForRent ( rl, r2 ).
() Staff
PropertyForRent.
S t a f f
PropertyForRent, : s t a f f N o propertyNo.

11. "-"

413

,

, ,
"

^,
[
1
' ^/

Staff

staffNo

1..1

Manages >

Branch

0..1

branchNo

. 11.14.

(1:1)

Staff Manages Branch

Staff
(staffNo)

SG37

PropertyForRer t
(propertyNo)

^-

SA9

r2
& ""'

p<*3
PA;

Puc. 11.15. , Staff Oversees PropertyForRent


. 11.15 , staffNo, SG37, propertyNo PG21
PG36, s t a f f N o SA9 propertyNo PA14, staffNo
SG5 , propertyNo PG4 . ,
, , ,
. , ,
, , , ,
. "
" (1:*).

1 :*

. 11.16

ER-

Staff
Oversees
PropertyForRent. , 414

III.

, ,
,
PropertyForRent 0. . *. ,
, S t a f f . . 1.
( , 1:* ,
, "" "".)
,
. , , ,
100, 0. . * 0. . 100.

11.6.3. " "

Advertises

Newspaper

PropertyForRent. . 11.17 Advertises ( rl, 2, 4).


()
Newspaper PropertyForRent.
Newspaper PropertyForRent, :
newspaperName propertyNo.


. 11.17, Glasgow Daily
propertyNo PG21 PG36, The
West News propertyNo PG36,
Aberdeen Express
propertyNo PA14. , propertyNo PG4
. , , ,
. , , , .
" " (*;*).
" ?*

,
".

Staff

staffNo

0..1

"
,
,
"

Oversees >

PropertyForRent

0..*

propertyNo

. 11.16. Staff Oversees


ForRent " " (1:*J
11. "-"

Property

415

Newspaper
(newspaperName)

Advertises

PropertyForRent
(propertyNo)

. 11.17. , Newspaper Advertises PropertyForRent

*:*
. 11.18 ER- Newspaper Advertises
PropertyForRent. ,
, ,
PropertyForRent 1..*.
, ,
, ,
Newspaper 0. . *.
( , *:* ,
, .)

11.6.4.
, , .

" ,

,
"

"
,
,
,
"

Advertises
.

. 11.18.

Newspaper
PropertyForRent " "

416

Advertises

III.

( ). (
^ ) n- , <-1) .
, n- , , , (-1)
, , . ,
, ,
. Registers Staff, Branch 1 lent
(, 11.19 11.20). . 11.19
Registers ( rl 5). ()
Staff, Branch Client. Staff, Branch Client, : staffNo, branchNo
clientNo. , . 11.19 Registers, Staff Branch .
Staff/Branch
(staff No/branchNo)

Registers

Client (clientNo]

. 11.19. , Registers Staff Branch

. 11.20. Registers

11. "-"

417


. 11.19 staffNo/branchNo clientNo, , sCaf fNo SG37, branchNo B003, clientNo CR56 CR74, staffNo SG14 branchNo
clientNo CR62, CR84 CR91. , staffNo SG5 kranchNo . , staffNo branchNo , clientNo
. .Registers
Staff Branch 0..*, ER- 0. . *, Client.
, , Staff/Client 1..1,
Branch. , Client/Branch
1..1, Staff.
ER- Registers . 11.20.
,
,
. 11.2.
11.2.

. .1

1. . 1 ( 1)

0 . . * ( *)

1--*

, , -

, , ,

11.6.5.
,
.
:: . -:
, ,
. \

'.

'.I 1 '"

- '

V >'._" ,:

;^'&!'-: - " '


^ "
" (1:1), " " (1:*) " " (*:*).
::;

. _ . - , ; - .

' - , !

"> '

''

'

',

"

" :

'

. -'

.. .

'

. . ,
^ .
VV /

418

'

'

'

III.

, ( ) ( ). . 11.21 Staff Manages Branch (1:1),


. 11.14.
, ER-, . 11.22.

11.7. ER
,
. ,
(connection trap),
[160].
:
"" (fan trap) "" (chasm trap), ER-.

, . ,
.

11.7.1. ""
"". , ; ,
[ .

"

"

"

"

Staff
staffNo

Branch

Manages *

1..1

0..1

"
-
" (

)

branchNo

"
'
(

]_

. 11.21. ,

Staff Manages Branch (1:1)
11. "-1

419

UML


{}

EntityName
attributeName {PK}
attributeName {AK}
attributeName
attributeName
attributeName
/attributeName
attribute [min..max]

RelationshipName

Win value.. Maxvalue

Minvalue.. Maxvalue

.

().
().

.

/ .


[min..max]




(MinVa!ue..MaxValue)

()

. 11.22. , , ER-
"" ,
1:* .
"" . 11.23, 1:* (Has
Operates) Division.
420

III.

Staff

4 Has

1..'

1..1

Division

Operates *
1..1

1..'

Branch

. 11.23. ""

, (Division)
(Branch) .
, . . 11.24 , Has Operates
S t a f f , Division Branch.

: " 'SG37'?"
, , . ,
' ' ' 0 0 7 ' .

"", S t a f f , Division Branch. ER- , . 11.25.

Staff

Division

Has

Operates

Branch

. 11.24. ER-, . 11.23


"

. 11.25. ER- (. 11.23)


""

11. "-"

421

Operates Has
(. 11.26), , . , 'SG37' ' ', ' D1'.

11.7.2. ""
"". , , ' ;.
"" ,
, ( ),
. . 11.27 ""
Branch, Staff PropertyForRent.
, ,
, .
- .
, , .
. 11.28 Has Oversees,
Branch,
Staff PropertyForRent.

Division

Branch

Operates

Staff

. 11.26. ER-. . 11.25

Branch

Has*1..1

1/

Staff

Oversees *
0..1

PropertyForRent

. 11.27. '"

422

III.


Staff

Branch

Oversees

PropertyForRent

. 11,28. ER-, . 11.27

: "
' 1 4 ' ? " , ,
,
- . ( ,
- ),
"".
S t a f f PropertyForRent Oversees , , ,
. Offers
Branch PropertyForRent. ER-,
. 11.29, . , , , , .
Has,
Oversees Offers (. 11.30), , : '14'
' 0 0 7 * .
Has

Oversees

Offers


Offers

""

. 11,29, ER-, . 11.27, ""

11. "-"

423


Branch

Has

Staff

PropertyForRent

. 11,30. ER-, . 11.29

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

424

III,

,
.
,
.
, , ,
.
,
,

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

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

11.1. , ER-,
.
11.2. , ER-,
-, -, - .
11.3. , ER-, , , ,
.
11.4. ?
11.5. ?

11. "-"

425

11.6.


, ?
11.7. .
11.8. ,
.
11.9. ""
"" ER- ?

11.10. ER- .
) , .
) , ), , .
) !!, ),
,
.
) , ),
.
) ER-, )-),
ER-.
11.11. , ,
. 30 , 100
. , , . , .

.
) .
) .
, .
) ) ), ER-,
.
11.12. ,
. .
, ,
, , , . , . , , .
:
, .
426

II.

, .
, . ,
, , , ,
, , , , , . . ,
. , Action (), Adult ( ), Children
( ), Drama (), Horror ( ) SciFi ( ). , . ,
. , , . , .
. , , : , , , , ,
, , , . .
) .
) " , ),
ER-.
) ,
).
ER-, ).
) .
ER-, ).
) () .
) , )-), ER-. , .

11. "-"

427


"-"
...

, ER-,
,
.

"-" (EER
Enhanced Entity-Relationship), /,
.
/,
EER-
UML (Unified Modeling Language ).
11 "-" (ER
Entity-Relationship).
,
, ,
. 1980- ,
.
(CAD Computer-Aided Design),
( Computer-Aided Manufacturing), (CASE Computer-Aided Software Engineering),
(OIS Office Information Systems) ,
(GIS
Geographical Information Systems). 24. ER-
, ,
"" . , ER-.
ER-, ,

"-"
(Enhanced
EntityRelationship EER). EER-: /, . -

/, EER-
UML (Unified Modeling Language ) [35]. 11 UML
ER-.

12.1 , /, EER UML. , , / ER- UML, 12.2 , 12.3 .


, EER- UML.

12.1. /
/ ,
, . ,
, /. . /, . ,
/
"-" (EER-) UML.
, /
"-" (ER-) Branch
DreamHome, , 11.1.

12.1.1.
11,
, Staff (), Branch () PropertyForRent
( ). , , .
. , ; ,
.

."

.;.,

,;

. 1 .

, , . , , s t a f f , Manager (), SalesPersonnel ( 430

III.

) Secretary (). , Staff Manager, SalesPersonnel Secretary. /. , / Staff/Manager.

12.1.2. /
.
, , , ,
,
. "
" (1:1) / (. 11.6.1). ;
,
, , Manager
SalesPersonnel
S t a f f . , ; , ,
, .
, , . , , salesArea ( ) carAllowance
( ). Staff
, , ,
, . , , s t a f f N o ( ), name ( ),
position () salary (). ,

. , , , (), . ,

, ,
, SalesPersonnel
Uses Car ( ).
AllStaff
( ), . 12.1.
, .
, ( ), , ,
( : staffNo, name, 'position salary), ,
,
, . ,
, Manager (mgrStartDate (
) bonus ()), SalesPersonnel (salesArea carAllowance)
Secretary (typingSpeed ( )), , . , , 12. "-"

431

Manager, SalesPersonnel Secretary,


, .
, ER-
. -,
, ,
ER- . -,
,
. , ,
" IS-A () " " IS-A
() ",
.

12.1.3.
, , ,
" ", ,
, , , .
,
SalesPersonnel Staff ( staffNo,
name, position salary), ,
SalesPersonnel ( salesArea carAllowance).
, , ,
, . , .. . ; ,
(, Manager Staff),
(, Staff Manager)
IS-A (, Manager IS-A ( ) Staff). .
, , . ,
,

II
staffNo

name

position

salary

SL21
SG37
SG66

John White
Ann Beech
Mary Martinez
Mary Howe
Stuart Stern
Robert Chin
Susan Brand

Manager
Assistant
Sales Manager
Assistant
Secretary.
Snr Sales Asst
Manager

30000 01/02/95
12000
27000
9000
8500
17000
24000 01/06/91

SA9

SL89
SL31
SG5

,
,

II

mgrStartDate bonus

sales
Area

car
Allowance

SA1A

5000

SA2B

3700

*'

typing
Speed

2000

100

2350

. 12.1. AllStaff,

432

. , , . .

12.1.4.
. ;:; .
.
.
, ( ),

( ). , ,
S t a f f . S t a f f , , / . , ,
, , , Manager, SalesPersonnel
Secretary S t a f f .

12.1.5.
I .
.
, . , , Manager,
SalesPersonnel Secretary .
,
, . ,
, , , Manager, SalesPersonnel
Secretary s t a f f .
,
/.

/
UML /. , / Staff, , . Staff Manager, SalesPersonnel Secretary
12. "-"

433

"-" (EER-),
. 12.2. , Staff , .
, .
{Optional, And) / , .
12,1,6.
, ,
, . ,
salesArea carAllowance SalesPersonnel
Manager Secretary.
, Manager
(mgrStartDate bonus) Secretary (typingSpeed).
, , , . , s t a f f No, name,
position salary S t a f f . , , . ,
. 12.2 Manager Branch
Manages (), Staff Branch Has ().
. ,
Staff FullTimePermanent
( ) Part Time Temporary ( ),
,

. 12.2. / S t a f f , ,

434

III.

. . 12.3 Staff , . , FullTiraePermanent (salaryScale


( ) holidayAllowan.ce ()) PartTimeTemporary
(hourlyRate ( )).
, , ,
.. . . 12.4;
/ (. . 12.2) ,
,
SalesManager ( ), Secretary
Assistant Secretary ( ).
, SalesManager SalesPersonnel Manager, S t a f f ,
, SalesManager Staff
(stiaffNo, name, position salary) SalesPersonnel
(salesArea carAllowance) Manager (mgrStartDate bonus),
salesTarget ( ).

,
AssistantSecretary

Secretary, S t a f f . ,
AssistantSecretary

Secretary S t a f f . AssistantSecretary Staff (staffNo, name, position salary) Secretary (typingSpeed), startDate.

{Mandatory, Or}

FullTitnePermanenl

PartTimeTemporary

salaryScale
holidayAllowance

hourlyRate

, 12.3. / Staff,
12. "-"

435

. 12.4. / Staff, , SalesManager Secretary,


AssistantSecretary

12.1.6. /
/ , : (participation constraint) (disjoint constraint)


; . , .
"

- ;

: - . : > . /

< :

\:

..

''

'

'

:*,'2,

.
/ ,
. , , "Mandatory" (). , . 12.3 /, ,
.

436

111.

/ , .
, , , ,
"Optional" (). ,
, /,
. 12.3, , , , Manager, SalesPersonnel Secretary.


; .
,
; .
, . , .
/
"Or". , . 12.3 /, , , ,
,
, .
, /, ( ),
.
/

"And". , . 12.3 /
, ,
Manager, SalesPersonnel Secretary. , SalesManager, . 12.4.
, , , ,
SalesManager AssistantSecretary, . 12.4, .
,
, , : " ", " ", " " " ".

12.1.7. /

Branch DreamHome
, , EER- /
( 1.6). ,
12. "-"

437

, ( ),
,
EER-.
11 , ER. Branch
Dreamffome. . 11,1 ER-.
/
ER- Branch EER-.
, . 11.1. ,
, . Branch , /, .
) , S t a f f , . 11.1, . Branch DreamHome,
,
, : Manager Supervisor ().

. ,
staff (. . 11.1),
S t a f f , Manager Supervisor,
Manager Supervisor S t a f f . , . ,
S t a f f Manager
Supervisor, staf fNo.
, Supervisor , . ,
Manager : ragrStartDate
bonus. Manager Supervisor
Manager Manages Branch ( )
Supervisor Supervises 3'iaff ( ).
Manager Supervisor Staff, . 12.5. , EER- .
; ,
/ .
/ Staff
( (Optional, Or}),
, ,
. , S t a f f ,
, ,
: Manager Manager Branch Supervisor Supervises S t a f f .

438

III.

Supervises

. 12.5.
Manager

Staff

Supervisor

) / .
Branch : PrivateOwner
( ) BusinessOwner ( ),
. 11.1. . , PrivateOwner BusinessOwner (. . 11.1),
Owner (), , PrivateOwner BusinessOwner
Owner. , , ,
. PrivateOwner
BusinessOwner (address () telNo
( )) ,

(PrivateOwner
POwns
PropertyForRent

BusinessOwner BOwns PropertyForRent).


; , PrivateOwner
ownerNo name, BusinessOwner
bName, contactName.
Owner PrivateOwner
BusinessOwner, . 12.6.
/ Owner
( {Mandatory, Or}),
, , . , Owner
PropertyForRent: Owns ().

12. "-"

439

Owner

PropertyForRent

Owns >

address
telNo

1..1

(Mandatory, Or)

PrivateOwner

BusinessOwner

ownerNo {PK}
name

bNarne {PK}
bType
contactName

1..*

propertyNo jPK}
address
street
city
postcode
type
rooms
rent

. 12.6. Owner PrivateOwner


BusinessOwner

/
. / ,
.
) Branch DreamHome , . , , , number name.
Person (),
Staff ( Manager
Supervisor), PrivateOwner Client, . 12.7.
,
/ Branch
DreamHome.
/, ) ),
) (. 12.8). EER- , . 12.7, / ,
, , Branch PropertyForRent.
, / , .
,
14, /
1.6.
2.3,
, ,
, , . , / , 440

III.

{Mandatory, Or}

Staff

PrivateOwner

Client

position
salary

address
telNo

telNo

(Optional, 0 ;

Supervisor

Manager
dateMgrStart
bonus

, 12.7. Perspn Staff (


Supervisor Manager), PrivateOwner u Client
, ER-.

/ Branch DreamHome. , ,
Branch: ER-, . 11,1,
EER-, . 12.8. .

12.2.
-. "has-a" () "is-part-of (
) , "", "".
, .
"has-a" "is-part-of",
("")*
(""). [35]. ,
,
.
Has, Branch ("") Staff ("").
12. "-"

441


dvartises

0..'

Newspaper
news pa rN a m e

Pi ivate Owner

BusinessOwner

ownerNo

bName

. 12.8. "-" Branch


DreamHome, . /


UML , , "". . 12.9 EER-, . 12.8, . EER- : Branch Has
Staff ( ) Branch Offers PropertyForRent

442

III.

,
' ""
. Has Offers^

"

Branch
branchNo

,
( "1'
Offers
. 12.9. : Branch Has
Branch O f f e r s PropertyForJ?ent

staff

( ). Branch "",
.

12.3.
. , , : "" "".
!(.'..

"'

"

.:;.-

-,.',-..-,.

.;:.

"

,
, ""
"". , , "" "" [35]. "" "", ,
"". , .
. 12.8 .
, Displays (), Newspaper () Advert ( ).
12. "-"

443

, , Advert
("") Newspaper ("").
,
. , Staff
"" Branch.


UML , , "". ,
. 12.10, Newspaper Displays Advert
Newspaper, "", .
,

"" 8
Displays

""
Displays

. 12.10.
Advert

Newspaper

Displays

/, ,
, . , , "has-a" "is-part-of", , , it
( "", "").
( 2.5
15). , EER-, . 12.11.
,

.
,
, ER-.

444

111.


, = Mandatory
Optional

/".

= And Or

"

""

"1

""

,

"" ""

. 12.11. , EER-

12. "-'

445

,
, .
, .
.
.
/ : .
, .

, - ,
"has-a" () "is-part-of" (
) , "", "".
, ,
"" "".

:
12.1. .
12.2. .
12.3. .
12.4. EER-?
12.5. ?
12.6. .
12.7. , ,
/.
12.8. , .

12.9. , "-", /, / , ,
.
12.10. , "-", /, / , ER- , 11.12.
, ER-
EER- .
446

ill.


...

.
, ,
: ,
.

.

.

, .
,
:
(1), (2) (),
- ().
(4) (5) .
, .
. , ,
(normalization).
, . , IV, , , .

.


'

-':: .,'"'

- ;".'

1 :,': . '<!:"

' 1 ,;:

13.1 .
13.2 , . 13.3
, : -

, . 13.4
, :
(1) ( 13.5), (2) ( 13.6)
() ( 13.7). 2 ,
, . 13.8
2 ,
. 13.9
, - (). 13.10 , () . 13.11
13.12 , ,
(4) (5) .
15 , ER- ( 11 12) .
, .
DreamHome,
10.4, .

13.1.
- .
I , .
. . [68]. ( ) . :
(1), (2) (). . . . [69]
, - (). , [212], , , .
(4) (5) [109], [110]. .
3 , .
, ER- (. 15). ,
.
, 448

. 111.

, . ,
, .

13.2.

, , , . ,
, , Staff
Branch . 13.1 13.2 StaffBranch . 13-3.
StaffBranch Staff
Branch. :
Staff
Branch
StaffBranch

( s t a f f N o , sName, position, salary, branchNo)


(branchNo, bAddress)
(staffNo, sNatne, position, salary, branchNo, bAddress)

, .
13.1. Staff
staffNo

sName

position

salary

branchNo

SL21

John White

Manager

30000

BOOS

SG37

Ann Beech

Assistant

12000

B003

SG14

David Ford

Supervisor

18000

SA9

Mary Howe

Assistant

9000

B007

SG5

Susan Brand

Manager

24000

SL41

Julie Lee

Assistant

9000

BOOS

13.2. Branch
branchNo

bAddress

005

22 Deer Rd, London

007

16 Argyll St, Aberdeen

163 Main St, Glasgow

13.3. StaffBranch
position

salary

branchNo

bAddress

John White

Manager

30000

BOOS

22 Deer Rd, London

Ann Beech

Assistant

12000

163 Main St, Glasgow

David Ford

Supervisor

18000

163 Main St, Glasgow

staffNo

sName

SL21

SG37
SG14

13.

449

. 13.3
staffNo

sName

position

salary

branchNo

bAddress

SA9

Mary Howe

Assistant

9000

8007

16 Argyll St, Aberdeen

SG5

Susan Brand

Manager

24000

BOOS

163 Main St, Glasgow

SL41

Julie Lee

Assistant

9000

BOOS

22 Deer Rd, London

Staff Branch ,
,
. Branch , Staff
(branchNo),
. , ,
, , .

13.2.1.
,
Staf fBranch (, . 13.3).
Staf fBranch. , . ,
' 0 0 7 ' ' 0 0 7 ' ,

StaffBranch. , . 13.1
13.2, , Staff
. ,
' B O Q 7 ' , Branch.
,
, NULL StaffBranch,
staffNo. staffNo StaffBranch,
NULL staffNo
(. 3.3) . ,
StaffBranch , NULL staffNo. , . 13.1 13.2,
, Branch . , ,
Staff .

13.2.2.
StaffBranch

. ,
450

III.

Staff Branch 'Mary Howe ' SA9'



1
007 . , . 13.1 13.2, ,
.
branchNo.
Staff ' SA9'
'07 ' Branch .

13.2.3.
Staff Branch (,
' ' ) .
Staf fBranch., . ,
' ' , , .
,
. 13.1 13.2 Staff Branch , Staf fBranch, . 13.3. ,
StaffBranch ,

Staff Branch.
. -, , . -, , ,
. , , , ,
.
.
, .

13.3.
(functional dependency)
[212].
,
.

13.3.1.
, (, , , . . ., Z)

R = (, , , . . . , Z ) . ,
.
13.

451

. . R, ,
( {)),
. ( . .)
( ) . ,
, , .
, . ,
, ,
. ,
, . .
, . 13.1.

. 13.1.

. , .
, ,
(determinant). , . 13.1
. .

13.1.
staffNo position Staff,
. 13.1. staffNo (, 'SL21'),
, ('Manager'). ,
position staffNo,
. 13.2, . . 13.2, , , staffNo position.
, , , .
staffNo position " "
(1:1),
. position s t a f f N o "
" (1:*), ( 452

III.

), . staffNo staffNo-position.
, " ".
position

staffNo

SL21

Manager

staffNo

position

SL21
Manager
SG5
)

. 132, : ) position staffNo


(staffNo^position); ) staffNo
position (position-*? staffNo)


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

I 13.2. ,

, staffNo sName
Staff (. . 13.1). ,
staffNo, SL21,
, John White. , , , sName, John White,
,
SL21. ,
13.

453

staffNo sName /
sName staffNo? , Staff (. . 13.1),
s t a f f No sName,
:
staffNo - sName
sNarae
> staffNo
, Staff (. 13.1), staffNo sName - , ", .
, , , , . , ,
.
,
. , ,
staffNo, , , sName, . , (staffNo) ,

(sName). , sName
, ,
(staffNo) . , staffNo sName
" " (1:1), . , sName
staffNo " " (1:*),
. , s t a f f N o sName Staff,
:
staffNo > sName
,
,
. ,
. , . , ,
, ( ) ., ()
, .
454

III.

I 13.3.
Staff .
s t a f f N o , sName sName
staffNo, sName - staffNo

staffNo
sName Staff, ,
, .
, ; ,
.
:
" " , ;
;
.

.

I 13.4.
StaffBranch
StaffBranch
(. . 13.3J. , ,
, .
,
:
s t a f f N o sName, position, salary, branchNo, bAddress
branchNo > bAddress
bAddress > branchNo
branchNo, position > salary
bAddress, position > salary
,
StaffBranch,

staffNo,
branchNo,
bAddress, (branchNo, position) (bAddress, position).
,
, ,
, .

13.3.2.

,
13.

455

. ,
,
.
.

I 13.5. StaffBranch

StaffBranch (. . 13.3).
staffNo, branchNo, bAddress,
(branchNo, position) (bAddress, position).
() StaffBranch,
, ( ) .
, ,
(.
3.2.5). , (
, ), .
StaffBranch, , staffNo, staffNo.
branchNo, bAddress, (branchNo, position)
(bAddress, position) ,
.
,
,
, , ( ) . .
. , ,
13.4, .

13.3.3.


" "
(1:1), , .
, . ,
( X) , ,
( Y)
, , Y X.
456

III.

,
X, , (Y).
, , . , >, ,
>. > 13.7.1.
, . ,
,
. .
"" .
,
,
, .
, X, X X*. , ,
, X* X. ,
, [7]. , , R. .
1. . , >.
2. . -^, , >, .
3. . > -, ^.
,
. ; , X , ,
X, X .
, - , X.
, X*.
, , ,
X 4 . , D R, .
4. . -^.
5. . >,

, - >.

6. . - ->, -*, .
7. . C->D, ,

>,

D.

1 () 4 () ,

. 13.

457

, , , ,
. 2 () ,
, . 3 ()
, . 5 () ,
. -^, , D
-, A-D. 6 () , , -, > A-D ,
, D. 7 () , 6, , .
F
, , , .
( 1-3) , . ,
,
, , .
*
, F (* F).

13.3.4.

. Y X, Y X*; ,
X.
X ,
.
1. X .
2. > X >,
, , X.
3. X , X.
, .
X X raln , X. ,
. StaffBranch
.
458

hi.

I 13.6.
StaffBranch
, , StaffBranch, 13.4, :
s t a f f No sName
staffNo
> position
s t a f f N o > salary
s t a f f N o - branchNo
s t a f f N o > bAddress
branchNo bAddress
bAddress branchNo
branchNo, position salary
bAddress, position > salary


StaffBranch. 1 , . 2
3 , ,
( 2),
,
X ( 3).

13.4.

( ) [68]. ,
, .
,
, ( )
.

, , .
() . ,
(1).
.
, 13.2, ().
. 13.3 . , 1
, 2 ..
. , 13.

459

. 13.3.

.

, .
13.5 (1).
13.6 13.7 (2) () , ,
( 13.8).
(2 ) , . 13.9
- (), ,
(4 5),
( 13.10 13.11).
,
,
. , . , IV , ,
, , ,
ER-, 11 12.
ER- , , , .

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

(1). , .

460

ill.


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

, .
2.
,
. .
,
.
, . ,
.
, ,
1 .
1 , . Dreamffome.

13.7. (1)

. 13.4 ,
DreamHome.
'John Kay 1 , , ' Tina Murphy'. ,
.
, , 'John Kay' 'Aline
Srewart', ,
. 13.4. ().
13.

461

DreamHome Lease
DreamHome Lease

<

DreamHome Lease
Property Number PG4

Client Number CR76


(Enter If known)
Full Name

Property Address
6 Lawrence St, Glasgow

John Kay

Monthly Rent .350

Owner Number CCW0


(Enter if known)

Rent Start 01/07/00

Full Name
^ Murphy
(Please print)

Rent Finish 31/08/01

. 13.4. DreamHome
13.4. ClientRental
client

No
CR76

CR56

cName property
No

pAddress

rent
Start

rent
Finish

rent

owner
No

oName

John
Kay

PG4

6 Lawrence
St Glasgow

1-Jul-OO

31-Aug-Ol

350

C040

Tina
Murphy

PG16

5 Novar Dr,
Glasgow

l-Sep-01

l-Sep-02

450

C093

Tony
Shaw

6 Lawrence
St, Glasgow

l-Sep-99

10-Jun-OO

350

C040

Tina
Murphy

PG36

2 Manor Rd,
Glasgow

10-Oct-OO

l-Dec-01

375

C093

Tony
Shaw

PG16

5 Novar Dr,
Glasgow

l-Nov-02

10-Aug-03

450

C093

Tony
Shaw

Aline
PG4
Stewart

ClientRental
(-) clientNo ( ). ,
. :
= (propertyNo, pAddress, rentStart,
rentFinish,rent, ownerNo, oName)
-
. , John

462

III.

Kay , PG4 PG16 ( propertyNo). , . .


(
) . ClientRental,
, . 13.5, : (clientNo,
propertyNo), (clientNo, rentstart), (propertyNo, rentstart).
(clientNo, propertyNo)
,
. ,
rentFinish
, NULL (. 3.3.1).
13.5. (1) ClientRental

rent

owner oName
No

350

C040

Tina
Murphy

l-Sep-01 l-Sep-02

450

C093

Tony
Shaw

6 Lawrence St,
Glasgow

l-Sep-99 10-Jim-OO

350

C040

Tina
Murphy

Aline
Stewart

2 Manor Rd,
Glasgow

10-Oct-OO l-Dec-01

375

C093

Tony
Shaw

Aline
Stewart

5 NovarDr,
Glasgow

l-Nov-02 10-Aug-03

450

C093

Tony
Shaw

clientNo property
No

cName

pAddress

rentstart rent
Finish

CR76

PG4

John Kay

6 Lawrence St,
Glasgow

1-Jul-OO

CR76

PG16

John Kay

5 Novar Dr,
Glasgow

CR56

PG4

Aline
Stewart

CR56

PG36

CR56

PG16

31-Aug-Ol

ClientRental :
ClientRental (clientNo, propertyNo, cName, pAddress, rentstart,
rentFini sh, rent, ownerNo, oName)
ClientRental ,
.
, , . , ClientRental . 1 , 13.2.
, .
( )
(clientNo),
. 13.7. (
. 13.6.)
. 1 .
13.

463

{1i entNo, cName)


Client
PropertyRentalOwner {clientNo, propertyNo, pAddress, rentStart,
rentFinish, rent, ownerNo, oName)
13.6.
(1) Client
clientNo

cName

CR76

John Kay

CR56

Aline Stewart

13.7.
(1) PropertyRentalOwner
rentStart

rentFinish

rent

owner

oName

No

property pAddress
No

CR76

PG4

6 Lawrence St,
Glasgow

1-Jul-OO

31-Aug-Ol

350

C040

Tina
Murphy

CR76

PG16

5 NovarDr,
Glasgow

l-Sep-01

l-Sep-02

450

C093

Tony
Shaw

CR56

PG4

6 Lawrence St,
Glasgow

l-Sep-99

10-Jun-OO

350

C040

Tina
Murphy

CR56

PG36

2 Manor Rd,
Glasgow

10-Oct-OO

l-Dec-01

375

C093

Tony
Shaw

CR56

PG16

5 Novar Dr,
Glasgow

l-Nov-02

10-Aug-03

450

CO 93

Tony
Shaw

client

No

(Client PropertyRentalOwner)
, . Client ,
PropertyRentalOwner . , . 1,3.7, , , 13.2.

1 2 Client Rental,
. 13.5. , . Client PropertyRentalOwner.

13.6. (2)
(2) , .

464

III.

13.6.1.
. -~ ,
,
,
.
> , - . -^ ,
, .
, :
staffNo, sName > branchNo
( s t a f f N o , sName) toranchNo. ,
branchNo {staffNo,
sName), .. staffNo. .

13.6.2.
, .. , . ,
, , 2. , 2, , 13.2. , ,
' PG4',
ClientRental, . 13.5.
, .
* (2). ,
, t , ; .
1 2
, ClientRental, . 13.5. , -
. 1
2 .

13.

465

I 13.8. (2)
. 13.5 ( fdl fd6) ClientRental (clientNo, propertyNo}
.
ClientRental
clientNo prop srtyNo

cHame

pAddress rant Start rentFinish rent ownerNo oName

fdl

fd2

( )

( )

fd3

11

t
fd4|_
^

fdS

wet

t
t

1\

i (
(
1 )
i

( )

, 13.5. ClientRenCal

ClientRental ,
,
, . 13.8.
ClientRental

fdl

clientNo, propertyNo -> rentStart, rentFinish

fda

clientNo -> cName

fd3

propertyNo -* pAddress, rent, ownerNo, oName

ovmerNo > oName

id Pi

clientNo, rentStart -* propertyNo, pAddress,


rentFinish, rent, ownerMo, oName

propertyNo, rentStart clientNo, cName,


rentFinish

fd6

ClientRental
.

466

III.

. , cName , ,
clientNo ( fd2).
, (pAddress, rent, ownerNo, oName)
,
propertyNo ( fd3). , (rentstart rentFinish) , ..
clientNo propertyNo ( fdl).
, . 13.5 (transitive dependence) ( fd4). ,
2.
.
, ClientRental, a
, .
ClientRental 2
, , , ,
, .

Client, Rental PropertyOwner,
. 13.8-13.10.
, , ,
.
:
Client
Rental
PropertyOwner

(clientJJo, cName)
(clientNo, properjtyNo, rentstart, rentFinish)
(propertyNo, pAddress, rent, ownerNo, oName)

13.8. (2) Client,


ClientRental
clientNo

cName

CR76

John Kay

CR56

Aline Stewart

13.9. (2) Rental,


ClientRental
propertyNo

rentstart

rentFinish

CRT 6

PG4

1-Jul-OO

31-Aug-Ol

CR76

PG16

l-Sep-01

l-Sep-02

CR56

PG4

l-Sep-99

10-Jun-OO

CR56

PG36

10-Oct-OO

l-Dec-01

CR56

PG16

l-Nov-02

10-Aug-03

clientNo

13.

467

13.10. (2) Property Owner,


ClientRental
propertyNo

pAddress

rent

ownerNo

oName

PG4

6 Lawrence St,
Glasgow

350

C040

Tina Murphy

PG16

5 Novar Dr,
Glasgow

450

C093

Tony Shaw

PG36

2 Manor Rd,
Glasgow

375

Tony Shaw

13.7. ()
2 ,
1, . , (,
Tony Shaw ( ownerNo))
PropertyOwner, . 13.10. , .
, . . .

13.7.1.
. ,
- -*, , ( , , ).
. , StaffBranch (. . 13.3):
s t a f f N o -> branchNo
branchNo > bAddress

staffNo > bAddress


branchNo. ,
s t a f f N o branchNo bAddress.
.

13.7.2.
(). ,
,
, .
468

III.

2 .
,
. 2 13.9.

I 13.9. ()
,
Client, Rental PropertyOwner, .

clientNo -> cName

ci lent
fd2
Rental
fdl

clientNo, propertyNo -> rentstart, rentPinish

fd5*

clientNo, rentstart -> propertyNo, rentFinish

propertyNo, rentstart -> clientNo, rentFinish

fd6*

PropertyOwner
fd3

propertyNo -* pAddress, rent, ownerNo, oNarne

fd4

ownerNo -* oName

Client Rental
. , Client Rental
(). ,
(fd)
(*), fd5*, (
).
PropertyOwner , oName, ownerNo ( fd4).
, (oNarae)
, (ownerNo).
. 13.5.
PropertyOwner
PropertyForRent Owner, . 13.11 13.12. :
PropertyForRent
Owner

(propertyNo, pAddress, rent, ownerNo)


(ownerNo, oName)

13.

469

13.11. Property For Rent ,


PropertyOwner
propertyNo

pAddress

rent

ownerNo

PG4

6 Lawrence St,

350

C040
C093
C093

Glasgow

PG16

5 NovarDr, Glasgow

450

PG36

2 Manor Rd, Glasgow

375

13.12. Owner ,
PropertyOwner
ownerNo

oName

040
093

Tina Murphy
Tony Shaw

PropertyForRent Owner ,
.
. 13.5
ClientRental ,
. . 13.6
, , 1 , :
Client
Rental
PropertyForRent
Owner

tclientNp, cName)
(clientNo, prop_ertyNq, rentStart, rentFinish)
(propertyNo, pAddress, rent, ownerNo)
(ownerNo, oName)

ClientRental, . 13.5,
Client, Rental, PropertyForRent
Owner.
. , ownerNo
Owner , , PropertyForRent . ownerNo,
, PropertyForRent Owner , .
ClientMental

PropertyOwner

Client

Rental

PropertyForRent Owner

. 13.6. 1
ClientRental

470

III.

clientNo Client Rental. ,


Rental clientNo ,
. , propertyNo
PropertyForRent Rental , .
,
ClientRental (. 4.1).
,
(nonloss), (nonadditive) . ,
.
Client, Rental, PropertyForRent Owner,
, . 13.13-13.16.
13.13. Client ,
ClientRental
clientNo

cName

CR76

John Kay

.356

Aline Stewart

13.14. Rental ,
ClientRental
clientNo

propertyNo

rentStart

rentFinish

CR76

PG4

1-Jul-OO

31-Aug-Ol

CR76

PG16

l-Sep-01

l-Sep-02

CR56

PG4

l-Sep-99

10-Jun-OO

CR56

PG36

10-Oct-OO

l-Dec-01

CR56

PG16

l-Nov-02

10-Aug-03

13.15. PropertyForRent ,
ClientRental
propertyNo

pAddress

rent

ownerNo

PG4

6 Lawrence St, Glasgow

350

C040

PG16

5 Novar Dr, Glasgow

450

C093

PG36

2 Manor Rd, Glasgow

375

C093

13.16. Owner ,
ClientRental
ownerNo

oName

40

Tina Murphy

093

Tony Shaw

13.

471

13.8.

(2) () ,
13.6 13.7, , , 13.2.
, .
2 , .
, 1,
. ,
,
.
(2).
, , , .

(). s
, ,
;; , .
2
, .
, , .
, , .
, , 2 ,
, , .
, 2 13.8 13.9, 13.6 13.7,
.
.

13.9. - ()
, ,
,
472

111.

13.2. ,
. ,
13.8, , , 13.8 2 .
,
. ,
,
, - () [69].

13.9.1. -
- () , .

, 13.8.
- ().
i: , .

, .
, ,
.
, , , . ,
. ,
- , ,
.
, Client, Rental, PropertyForRent Owner, . 13.1313.16. Client, PropertyForRent Owner
, ,
. , Rental : (clientNo,
propertyNo}, (clientNo, rentStart) (propertyNo, rentstart),
13.5 :
fdl
fdS*
fd6*

clientNo, propertyNo->rentStart, rentFinish


clientNo, rentStart-propertyNo, rentFinish
propertyNo, rentStart->clientNo, rentFinish

Rental , Rental . ,
:
13.

473

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

13.10. - ()
DreatnHome . , , clientlnterview
(. 13.17). , ,
.
.
, .
13.17. Clientlnterview
clientNo

interview/Date

interviewTime

staffNo

roomNo

CR76

13--02

10:30

SG5

G101

CR56

13--02

12:00

SG5

G101

CR74

13--02

12:00

SG37

G102

CR56

l-Jul-02

10:30

SG5

G102

Clientlnterview :
(clientNo, interviewDate) , I s t a f f N o , interviewDate, interviewTime)
(roomNo,
interviewDate,
interviewTime).
,

Clientlnterview ,
,
interviewDate. (clientNo, interviewDate).
:
Clientlnterview (clientNo,
roomNo)

i nteviewDate,

interviewTime, staffNo,

Clientlnterview

fdl

clientNo, interviewDate -> interviewTime, s t a f f N o ,


roomNo

fd2

s t a f f N o , interviewDate, interviewTime > clientNo

fd3

roomNo, interviewDate, interviewTime ~ staffNo,


clientNo

fd4

staffNo, interviewDate ) roomNo

474

- III.


Clientlnterview.
fdl, fd2 fd3 ,
. staffNo, interviewDate > roomNo ( fd4).
(staffNo, interviewDate} Clientlnterview,
, roomNo

(roomNo,
interviewDate,
interviewTime). (clientNo, interviewDate}
fd4, , Clientlnterview ,
(
),

(staffNo,
interviewDate), . , . Clientlnterview
. , 13 2002 (
--02 1 ) , 'SG5 1 ,
.
, .
Clientlnterview
Interview StaffRoom,
. 13.18 13.19. Interview Staf fRoom :
Interview
StaffRoom

(clientNq, interviewDate, interviewTime,


{staffNo, interviewDate, roomNo)

staffNo)

13.18. Interview
clientNo

interviewDate

interviewTime

staffNo

CR76

13-May-02

10.30

SG5

CR56

13-May-02

12.00

SG5

CR74

13-~02

12.00

SG37

CR56

l-Jul-02

10.30

SG5

13.19. Staff Room


staffNo

interviewDate

roomNo

SG5

13-May-02

G101

SG37

13-May-02

G102

SG5

l-Jul-02

G102

, , , . . ,
13.

475

( ). , .
, , .
, 13.10 Clientlnterview "" : roomNo, interviewDate, interviewTime
> staffNo, clientNo ( fd3), , . , staffNo, interviewDate > roomNo ( fd4),
Clientlnterview .
,
, , - fd4, ,
"" fd3. , ,
, fd4 Clientlnterview
.
, , fd4 Clientlnterview
. , fd3. , , fd3 - ,
. , .

13.10.
(1)

, .
- ( 13.11). 2 , .
2 .

13.11.
- ()

DreamHome ,
.
.
.
476

III.

,
. . 13.7
"Property Inspection Report" DreamHome
.

' PG4 ', .
DreamHome
Property Inspection Report
DreamHome
Property Inspection Report
Property Number PG4
Property Address 6Lawrence St, Glasgow

Inspection Inspection
Time
Date
18-Oct-OQ

10.00

22-Apr-Q1
1-Qet-OI

09.00
12.00

Comments
Need to replace
. crockery
in good order
Damp rot in bathroon

Staff no Staff Name

Registration

SG37

Ann Beech

SGt4
SGt4

David Ford M533HDR


David Ford N721HFR

M231JGR

Page 1
. 13.7. "Property Inspection Report" DreamHome

(1)

, . Staff Property Inspect ion;
. 13.20. propertyNo.

,
. , .
= (iDate, iTime, comments, s t a f f N o , sNarae,
carReg)


. , propertyNo (' PG4 ')
iDate (' IS-Oct-oo', '22-Apr-Ol 1 , '1-Oct-Ol')- ,
, 13.5.
13.

477

( ) ( ). StaffPropertylnspection , . 13.21.
13.20. StaffPropertylnspection
iTime comments

property pAddress
No

iDate

PG4

18-Oct-OO

6 Lawrence
St, Glasgow

l-Oct-01

5 Novar Dr,
Glasgow

sName carReg

No

22-Apr-Ol

PG16

staff

22-Apr-Ol

24-Oct-Ol

Need to replace crockery


(
)
09.00 In good order (
)
12.00 Damp rot in bathroom
(
)
13.00 Replace living room
carpet (
)
14.00 Good condition (
)
10.00

SG37

Beech

M231
JGR

SG14

David
Ford

M533

SG14

David
Ford

N721
HFR

SG14

David
Ford

M533

Ann

N721
HFR

SG37

Beech

HDR

HOR

13.21. StaffPropertylnspection
property
No

iDate

iTlme

pAddress

comments

staffNo

sName

carReg

PG4

18-Oct-OO

10.00

6 Lawrence St,
Glasgow

SG37

Ann

M231
JGR

PG4

22-Apr-Ol

09.00 6 LawenceSt,
Glasgow
12.00 6 Lawrence St,
Glasgow
13.00 5 Novar Or,
Glasgow
14.00 5 Novar Dr,
Glasgow

Need to replace
crockery
In good order

SG14

David
Ford
David
Ford

M533

PG4

l-Oct-01

PG16

22-Apr-Ol

PG16

24-Oct-Ol

Damp rotin
bathroom
Replace living
room carpet
Good condition

SG14
SG14

SG37

Beech

David
Ford
Ann

Beech

HDR

N721
HFR

M533

HDR

N721
HFR

staf f Proper t Inspect ion :


(propertyNo, iDate), ( s t a f f N o , iDate, iTime) (carReg, iDate,
i T i m e ) . (propertyNo, iDate). , , .

StaffPropertylnspection :
StaffPropertylnspection (propertyN_o, iDate, iTime, pAddress,
comments, s t a f f N o , sName, carReg)

478

III.

StaffPropertylnspection ,
. , .
StaffPropertylnspection . , 1 .
.
(2)
1 2 . ,
.
( fdl fd6) StaffPropertylnspection
(propertyNo, iDate) . 13.8.

fdl

propertyNo,
iDate

>
s t a f f No , sName , carReg

fd2

propertyNo

fd3

staff

-*

sName

fd4

No

iTime,

comments,

Address

-staffNo, iDate -* carReg

fd5

carReg, iDate, iTime > propertyNo, pAddress,


comments, staffNo, sName

fd6

staffNo, iDate, iTime -> propertyNo,

pAddress, comments

StaffPropertylnspection
propertyNo IDate {Time pAddress comments sta fhlo sName carReg

fdll
fti2\

t ( )

* ( )
{
1 )

fd3
fd4

fdsf

fdef

J ( )

( )

. 13.8. StaffPropertylnspection
13.

479

Staff Property-Inspection . , (2).


, pAddress , propertyNo ( fd2). iTime,
comments, staffNo, sName, carReg
( propertyNo iDate) ( fdl). , staffNo, iDate - carReg ( fd4) iDate ,
, , ( staf fNo). ,
2.
(propertyNo -> pAddress) ,
StaffPropertylnspection
. , ,
,
.
Staf f Propertylnspection

, Property Propertylnspection, :
Property
Propertylnspection

{propertyNo, Address)
(propertyNo, iDate, iTime,
sName, carReg)

comments,

staffNo,

, , ,
.
()
2
.

. Property
Propertylnspection

Property
fd2

propertyNo > pAddress

Propertylnspection
fdl*

propertyNo, iDate ~ iTime, comments, s t a f f N o , sName, carReg

fd3

s t a f f N o ~* sNarae

fd4

staffNo,

480

iDate ~> carReg

HI.

fd5*
fd6*

carReg, iDate, iTime > propertyNo, comments, s t a f f N o , sName


staffNo, iDate, iTime propertyNo, comments

Property , ().
Propertylnspection
, sName
staffNo ( fd3).
, staffNo, iDate -> carReg
( fd4J
carReg staffNo.
, , iDate. ,
, ,
. ( , 13.9.1,
, staffNo,
iDate - carReg , carReg
, {carReg, iDate, iTime)
Staff Propertylnspection.)
staff Propertylnspection staffNo > sName.
staff
PropertyInspect:
Staff
Propertylnspect

(staffNo, sNarae)
(propertyNo, iDate, iTime, comments, staffNo, carReg)

staff Propertylnspect , , , , . ,
Staff Propertylnspection, . 13,8, :
Property
{propertyNo, pAddress)
Staff
( s t a f f N o , sName)
Propertylnspect (p_rop_e_rtyNo, iDate, iTime, comments, staffNo, carReg}
- ()

Property, Staff Propertylnspect


-. ,
,
. ,

, .
Property, Staff Propertylnspect
.

13.

481

Property
fd2

propertyNo - pAddress

staff
fd3

s t a f f N o - Name

Propertyinspection
fdl*

propertyNo, iDate > iTime, comments, s t a f f N o , carReg

fd4

s t a f f N o , iDate - carReg

fd5*

carReg, iDate, iTime > propertyNo, comments, s t a f f N o

fd6*

s t a f f N o , iDate, iTime > propertyNo, comments

, Property Staff
, . ,
, Property-Inspect, {staffNo, iDate), ( fd4). Propertylnspect
. , , ' SG14 ' 22
2000 (' 22-- '},
.
, .
Propertylnspect
, ,
StaffCar Inspection. :
StaffCar
Inspection

(staffNo, iDate, carReg)


(pygpertyNo, iDate, iTime, comments, s t a f f N o )

StaffCar Inspection , .
. 13.21
StaffPropertyinspection ( ) , . 13.9. Staf f Propertylnspect ion carReg,
iDate, iTime * propertyNo, pAddress, comments, staffNo, sName ( fd5*), . ,
staffNo, iDate > carReg ( fd4),
Propertyinspection .
, ,
:
Property
(propertyNo, pAddress)
Staff
(staffNo, sNaraei
Inspection (propertyNo, iDate, iTime, comments, s t a f f N o )
StaffCar
( s t a f f N o , iDate, carReg)

482

III.

Staff Propertylnspection

Propertylnspection

Propertylnspect

Staff

StaffCar

Inspection

Property

. 13.9. StaffProperty Inspect ion


S t a f f Propertylnspection, . 13.21,

Property, S t a f f , Inspection StaffCar / . , s t a f f N o
Staff, Inspection .
Staff
Inspection ,
.

13.11. (4)
, , .
(Multi-Valued Dependency MVD), , [109].
(4).

13.11.1.
1,
. ,

. .
. 13.22 BranchStaffOwner, (sName) (oName)
(branchNo). , (sName)
, (oName) .

13.

483

13.22. BranchStaffOwner
branchNo

sManie

oName

Ann Beech

Carol Farrel

David Ford

Carol Farrel

Ann Beech

Tina Murphy

David Ford

Tina Murphy
1

' 1
'Ann Beech' 'David Ford . , 'Carol Farrel' 'Tina Murphy'.
,
,
. BranchStaffOwner . , ,
1:*.
: . (, , ),
. ^ .
,
:
->
-

, , BranchStaffOwner, . 13.22, ;
branchNo > sName
branchNo > oName
. , > R ,
= R. , , . ()
, .
. 13.22
BranchStaffOwner ,

.
,

BranchStaffOwner , ,
, sName
oName. , 484

III.

, , , . ,
.
BranchStaffOwner ,
- , . ,
, , BranchStaf fOwner.

13.11.2.
(4) -, * .
(4)
-, 4 [109].
4 .
, BranchStaf fOwner (. . 13.22)
4, .
BranchStaf f BranchOwner, . 13.23
13.24. 4,
BranchStaff branchNo - sName,
BranchOwner branchNo - oName. ,
4 , . , , BranchOvmer.
13.23. BranchStaff 4
branchNo

sName

Ann Beech

David Ford

13.24. BranchOwner 4
branchNo

oName

Carol Parrel
Tina Murphy

[93], [106] [154].

13.

485

13.12. (5)

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

13.12.1.
. ,
.

. ,
, .
( ), ,
. , BranchStaff BranchOwner (. . 13,23 13.24), BranchStaffOwner (. . 13.22),
. ,
BranchStaf fOwner BranchStaff BranchOwner. ,
, [3]. (5).

13.12.2. (5)
(5). .
(5), , (Project-Join Normal Form PJNF), ,
[].

. 13.10

Property! temSupplieir.
(propertyNo),
(ItemDescription), (supplierNo)
(propertyNo). , - () (i), (s) (i), (s) , ,
(), ()
486

III.

(i) (). , (ItemDescription) .


,
PropertyltemSupplier (. 13.10, ), .

PG4
'Bed'()
( 1),
PG4 S2
( 2 ) 1,
S2 'Bed
( 3 ) ,
1
S2 'Bed
PG4

, PropertyltemSupplier. , (PG4, Bed, S2) PropertyltemSupplier (. 13.10, ).


, (Join Dependency JD).
. . , R - :|
- R, , , .... ; Z, R - *
, R - ;
, , ..., 2. ,
, PropertyltemSupplier
(5);

PropertyltemSupplier 5, Propertyltem (Ri),


ItemSupplier (R2) PropertySupplier (R3), . 13.25-13.27.
, PropertyltemSupplier
(, , ) JD (R1(A, ) , R2 (, ) ,
R3(A, ) .
13.25. Propertyltem
propertyNo

ItemDescription

PG4

Bed

PG4

Chair

PG16

Bed

'

13.26. ItemSupplier 5
ItemDescription

supplierNo

Bed

Chair
Bed

13.

487

13.27. PropertySupplier 5
propertyNo

supplierNo

PG4

SI

PG4

S2

PG16

, ,
PropertyltemSupplier
.
[93], [106] [154].
) PropertyItemSupplier
( )
propertyNo Item Description upplierNo

PG4
PG4
PG16

Bed
Chair
Bed

S1
S2
S2

) PropertyltemSuppller
( )
propertyNo itemDescrlption supplierNo
PG4
PG4

PG16
PG4

Bed
Chair
Bed
Bed

81
S2
S2

32

:
,

. 13.10. : )
PropertyltemSupplier; ) PropertyltemSupplier

, . ,

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

488

III.

( ), ,
.
,
, : " " , , .
() ,
.
(1) , .
(2) ,
, ,
, .
:
, , - .
() ,
, , , .
, : > -,
( , ).
(2) , , ,
, . ,
.
() , ,
, , . ,
.
() ,
.
(4) , - . , ,
3 , .
, , .
(5) ,
. R , , . . . ,
Z ,
R , , . . ., Z.

13.

489

13.1. ?
13.2. , , .
13.3. .
13.4. , ?
13.5. , ?
13.6. .
13.7. ()

(1).
13.8. , , , . .
13.9. (1)
(2)?
13.10. , 2. .
13.11. ,
. .
13.12. 2 2 . .
13.13. - () . .
13.14. ,
4. .
13.15. ,
5. .

13.16. (Patient Medication Form)


Wetimeadows Hospital, . 13.11.
) , . 13.11.
) ,
. 13.11, (1), (), () .
) , .

490

ill.

Wellmeadows Hospital
Patient Medication Form
Patient Number:
FufI Name:

Robert MacDonold

Bed Number: 84

DrUfl
Number

Name

Description

P10034
WardJf

WardNumber:
Ward Name:

Dosage

Method of
Admin

10223

Morphine

Paia Kilter

JOmg/ml

Oral

10334

Tetracyclene

Antibiotic

Q.5mg/ml

IV

10223

Morphine

Pain Killer

JOmg/mf

Oral

QrMeyroedfc

Units per
Day
''-- 50

..

10 '
10

"

Start Date Finish Date


24/03/0}

24/04/02

24/03/01

17/04/01

25/04/02

02/05/03

. 13.11, (Patient Medication Form.) Wellmeadows Hospital

13.17. . 13.28
. ,
, . ,
, .
) . 13.28 .
, .
) . 13.28
. , , .
13.18. Instant Cover
. . 13.29 .
(National Insurance Number NIN).
) . 13.29 .
, .
) . 13.29
. , , .
13.19. . 13.30 (staffName),
(wardName), (patientName),
.
. , (staffName) , (patientName) .
" 13.

491

) , , . 13,30,
, 4.
) , . 13.30, . , .
) ,
. 13.30, 4.
13.20. , . 13.31,
(hospitalName), (itemDescription), (supplierNo)
(hospitalName). , (h)
(1), (s) (i)
()
(h), (s)
(i) (h).

(itemDescription) .
) , , . 13.31,
5.
) ,
. 13.31, 5.
13.28.
staffNo

dentistName

patNo

patName

appointment
date

appointment
time

surgery
No

S1011

Tony Smith

P100

Gillian
White

12-Sep-Ol

10.00

S15

S1011

Tony Smith

P105

Jill Bell

12-Sep-Ol

12.00

S15

S1024

Helen
Pearson

P10S

Ian

12-Sep-Ol

10.00

S10

S1024

Helen
Pearson

P108

Ian

14-Sep-Ol

14.00

S10

S1032

Robin Plevin

P105

Jill Bell

14-Sep-Ol

16.30

S15

S1032

Robin Plevin

P110

John
Walker

15-Sep-Ol

18.00

S13

MacKay
MacKay

13.29. Instant Cover


NIN

contractNo

hours

eName

hNo

hLoc

1135

C1024

16

Smith J

H25

East Kilbride

1057

C1024

24

Hocine D

H25

East Kilbride

1068

C1025

28

White

H4

Glasgow

1135

C1025

15

Smith J

H4

Glasgow

492

III.

13.30. WardStaffPatient
ward Name

staff Name

patientName

Pediatrics

Kim Jones

Claire Johnson

Pediatrics

Kim Jones

Brian White

Pediatrics

Stephen Ball

Claire Johnson

Pediatrics

Stephen Ball

Brian White

13.31. HospitalltemSupplier
hiospitalName

itemDescription

supplierNo

Western General

Antiseptic Wipes

SI

Western General

Paper Towels

S2

Yorkhill

Antiseptic Wipes

S2

Western General

Antiseptic Wipes

S2

13.

493

497
525
569
603

...

.
: ,
,

.
"-"
, ,

.


.

.

.

. .
,
-.
, 15-17 ,
, ,
. , : ,
(. 9.1). .
,
.

, .
,
( ) ,
.


14.1
, .
14.2 ,
. 14.3 ; , .
,
,
ER-, 11 12.
15 . , .
. ,
, .
16 17
. ,
,
. ,

. , , .

, . " " " " "" "",
; ""
. ,
Staff DreamHome,
10.4 .

14.1.

, , , ,
.

498

IV.

14.1.1.

. , , ,
,
: .
, , , . , , . , , , ,
,
, , ,

14.1.2. ,

: ,
.
. 4 , -
^.
, . ,
, ,
, .
. ,
: .

(, ). .
,
.
14.

499

.
, .
". , , . , '= ! .
. . , ,
, .

14.1.3.

,
.

.
.
, , .

.

, .
.
(Database Design
Language DBDL).
DBDL .
,
.

, .

14.2.

,
. .
500

IV.


1. .
2. .
3. .
4. .
5. .
6. , .
7. ( ).
8. .
9.
.
10.
.

( )
1. .
2. ,
( ).
3.
.
4. .
5. .
6. .
7. .
8. .
9. .
10. .
11. .
12. .


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

.
.
, .
.
.

14.

501

6.
7.
8.
9.
10.
11.
12.
13.

.
.
.
.
.
.
.

.
. ( ) , .
, .

( ), ER-, .
. ,
,
.
, .
,
. 2

, .

(
) ( ). ,
; ,
. , .

,
. , ,
.
, ,
,
. , , , ,
. ,
502

IV.

. , .

, 16 17.

14.3.

.

1.


' . : . . ,
:

= . . . - . "

' '

'

..

/:

/ '

, ; .
, , , ,
.
( 10.4.4} ,
DreamHome .
Branch, , Director () Manager ().
S t a f f ,
, Supervisor () Assistant
().
Staff DreamHome, ,
, ,
Branch,
. 12.8. :
;
;
;
14.

503

;
;
.
,
, .
, , .
.
1. .
2. .
3. .
4. .
5. , .
6. ( ).
7. ,
8.
.
9.
.

1.1.
. , .
, . , (. 11.1).
. (, " ",
" ", " ", " ", " ", " ").
( , )
, . , , " " " ", ""
(staff), " ", " ", " " " " " " (PropertyForRent).
,
. , Staff, ,
, , , - "", , .
.
504

IV.

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

, . . , .
,
. . 14.1
, , Staff DreamHome.
14.1. Staff
DreamHome,

Staff



DreamHome

Employee

14.

505

, 14.1

PropertyForR

ent

Property


,

. , , ,

1.2.
I . , , .
(. 11.2).
, .

. , ,
, :
Staff Manages PropertyForRent ( );
PrivateQwner' Owns PropertyForRent (
);
PropertyForRent AssociatedWith Lease (
).
, ,
, . .
,
. , Staff Manages PropertyForRent PrivateOwner
Owns PropertyForRent.
(, Staff
Assists PrivateOwner) . , ,
,
.
, ,
.
,
(. 11.2.1),
,
(. 11.2.2).
506

IV.

, ,
.

, , , . ,

, . , ,
, ( 1.8).
"-" (ER-)
, , .
"-" (ER-). ER- .

.

, UML
(Unified Modeling Language ),
.
,
, , (. 1.6). , .
.
, ,
. , , .
"" ""
, " ".
, ,
"" "" (. 11.7).
,
,
, ,
, 2.2 .
.
,
, - , 14.

507

, . , , , - .
,
, . . 14.1 ER-
Staff DreamHome.
Supervises

. 14.1. ER-,
Staff DreamHome


, . , , , . 14.2
, S t a f f DreamHome.

14.2. Staff
DreamHome,

Manages

PropertyForRent

0. .100

Supervises

Staff

0. .10

AssociatedWith

Lease

0 .*

staff

0. .1
0. .1

1. .1

PropertyForRent

508

IV.

1.3.

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

: "
?" . ,
. , ,
,
.

, , (. 11,3.1). . , address ()
, "115
Dumbarton Road, Glasgow, Gil 6YG". , .. , , street (115 Dumbarton
Road), city (Glasgow) postcode (Gil 6YG). , .
, .
, address , .
,
, , .


,
(. 11.3.2).
,
; , ,
,
. , telNo ( ) Client
, .
14.

509

, , Client. . 2.2,
,

,
, (. 11.3). :
;
, ;
, ( ).

. ,
,
, , .
,
.
, ,
. .
, , ,
, .
, 16 ( 4.2).


, ,
, . , ,
, .

,
, .
. ,
.
,
.
, , . .
510

IV.

1. , . , , Assistant Supervisor staffNo ( ), name


(), sex () DOB ( ). , Staff staffNo, name,
sex, DOB position () ( Assistant
Supervisor). , ,
, ,
. ,
,
Staff, , . ,
, 12; 1.6.
2. .
( ) ,
1.2. ,
. , , Staff PropertyForRent :
Staff
(staffNo, name, position, sex, DOB)
PropertyForRent (property-No, street, city, postcode, type, rooms,
rent, manage rName)
PropertyForRent managerName ( ,
).
Staff Manages PropertyForRent (
).
managerName PropertyForRent
Manages,

DreamHome
Staff DreamHome , . 14.3.
14.3. DreamHome

SCaff

staffNo, name (: fName, IName), position, sex, DOB

PropertyForRent

propertyNo, address (: street, city, postcode), type,


rooms, rent

PrivateOwner

ownerHo, name (: fName, IName}, address, telNo

BusinessOwner

ownerNo, bName, bType, address, telNo, contactNarae

Client

clientNo, name (; fName, IName), telNo

Preference

prefType, maxRent

Lease

leaseNo, paymentMethod, depositAmount (


PropertyForRent .rent*2), depositPaid, rentstart,
rentFinish, duration(npOH3BOflHbli*OTrentFinish - rentstart)

14.

511

DreamHome
.
. Staff DreamHome , . 14.4.
14.4. DreamHome

Views

viewDate,comment


, .
:
;
;
, ;
, , , ;
, ;
, ,
, ;
, ( ).
. 14.5 , Staff DreamHome,
14.5. Staff
DreamHome,

Staff

staffNo

name
fName


15

IName


!5



10

position
sex

512


( F)

IV.

. 14.5

Property
ForRent

DOE

property

No

1.4.
|. , !
.
,
(. 11.3). ,
. .
,
(staf fNo). ,
; , 1 3, 1 999.
sex Staff,
"" "F". "" "F".

. :
;
.
, ,
, . .

. , ,
.

14.

513

1.5. ,

. . , /] , .

( ), (. 11.3.4). ,
.
. , . .
. , , Staff
name ( ). , Dreamffome
, ,
name . , DreamHome. ,
, ,
, staff No
Staff owr.erNo PrivateOwner, , .
.
.
,
.
,
( ).
,
( ).
,
( ).
, .
, .
, ,
(. 11.4).

- ,
! .
2.2 (. 15).
.
514

IV.

DreamHome
Staff DreamHome
. 14.2. , Preference
, , Views
(viewDate comment).

(
) .

1.6.
( )
:

.
, /, .

ER-
, 12,
/, .
,
. , , . "has-a" () "is-part-of" ( )
; "",
Supervises

. 14.2. - Staff DreamHome,


" 14.

515

"". ( ) ,
"" "".
Staff DreamHome (PrivateOwner BusinessOwner)
Owner, ownerNo, address telNo.
Owner ( (Mandatory, Or}), Owner ,
.
, , Staff
( Supervisor), Supervises (). Staff Supervisor , Staff
Supervisor. . ER- Staff
DreamHome . 14.3.
, ER- , -

Supervises

{Mandatory. Or)

PrivateOwner

BusinessOwner

. 14.3. ER- S t a f f
DreamHome /

516

IV.

.
, ER- . , , ER-
.
ER. ,
"ER-" .

1.7.
^^^^^^^^|^^|^^^1^|^^^^^^^>^|^^|^

. - .:

^^^^^^^8^^88^^^^1^^^^^86^^^

:
, .
.
1. " " (1:1).
2. .
" " (1:1)
, , . , , (Client
Renter), ; ,
Client Renter.
. , , .

,
. , ,
. ER- , , . ,
, .
, . , ,
Man (), Woman () Child (),
. 14.4. , Man Child
: FatherOf ( ),
MarriedTo ( ) MotherOf ( ). , FatherOf .
.

14.

517

1. , 1:1.
2. -
, ( - ,
).

FatherOf, .
.

1.8.

. ,
, .
,
.
, ,
. .
,
. , , , . , ,
- , .
, .
1. .
2. .

,
(, ),

MarriedTo >

' 1

i
FatherOf

MotherOf

. 14.4. FatherOf

518

IV.

.
.
DreamHome, , S t a f f .
D. ,
PropertyForRent,
, ,
Staff,
Staff Manages PropertyForRent.


, ER-.
Staff (. ) . 14.5. , ,
.

, , ,
. -

. 14.5.
14.

519

,
. , , , - , , .
,
, . , ,
- , .
,

, ,
.
.
, ,
.

1.9.

.
^ .
, .
ER- ,
. - , ( , ). ,
, .
, .

'


, , ,, .

,
.

, .
, , ,
520

IV.

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

.
,
. ,
/ ,
, ,
/ .
,
.


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

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

14.

521

14.1. ?
14.2. ?
14.3.
.
14.4.
?
14.5.
?
14.6. ?
14.7. ?
14.8. , ?
14.9. / ?

?
14.10. . .
14.11. ,
, .
14.12. , ?

DreamHome
14.13.
Branch DreamHome, . ER- ,
. 12.8, .
14.14. , Branch DreamHome, , .
University Accommodation Office
14.15.
University Accommodation Office, .
14.16. . , . ,
.
EasyDrive School of Motoring
14.17.
EasyDrive School of Motoring, .
522

IV.

14.18. . , . , .
Wellmeadows Hospital
14.19. Medical
Director ( ) Charge Nurse ( ) Wellmeadows Hospital, .
14.20.
.
14.21.
. , .

14.

523


...


.

.

.

.
,
,
.


.
.


(. 14).
, ( " "). , , .
, " " , . , 13.
,
. ,
.
, . , -

( 3), , .
16 17 . .
, .

,
; , ,
. ,
Staff DreamHome. ,
,
Staff, Branch
DreamHome, . 12.8. Staff Branch .

15.1.

: , . .
. ,

.
.
1.
.
2. .

2.

. , ,
.
526

IV.

,
1, ,
ER- .
, ,
( " ").
, .
, ,
, . , . ,
.
, .
, , , .
,, , .
.
1. ,
( ).
2. .
3. .
4.
.
5. .
6. .
, Staff
DreamHome. . 15.1 , . , ,
Staff, Branch
DreamHome, . 12.8.

2.1. ,
( )
-.
, .

1
, . ,
. ,
. , .
15. 527

, .
. , 2.2
, .
.
1. " " (*:*).
2. " " (*:*).
3. .
4. .

Supervises

. 15.1. S t a f f ,

528

IV.

1. " " (*:*)


" " (*:*), (. 11.6.3). *:*
" " (1:*), .
, Client Views PropertyForRent ( ) *:*, . 15.2, .
Views ()
Viewing 1:* (Requests ( ) Takes
()). Views *:* Client
Requests Viewing ( ) PropertyForRent
Takes Viewing ( ),
. 15.2, . , Viewing (
), (Client PropertyForRent).
2. " " (*:*)
, (. 11.2.2). .
" " (1:1).
" " (1:*).
" " (*:*),

- , 1:*
"", , ,
. 1:1 1:* 2,2. *:*,
. DreamHome *:*
PropertyForRent
propertyNo {PK}

Client

Views

0 ."

clientNo {PK}

vewDate
comment

I)
PropertyForRent
propertyNo {PK}

Viewing

Takes

1..1

0..*

viewDate
comment

Client

4 Requests

0..*

1..1

clientNo {PK}

6)
. 15.2. : ) Client Views PropertyForRent
*:*; ) 1:* ("Takes Requests^ () Viewing
15. 529

, Staff Supervises Staff (


) 1:*. *:* ,
*:*, , (, 15.3, ).

, . *:* , *:* .
, Staff
*:* (. 15.3, ]. ,
*:* () Supervision ()
(. 15.3, ). . Staff
, ;
, . 15.3, .
3.
, (. 11.2.1). ;
Supervisee

0..*

Staff

0..*

Supervises
Supervisor

staffNo

a)
Staff
staffNo

Staff
staffNo

"

0..*

1/

staffNo

''
Supervision

Supervises *
!

Staff
()

Supervises >

Supervised By

0..*

0.."

1..1

Staff
()
staffNo

a)

1..1
0..*
SupervisedBy ^
1..1
-

Supervision

r)

. 15.3. ; ) Supervises
" " (*:*); ) Supervises *:*
; ,1* *:*
() Supervision SupervisedBy; ) S t a f f

530

IV.

, .
() 1:* .
, Registers ()
Branch , (. 15.4, ). ,
()
.
Registers () Registration (). : Branch .Registers Registration ( ), Staff Processes Registration (
) Client Agrees Registration (
), . 15.4, .
4.
,
(. 11.3.2). , . , Branch
, , t e INo ranch

. 15.4. : ) Registers; ) ('Registers, Processes Agrees)


() Registration

15. 531

(. 15.5, ).
Telephone telNo, , ( ), Provides
() 1:3, . 15.5, .

2.2.

.
, .

,
, , . DBDL (Database Definition Language
), . DBDL ,
.
/
. ,
.
, .

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

Provides

. 15.5. : )
Branch telNo; () telNo
Telephone ( )
telNo Prcvides 1:3

532

IV.

1.
, .
(, name) ( fName iName). Staff, . 15.1.
Staff (staffNo, fName, IName, position, sex, DOB)
staffNo
2.
, ,
, .
-

, -. , Preference (. 15.1) :
Preference (prefType, maxRent)
( )
Preference ,
States .
3. " " (1 :*}
1:* ,
"", , "" . ()
,
, .
, Staff Registers client ( ) (, . 1-5.1) 1:*,
.
staff "" ,
Client "" .

() Staff (staffNo) ()
Client. Staff Client
. 15.6.
staffNo Client, Registers 1 :*

Staff (staffNo, fName, IName, position, sex, DOB}


staffNo

Client (clientNo, fName, IName, telNo, staffNo)


clientNo
telNo
staffNo Staff (staffNo)

. 15.6. Staff Client

15. 533

, 1:* ,
. , Staff .Registers Client
dateRegister ( ), ,
,
Client
S t a f f , staf fNo.
4. " " (1:1)
, 1:1, , , , , . , ,
, (.
11.6.5). , .
1. 1:1.
2. 1:1.
3. 1:1.
. 1:1

, , , ( ) .
Client States Preference ( ) 1:1 . , Client:
Client (clientNo, fName, IName, telNo, prefType, raaxRent, staffNo)
clientNo
s t a f f N o S t a f f ( s t a f f N o )

, 1:1
,
. , States
dateStated, , Client.
, , , (, 1:*). , states
/ .
.

534

IV.

6. 1:1


1:1 . , ,
, , ,
. , , . , .
, Client States Preference 1:1
Client ( ,
),
Client ,
Preference . () Preference () Client (
clientNo), , . 15.7.
, Preference .
Preference ,
Client
Preference.
, , .
. 1:1

,
, -
,
.
, , Staff Uses Car
( ) 1:1 . ( , 1:1 ,
.)
- ,
, . ,
Staff .
, , ( ), , . 1:1
Client clientNo
Preference, States

Client (clientNo, fName, IName, telNo, staffNo)


clientNo
staffNo Staff (staffNo)

Preference (clientNo, prefType, maxRent)


clientNo
clientNo Client(clientNo)

, 15.7. 1:1

15. 535

Car, ,
S t a f f . S t a f f ,
staff (
staf fNo) .
5. " " (1:1)
1:1
, 1:1.
1:1 . 1:1 .
1:1,
, .
1:1
,
, , , . , .
,
,
.
1:1 ,
, .
6. /
/ , , ,
, , . . ,
, / (. 12.1.6), , , , /. . 15.1 /
.
, / Owner,
. 15.1. . 15.1, ;
( 15.1) , (pOwnerFlag
bOwnerFlag), ,
( 1),
( 4).
/ , . . 15.1,
Owner , Owner
(PrivateOwner BuainessOwner),
. 3, , , ()
.
536

IV.

15.1.
/

{Mandatory}

{And}

( ,
)

{Optional}

{And}

: , ( ,
)

{Mandatory}

{Or}

:
/

{Optional}

{or}

: ,

15.1. /
Owner,
, . 15.1
1 - ,
AllOwner (ownerNo, address, telNo, fName, INarae, bName, toType,
contactName, pOwnerFlag, bownerFlag)
ownerNo
_2_ - ,
Owner (ownerNo, address, telNo)
ownerNo
OwnerDeCails (ownerNo, fName IName, bName, bType, contactName,
pOwnerFlag, bOwnerFlag)
ownerNo
ownerNo Owner(ownerNo)
3 - ,
PrivateOwner (ownerNo, fName, IName, address, telNo)
ownerNo
BusinessOwner (ownerNo, bName, bType, contactName, address, telNo}
ownerNo
4 - ,__
Owner (ownerNo, address, telNo)
ownerNo
PrivateOwner (ownerNo, fName, IName}
ownerNo
ownerNo Owner(ownerNo)
BusinessOwner (ownerNo, bName, bType, contactName)
ownerNo
ownerNo Owner(ownerNo)

15. 537

, , . 15.1, , . , 1
(, ) , . , , PrivateOwner, BusinessOwner .

, , , , NULL, . , (, NULL).
. 15.1 / Staf Supervisor . Staff (Supervisor), . , " " ,
:
Staff ( s t a f f N o , fName, IName, position, sex, DOB,
supervisorStaffNo)
s t a f f N o
supervisorStaffNo Staff

(staffNo)

/ - 1:* (
. 14.2) , , .
, , 2.1. , .
7. " " (*:*)
*:* , , ,
. , , . ,
, . , ,
- . .
, . Client Views Proper tyPorRent *:*
(. 15.2, ). client PropertyForRent, Viewing,
Views. , . 15.8,
, ,
. 15.2, , *:* .

538

IV.

Client (clientNo, fName, IName, telNo,


prefType, maxRent, staffNo)
clientNo;
staffNo Staff {staffNo)

PropertyForRent (propertyNo, street, city,


postcode, type, rooms, rent)
propertyNo

Viewing (clientNo, propertyNo, dateView, comment)


clientNo, propertyNo
Client (clientNo)
PropertyForRent (propertyNo)

, 15.8. *:*

.
' , ,
, ,

, .
, "" (, 1..*,
0..*), , ,
, .
, Registers Branch , ,
(. 15.4, ).
, Branch, Staff Client, a
Registration, Registers. , . 15.9.
-, ,
, , . 15.4, ,
.
Staff (staffNo, fName, IName, position, sex, DOB, supervisorStaffNo)
staffNo
supervisorStaffNo Staff (staffNo)
Branch (branchNo, street, city, postcode)
branchNo
Client (clientNo, fName, IName, teiNo, prefType, maxRent, staffNo)
clientNo
slaffNo Staff (staffNo)

Registration (clientNo, branchNo, staffNo, dateJoined)


clientNo
branchNo Branch (branchNo)
clientNo Client (clientNo)
staffNo Staff (staffNo)
. 15.9. Registration

15. 539

9.
,
,
.
,

.
, Branch , , telNo
Branch (. . 15.5, ).
Branch
Telephone, telNo. , . 15.10.
branchNo Telephone

Branch (branchNo, street, city, postcode)


branchNo

Telephone (telNo, branchNo)


telNo
branchNo Branch {branchNo)

. 15.10. Branch Telephone


, . 15.5, . . 15.2
.
15.2.

/

, (
-
)


1:*

"" ,
"". ""


1:1:

""
, ""

540

IV.

. 15.2
/

"/"

*:*,


. . 15.1
, , .
-
, , -

2.2 DBDL , . ,
staff DreamHome,
. 15.3.
15.3. , Staff
DreamHome

Staff (staffNo, fName, INarae, position, sex, DOB, supervisorStaffNo}

staffNo
supervisorStaf fNo Staff {staffNo)
BusinessOwner (ownerNo, bName, , contactName, address, telNo)
ownerNo

bName
telNo
PropertyForRent (propertyNo, street, city, postcode, type, rooms, rent,
ownerNo, staffNo)

propertyNo
ownerNo PrivateOwner (ownerNo)
BusinessQwner(ownerNo)
staff NO staff (staffNo)
Lease (leaseNo, paymentMethod, depositPaid, rentStart, rentFinish,
clientNo, propertyNo)
leaseNo

propertyNo, rentstart
clientNo, rentStart

clientHo client (clientNo)


propertyNo PropertyForRent (propertyNo}
deposit (PropertyForRent .rent*2}
duration (rentFinish - rentstart)

15. 541

. 15.3

PrivateOwner (ownerNo, fName, IName, address, telNo)


ownerNo

Cllent (clientNo, fName, IName, telNo, prefType, maxRent, staffNo)


clientNo
staffNo :staf f (staffNO)
Viewing (clientNo, propertyNo, dateView, comment)
clientNo, propertyNo

clientNo HEI client (clientNo)


propertyNo PropertyForRent (propertyNo}

,
/ . ,
( ). ,
Viewing ,
PropertyForRent ( propertyNo)
Client ( clientNo).
,
, DBDL ( 2.5). ,
, . ,
Lease ,
(propertyNo, rents tart) (clientNo, rentStart).

2,3.
-". , .
13.
, ,
. ,
6' , ,
.
, 2.2.
, . ,
. .

542

IV.

. .
.

, .
,
.
. , ,
. 17 ( 8).
, 13.
,

, .
, .
.
,
.
,
.
. ,
. :
(1),
;
(2),
;
(),
;
- (), .
, , , , , . , , ,

. -'
, .
15. 543

2.4.

. ., , =
.

, , .
. 1.8 (. 14) ,

. ,
,
; , .
, /
, , ER- .
,
. -
, , , .
, , , , , .

2.5.
. , - ,
,'; .

.
, , . ,
, . , .
,

. .
.
.
.

544

IV.

.
.

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

,
. , sex
"" "F",
, .
,
( 1.4, 14).

. , staff ; staffNo.
( 1.5, 14).


,
. ,
, . ,
Staff Manages PropertyForRent. staffNo
PropertyForRent
S t a f f , , . staffNo
NULL, ,
s t a f f N o s t a f f , .
, . , , . ,
,
(..
staffNo)? ,
, ,
, .
, , . , ,
.
15. 545

.
, , , .
, , Staf E Manages PropertyForRent 1:*.
1. (PropertyForRent}
,
staffNo PropertyForRent
, Staff.
2. (PropertyForRent)

.
3.
(PropertyForRent)
1. , staffNo
PropertyForRent ,
, Staff.
4. (Staff)
( s t a f f ) . , . ,
.
5. (Staff)
,
, .
, , , , . .
NO ACTION. ,
. : " , ".
CASCADE.
. , , .. , . ,

. : " 546

IV.

, ". ,
.

, CASCADE (. 12.3).
SET NULL.
. ,

.
: " , , , , ". ,
.
SET DEFAULT.
, . ,

,
. : "
, , (, )".
,
,
.
NO CHECK. .
6. (Staff)

,
, , . , ,
,
.
.
CASCADE , ( )., , , ,
, ..
, CASCADE.
, Staff DreamHome, 15.2.

15. 547

15.2. ,
Staff
DreamHome
Staff {staffNo, fName, IName, position, sex, DOB, supervisorStaffNo)
staffNo
SupervisorStafJ:No Staff{staffNo) ON
UPDATE CASCADE ON DELETE SE7 NULL
Client {clientNo, fName, IName, telNo, prefType, maxRent, staffNo)
clientNo
staffNo Staff{staffNo} ON UPDATE CASCADE
ON DELETE NO ACTION
PropertyForRent {propertyNo, street, city, postcode, type, rooms,
rent, ownerNo, staffNo}
propertyNo
ownerNo PrivateOwner(ownerNo)
BusinessOwner(ownerNo) ON UPDATE CASCADE ON DELETE NO ACTION
staffNo Staff(staffNo) ON UPDATE CASCADE
ON DELETE SET NULL
Viewing (clientNo, propertyMo, dateView, comment)
clientNo, propertyNo
clientNo Client(clientNo) ON UPDATE
CASCADE ON DELETE NO ACTION
propertyNo PropertyForRent(propertyNo) ON
UPDATE CASCADE ON DELETE CASCADE
Lease (leaseNo, paymentMethod, depositPaid, rentStart, rentFinish,
clientNo, propertyNo)
leaseNo
propertyNo, rentStart
clientNo, rentStart
clientNo Client(clientNo) ON UPDATE
CASCADE ON DELETE NO ACTION
propertyNo PropertyForRent(propertyNo) ON
UPDATE CASCADE ON DELETE NC ACTION


, ( -). ,
,
, . DreamHome
, : .

.
.

548

IV.

2.6.

. , | ,;
| .
~~" : - -

'

--

- .

'"'-..

\"

\;,

, ,
.
, .
,

, . , , , .
, , , .


. (Data Flow Diagram DFD) . , , , ,
, .
(
) , . ,
, .
, ..
.

.

3.

. :
, \
: .

"-

-: 15. 549


,
,
.
, ,
.
, 2.3
2.4. ,
. ,
, ,
. .
,
, . , , , . ,
. ,
, .
.
1. .
2. .
3. .
4. .

, Staff
DreamHome, , 11 12
Branch DreamHome. . 15.4 , Branch (. 12.8) ER-.

(. 15.10).
15.4. , Branch
DreamHome

Branch {branchNo, street, city, postcode, ragrStaffNo)


branchNo
postcode
mgrstaf f No Manager ( s t a f f No)
Staff

( s t a f f N o , name, position,

salary,

supervisorStaffNo,'branchNo)

s t a f f N o
supervisorStaf fNo S t a f f ( s t a f f N o )
branchNo Branch(branchNo)

550

IV.

. 15.4

PrivateOwner (ownerNo, name, address, telNo)

ownerNo
PropertyForRent {propertyNo, street, city, postcode, type, rooms, rent,
ownerNo, staffNo, bName, branchKo)

propertyNo
ownerNo PrivateOwner (ownerNo)

bName BusinessOwner (bName)


staff No staff (staffNo)
branchNo Branch (branchNo)
Lease (leaseNo, paymentMethod, depositPaid, rentStart, rentFinish,
clientNo, propertyNo}

leaseNo
propertyNo, rentStart
clientNo, rentStart
clientNo Client (clientNo)
propertyNo PropertyForRent (propertyNo)
deposit (PropertyForRent .rent*2)

duration (rentFinish - rentStart)


Advert (propertyNo, newspaperName, dateAdvert, cost)
propertyNo, newspaperName, dateAdvert
propertyNo PropertyForRent (propertyNo}
newspaperName Newspaper (newspaperName)
Telephone (telNo, branchNo)

telNo
branchNo Branch (branchNo)
Manager (staffNo, mgrStartDate, bonus)

staffNo
staff No staff {staffNo)
BusinessOwner (bName, bType, contactName, address, telNo)

bName
telNo
Client (clientNo, name, telNo, prefType, maxRent)

clientNo
Registration (clientNo, branchNo, staffNo, dateJoined)
clientNo

clientNo client {clientNo)


branchNo Branch (branchNo)
staffNo Staff (staf fNc)
Newspaper (newspaperName, address, telNo, contactName)
newspaperName

telNo

15. 551

3.1.

. /
^ .

, . . , - ' - . "

.->--:

ER-, , , .
, .
, - , .
.
,
.
[22], [32], [36] [289].
.
1. /
.
2. / .
3. /, .

4. ( ) /,
.
5. / .
6. ( ) / ,
.
7. , / / .
8. .
9. .
10. ER-/ .
11. ,

"/" "/ ". , ER- , ER-, ,
. , ,
, ER-, , . , "
" ,
.

552

IV.

,
..
,
. ,
.
1 . /

, ;
. :
/ ,
( );
/ ,
( ).

/. , / , , .
. 15.5 , Branch Staff DreamHome. , , .
1 5.5. /,
Branch Staff
Branch

Staff

Branch

branchNo
postcode

Telephone

telNo

Staff

staff Ho

Staff

staffNo

Manager

staffNo
ownerNo

PrivateOwner

ownerNo

PrivabeOwner

BusinessOwner

bWame

BusinessOwner

telNo
ownerNo
Client

clientNo

PropertyForRent

properbyNo

Lease

leaseHo
propertyNo,

Client

clientNo

PropertyForRent

properCyNo

Viewing

clientNo,
propertyNo

Lease

leaseHo

rent Start

clientNo, rents tart

clientNo,
rentstart

15. 553

. 15.5
Branch

Staff

Registration

clientNo

Newspaper

newpaperName

telNo
Advert

{propertyNo,
newspaperName,
dateAdvert)

2. /
/. ,
. 15.6 Branch
Staff DreamHome. ,
, . , ,
, ,
Staff PropertyForRent (branchNo).
15.6. Branch Staff
Branch

Staff

Branch

rngrStaf fNo
Manager ( staff Mo)

Manages

Telephone

branchNo
Branch (branchNo)

Staff

supervisors taiif No
-* Staff (staffNo)

Supervises

branchNo -^
Branch(branchNo)

Has

staffNo -*
Staff(staffNo;

Manager

s up e ryi_is S
taffNo -
Staff (staff
No)

Supervise ji

staffNo ^
Staf f {staff
No)

Registers

L)

PrivateOwner
BusinessOwner
Client

PropertyFor
Rent

554

owner
No

PrivateOwner (owner
Ho)

Owns

ownerNo >
PrivateOwne
r (ownerMo)

POwne

ownerNo

BusinessOwner (owne
rNo)

Owns

ownerNo >
BusineasOwn
er (ownerNo}

BOwns

IV.

. 15.6
Branch

Staff

staffMo ->
Staff(staffNo)

Oversees

staffHo ->
Staff (staff
No)

Manages

branchNo >
Branch(branchNo)

Offers
clientNo ->
Client(clie
ntNo)

Requests

propertyNo
->
PropertyFor
Rent(proper
tyNo)

Takes

Viewing

Lease

Registration

clientNo >
Client(clientNo)

Holds

clientNo ->
Client(clie
ntNo)

Holds

propertygo *
PropertyForRent(pr
opertyNo)

LeasedBy

prgpertyWo
=
PropertyFor
Rent(proper
tyNo}

Associated
With

clientNo
Client(clientNo)

(2)

branchNo >
Branch(branchNo)

(2)

staffNo -
Staff(staffNo)
Newspaper
Advert

propertyNo >
PropertyForRent(pr
opertyNo)

(3)

newspaperNarae
Newspaper(newspape
rName)

(3)

.
fl>

Telephone telNo.
' Registration Registers.
(3
' Advert Advertises " " (*:*).
(2

/ , .
, ,
. / / ,

15. 555

, , .
, ,
, , ( ).
Staff Manages PropertyForRent (
Staff) Manager Manages Branci ( Branch). , Manages (
Manages "", "").
, , , "
" . (, ,
), ,
. ,
. , Branch managerName ,
Manager .
3. /,
/ ,
, ,
/ " "
. , : :
/
;
/ ,
;
/
.
/

, / " " . / / . ,
. 15.11 , PrivateOwner, Branch S t a f f .
ownerNo. ,
, PrivateOwner ,
PrivateOwner. ,
, ,
.
( ) , , . , , fName IName.

556

IV.

Branch

Staff

PrivateOwner (ownerNo, name, address, telNo}


ownerNo

PrivateOwner (ownerNo, fName, (Name, address, telNo)


ownerNo


PrivateOwner (ownerNo, fName, IName, address, telNo]
ownerNo
. 15.11. PrivateOwner Branch Staff

, . 15.2, S t a f f , client,
PropertyForRent Lease , .
/ ,

/ ,
. /
, . ,
. , . 15.12
, BusinessOwner, . BusinessOwner
Branch bName,
BusinessOwner Staff ownerNo.
BusinessOwner Staff bName. ,
, BusinessOwner Branch
BusinessOwner Staff. , . 15.12, bName .
/

/,
, , -, .
/ :
, ;
;
, .
, , staff ( ) Employee (),
.

15. 557

Branch

Staff

BuslnessOwner(bName, , contactName,
address, telNo)
bName
telNo

BusinessOwner(ownerNo, bName, bType,


contactName, address, telNo)

bName
telNo


BusinessOwner {ownerNo, bName, bType, contactName, address, telNo}
ownerNo
bName
telNo

. 15.12, BusinessOwner

4. ( ) /,

,
.
- . . 15.2, Branch, Telephone, Manager, Registration, Newspaper Advert Branch , Viewing S t a f f .
5. /
/
. / ,
. :
/ ;
/ , .
, . 15.5 ,
, . 15.7 .
, Registers
: Staff
.Registers ,
, Branch ,
, , , , , Registration.
Registers Staff
/
Branch.

558

IV.

15.7.

staff

supervisorStaf fNo SCaf f {staff No)

(Supervises)

Property
ForRent

ownerNo~PrivateOwner (ownerNo)
EusinessOwner (ownerNo)

(POwns/Bowns)

staf fNo-*Staf f (staf fNo)

(Oversees/Manages)

clientNo-Client (clientNo)

(Holds)

propertyNoPropertyForRent (propertyNo)

(LeasedBy/Associa
tedWith)

Lease

6. ( ) / ,

,
/ ( /
/, ).
/ . . 15.6, / ,
. 15.8.
15.8. / ,

Branch

mgrStaffNo * Manager (staf fNo)

(Manages)

Telephone

branchNo * Branch (branchNo)

Staff

branchNo Branch (branchNo]

(Has)

Manager

staf fNo -> Staff (staf fNo)

PropertyForRent

branchNo Branch (branchNo)

(Offers)

Viewing

clientNo Client (clientNo)

(Requests)

propertyNo * PropertyForRent (propert vNo)

(Takes)

Registration

clientNo - Client(clientNo)
branchNo - Branch(branchNo}
staffNo - Staff(staffNo)

Advert

propertyNo > PropertyForRent(propertyNo)


newspaperName > Newspaper(newspaperName)

7. , / /

, / / , .
, ,
15. 559

, .
: *:,
( , ). / /
. , , /
, / .
8.
/ /
, . , ' , . , DreamHome,
. 15.9.
1 S.9. ,
DreamHome

Branch {branchNo, street, city, postcode, mgrStaffNo}


branchNo
postcode
mgrStaf fNo Manager (staf fNo)
Staff ( s t a f f N o , fName, IName, position, sex, DOB, salary,
supervisorStaffNo, branchNo}
s t a f f N o
supervisorStaf fNo staff (staf fNo}
branchNo Branch (branchNo}
PrivateOwner (ownerNo, fName, IName, address, telNo]
ownerNo
PropertyForRent {propertyNo, street, city, postcode, type, rooms, rent,
ownerNo, s t a f f N o , branchNo}
propertyNo
ownerNo PrivateOwner (ownerNo}
BusinessOwner{ownerNo}
s t a f f N o s t a f f ( s t a f f N o )
branchNo Branch (branchNo)
Client (clientNo, fName, lNam=, telNo, prefType, maxRent)
clientNo
Lease (leaseNo, paymentMethod, depositPaid, rentStart, rentFinish,
clientNo, propertyNo)
leaseNo
propertyNo, rentstart
clientNo, rentstart
560

IV.

. 15.9

clientNo client (clientNo)


propertyNo PropertyForRent (propertyNo)
deposit

(PropertyForRent .rent*2)

duration (rentFinish - rentstart)


Advert (propertyNo, newspaperName, dateAdvert, cost)
propertyNo, newspaperName, dateAdvert
propertyNo PropertyForRent (propertyNo)
newspaperName Newspaper (newspaperName)
Telephone (telNo, branchNo)
telNo
branchNo Branch (branchNo)
Manager ( s t a f f N o , mgrStartDate, bonus)
s t a f f N o
s t a f f N o s t a f f ( s t a f f N o )
BusinessOwner (ownerNo, bName, bType, contactName, address, telNo)
ownerNo
bName
telNo
Viewing (clientNo, propertyNo, dateView, comment)
clientNo, propertyNo
clientNo client {clientNo)
propertyNo PropertyForRent {propertyNo)
Registration ( c l i e n t N o , branchNo, s t a f f N o , dateJoined)
clientNo
clientNo client (clientNo)
branchNo Branch (branchNo)

staf fNo s t a f f ( s t a f f N o )
Newspaper (newspaperName, address, telNo, contactName)
newspaperName
telNo

9.
,
, . - , ,
. .
10. ER-/
, . ,
15. 561

, , .
ER-, ER-.
DreamHome . 15.13.

ientNo (, FK)
branchNo {FK}
s:affNo{FK}

properlyNo {PK)
ownerNo {FK}
staffNo {FK}
branchNo {FK}

propertyNo {PK, FK}


newspaperName {PK. FK)
dateAdvert {PK}

A
Displays

Newspaper
newspaperName {PK}

. 15.13. DreamHome

562

IV.

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

3.2.
| . , Mo- -
[: , ;;
^, .
2.3 2.4,
.
,
, . , .

3.3.
. , - - i
|; , s
1; ,
,
.
, ,
.
,
,
. ,
, , .
, . .
, .
.

15. 563

3.4.

. , ,

.
, ,
; .
,
.

: , .
,
,
.
ER-,
( ), .
, i ( 2);
( 3).

. , . 1:* , "",
"". *:*
, , .

, . ,
, . , ,
, . , , .
564

IV.

,

. : , , ,
.
, ,
, .
,
, , /: NO ACTION, CASCADE, SET NULL, SET DEFAULT NO CHECK.
-.
, "" ,
.

,
, ,
.
.
: /
; / ;
/, ; ( ) /, ; / ,
; ( ) / , ; ,
/ / .

15.1. ?
15.2. , , , . .
15.3. , :
) ;
) ;
) " " (1:1);
) " " (1:1);

) /;
) " " (*:*);
) ;
) .
.
15. 565

15.4. ,
, .
15.5. , , ?
15.6.
.
15.7. ,
, , ?
15.8. , .

15.9. , . 15.14.

, 15.14,

DreamHome
15. Branch
DreamHome ,
14.13, , . 15.4. .

566

IV.

University Accommodation Office


15.11.

University Accommodation Office, 14.16.
EasyDrive School of Motoring
15.12. EasyDrive
School of Motoringt 14.18.
Welfmeadows Hospital
15.13.

Wellmeadows Hospital, 14.21.
15.14.
Wellmeadows Hospital. , .
15.15. Wellmeadows Hospital.

15. 567


...

.

.
.
.

.

.
.
.

.

.
,
-
(. 14, 15). 1
2, . (. 13) .
3
, , , . , 3 ,
.
,
, (..
, , ) -

, .
, . ,
, ,
' . , : .

16.1
. 16.2 ,
. 16.3 ,
.
, ,
, . .
.
17 . , , , ,
, . ,
.

16.1.


: , .
, ,
.
.
,
. , ER , ,
, , ,
.

570

IV.

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

16.2.

{" .
I ; " , , , ; - ,
:;; .
.
1. .
2. .
3. .
4. .
5. .
6. .
7. .
8. .
9. .
10. .
11. .
12. .
13. .

.
, 16.

571

4-9. 4
,
, .
5 . , ,
.
. ,
. (.
2.1.5).
(. . 2.1).
. ,
.

. 5 ,
, .
6 ,
. 7 , , .
8
, . , . 9
,
, , .

, , .

16.3.


. ,
572

IV.

. , , . (8 9) .

4.

.
|;, , ;:
$ .

, , ,
. , .
.
, . , :
;
, ;
(..
, NULL);
;
;
.
4 .
1. .
2. .
3. .

4.1.
';:''

. '

"

...--..

" ; ' ;-

- ..; >

'.",.',-.:

|. , .

, ,
. ,
DBDL. :
;
, ;
16.

573

( ) () (FK) ;
;
.

;
, ,

;
();
NULL .
DBDL, ,
NULL.
16.1 PropertyForRent
DreamHome,
16.1. PropertyForRent DBDL
Domain
Domain
Domain
Domain
Domain

PropertyNumber:
Street:
City:
Postcode:
PropertyType:

variable length character


variable length character
variable length character
variable length character
single character, must be
'D1,

'E',

'F1 ,

'H1,

'M',

string,
string,
string,
string,
one of

length 5
length 25
length 15
length 8
' ' , ',

'S'

Domain PropertyRooms:
integer, in the range 1-15
Domain PropertyRent:
monetary value, in the range 0.00-9999.99
Domain OwnerNumber:
variable length character string, length 5
Domain StaffNumber:
variable length character string, length 5
Domain BranchNuraber:
fixed length character string, length 4
PropertyForRent(
propertyNo PropertyNumber NOT NULL,
street
Street
NOT NULL,
city
City
NOT NULL,
postcode
Postcode,
type
PropertyType
NOT NULL DEFAULT 'P',
rooms
PropertyRooms
NOT NULL DEFAULT 4,
rent
PropertyRent
NOT NULL DEFAULT 600,
ownerNo
OwnerNumber
NOT NULL,
staffNo
StafrNumber,
branchNo
BranchNumber
NOT NULL,
PRIMARY KEY (propertyNo),
FOREIGN KEY (staffNo) REFERENCES Staff(staffNo) ON UPDATE CASCADE
ON DELETE SET NULL,
FOREIGN KEY {ownerNo) REFERENCES PrivateOwner(ownerNo) and
BusinessOwner(ownerNo) ON UPDATE CASCADE ON DELETE NO ACTION,
FOREIGN KEY (branchNo) REFERENCES Branch{branchNo) ON UPDATE
CASCADE ON DELETE NO ACTION);

574

IV.


.
,
. : ISO SQL ( 6.1),
Microsoft Access ( 8.1.3) Oracle ( 8.2.3).


,
. , , , .

4.2.
.'

1.
, .
, ,
. ,
:
, ;
;
, .
,
. ,
, ,
(/), 11.1.2.
, .
, , . :

, ;
, .
.
staff ,
, . . 16.1
PropertyForRent, . 16.2 Staff noOfProperties, DreamHome, . 3.3-3.9.

16.

575

16.1. PropertyForRent
proper

rooms rent

owner staff
No
No

branch
No

House

650

C046

SA9

B007

lal
i at

400

C087

SL41

BOOB

350

C040

Flat

375

C093

SG37

B003

postcode type

street

city

PA14

16 Holhead

Aberdeen AB7 5SU

PL94

6 Argyll St

London

PG4

6 Lawrence St Glasgow

PG36

2 Manor Rd

tyNo

Glasgow

NW2
Gil
9QX

G32

BOOS

4QX
PG21

18 Dale Rd

Glasgow

G12

House

600

C087

SG37

B003

PG16

SNovarDr

Glasgow

G129AX

Flat

450

C093

SG14

BOOS

16.2. Staff
noOfProperties
staffNo

fName

IName

branch No

noOfProperties

SL21

John

White

BOOS

SG37

Ann

Beech

BOOS

SG14

David

Ford

BOOS

SA9

Mary

Howe

B007

SG5

Susan

Brand

BOOS

SL41

Julie

Lee

BOOS


. ,
- ; . noOfProperties 1. ,
, .
. , Staff,
, .
Staff PropertyForRent. ,
.
,
, .
1
, ,
,
. ,
SQL , , 5.

576

IV.


. ,
, , .

4.3.
. .
, , . -
, , . , SQL, . , DreamHome ,
.
CREATE TABLE SQL
PropertyForRent :
CONSTRAINT StaffNotHandlingTooMuch
CHECK

(NOT EXIST

{SELECT s t a f f N o
FROM PropertyForRent
GROUP BY s t a f f N o
HAVING C O U N T t * ) > 1 0 0 ) }

8.1.4
Microsoft Access VBA
(Visual Basic for Applications). , 8.2.7.

. ,
( )
, " 17:30 , , ".

, , .
,
.

16.

577

5.

.. , ,
; , -*
.
(. ). , .
.
, . ,
, .
. ,
.
. , ,
, ,
, .
. , .
.
. ,
. , .
, .
( 9).

(Data
Base
Administrator DBA) , . ,
, ,
. , , , , .
-
,
. ,

578

IV.

, ,
. , ,
. , ,
, .
,
. 20.


, ,
.
. ( ) ,
. , , . ,
, 5% .
10%,
. , ,
. , .
, .
,
, .
( ) ,
.
. .
, . ,
.

.
-.
-. ,
- .
, .

. , . . 16.1 16. 579


.

.

.

(. 19.3.3).
. .
.
, :

, , ;
-.
, , .
1. .
2. .
3. .
4. .

5.1.
. ,
^ , ,.

,
, . , . :
,
;
, ;
/,
( ).

. 16.1.

580

IV.

, . , , , , ,
, . .
, ""
( ,
). , 20% 80%
[325]. "80/20"
. , , , , , , ,
. ,
, .
.
,
.
, .

1.8, 2.4 3.2 / , , ; /.
, . 14.5,
,
. , - ,
. ,
. , . 16.3
, / DreamHome (. ).

(A)


(, PG4, Tina Murphy)

Staff

(B)

(C)

16.

581

(D)

, , ,
,

Branch

(E)

,
,

(F)

16.3.
/

()
I

()
R U D

()

R U D I

Branch

()

()

R U D I
X

R U D I

(F)
R U D I

R U D
X

Telephone
Staff

Manager
PrivateOwner

BusinessOwner

PropertyFor
Rent

X X X

Viewing
Client
Registration
Lease
Newspaper
Advert

. I ; R (); U ; D ,
, , ()
Staff,
PropertyForRent PrivateOwner/BusinessOwner. , (, , ).
,
. ,
Staff PropertyForRent ,
, . , , .

582

IV.


DreamHome,
10.4.4, , 100000 , 100 2000 , 1000 3000 . . 16.2 (),
(D), () (F), Staff
PropertyForRent, . PropertyForRent , .
, ,
, .

, ,
, , . ,
, 14:00 16:00
, , .
, 17:0019:00 ,
.
, . , ,
, , , .
,
, ,
, 8 .
,
(,

, , ).

avg = 50
max = 1 00

avg= 1000
max = 3000

. 16.2.

16. 583



. .
, , ; ,
, , ( ).
, , (
).
, ( SQL , WHERE).
, :
, name LIKE ' %Smith% ';
, salary BETWEEN 10000 AND 20000;
, salary = 30000.
,
,
, .
, .
, ,
.
1
.
; , , 50 .
; ,
, 1 .
, , .
. 16.3 (D). , 50
, , 100 ,
17:00 19:00. , ,
, .
SQL
.
SQL, :
;
, (
);
584

IV.

, ( );
, ( );
, ( AVG SUM);
, .
, . , :
( );
,
;
,
.
,

. , , , ,
.

5.2.
. ; .

. ,

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

, .

,
.
, . ,
.
.
.
16.

585

- (ISAM Indexed Sequential Access


Method).
(+-).
.
, .
()
.
.
1. . ,
. , .
2. .
, .
3. ( ). .
4. ,
.
.
, .

. , , ,
. , PropertyForRent propertyNo,
" propertyNo PG36" .
.
1. . ,
, (propertyNo)
PG.
2. , . ,
300 500 .
3. ,
. ,
586

IV.

Staff no staffNo,
IName.
IName (. 5.3).
4. . , PropertyForRent
rooms rent, rooms.

.
5. .
(
- ).
.
-
- (ISAM)
5.2 . ISAM . , ,
.
ISAM
. ISAM
.
ISAM,
.
, . , ISAM , .

t
, (+-), 5.5 .

. ,
, .
,
. , ISAM,
. +- , . , ISAM, .
, - . , ISAM , ( - , ).

16.

587


, Oracle,
(. 6 ).
, , .
. ,
.
. ,
Oracle, .
, , . . .
,
( ). Oracle :
.
.


. Oracle
:

;
.
, ,
, .
, .
,
.
(
, Oracle .)
, . (
. Oracle ,
,
.)
, " " (1:*), , . (
() , , , ^ , ,
-.)
588

IV.

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


, .
- .
. Oracle
:
,
(,
" ");
,
, .

, .

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

, ,
.
,

. ( ,
, ,
. 16.

589


, .)
, .
, ,
, , ,
.


. . , , ( ).

5.3.
. . , .

, . (. 5 ). , ,
:
, ,
;
,
.
, ,
, , , , , . , , .
6.3.4, SQL;
CREATE INDEX. , PropertyForRent propertyNo
SQL:
CREATE UNIQUE INDEX PropertyNoInd ON PropertyForRent(propertyNo);

PropertyForRent
' staff No SQL:
CREATE INDEX StaffNoInd ON PropertyForRent(staffNo)

CLUSTER;

,
. , Oracle 590

IV.

, , ,
. , ,
INGRES, ,
CREATE INDEX:
[STRUCTURE = BTREE

ISAM

HASH

HEAP]


, . , PropertyForRent
(propertyNo), . , rent.
rent .
, ,
, . , ,
.

.

.

.
,
.

, ,
.
.
1. .
, , .
2. , ,
.
SQL , (. 6.2.3), , .
3. ,
. , , 16.

591

PropertyForRent PrivateOwner/BusinessOwner ownerNo ( ). PropertyForRent, ownerNo. ,


.
4. , (,
PropertyForRent rent,
, ).
5. ,
:
;
ORDER BY;

GROUP BY;
, ( UNION DISTINCT).
6. , , , . ,
,
SQL:
SELECT branchNo, A V G ( s a l a r y )
FROM Staff
GROUP BY branchNo;

,
branchNo,
GROUP BY.
branchNo, salary. , .
, , , .
7. , ,
,
, .
8. , .
9. , (, 25%)
. , .
10. , .

OR,
,
,
. , ,
592

IV.

type rent PropertyForRent


:
SELECT *
FROM PropertyForRent
WHERE (type = ' F l a t ' OR rent > 500 OR rooms > 5 } ;

(type =
'Flat 1 or rent> 500), , rooms , ,
WHERE . type rent
( , ),
, WHERE AND, type rent .


.
, . , . ,
(staffNo) staffNo ,
.
,
,
. , , , .
, ,
, .
,
;
(Query Execution Plan QEP). ,
Microsoft Access Performance Analyzer, Oracle
EXPLAIN PLAN (. 20.6.3), DB2 EXPLAIN, INGRES . , ,

, .

, , , . ,
10%, .

16. 593


, .

. ,
, , .


, . , , .
DreamHome,
Microsoft Access
( ) , Microsoft Access ,
, 5.2 . , , Microsoft Access .
Access, .

Access ,
Memo, Hyperlink OLE Object . , Microsoft , :
Text, Number, Currency Date/Time;
, , ;
, ;
, .
, , ,
.
, Microsoft :
, Access
, ;
,
, GROUP BY ,
, , .
Microsoft Access ( Access ). Microsoft Access Rushmore, .
AND OR, , :
594

IV.

branchNo = 'B001' AND rooms > 5


type ' F l a t 1 OR rent > 300
Access
, ,
, ,
. Rushmore, :
AND OR;
;
; , .
DreamHome
, ,
.
DreamHome
Branch, Telephone, Manager Newspaper.
, .
1. ,
Access .
2. Relationships, Access .
(),
Staff DreamHome.
. 16.1. :
(), , ( , , , , , ), .
16.4.
Staff
DreamHome

(
)

Staff

Client

(a),(d)

: fName, IName
1

20

()

: staff
supervisorStaffNo

20

()

: fName, IName

20

()

; pos i t ion

20

()

: Staff staff No

1000-2000

: fName, IName

1000

16. 595

. 16.4

(
)

Property
ForRent

()

: rentPinish

5000-10000

rentFinish
:
PrivateCwner/BusinessOwner ownerNo
: staff no staff
city
: rent
; ci lent clientNo
: Client clientNo
: PropertyForRent
propertyNo
: PropertyForRent
propertyNo
: client clientNo

100
5000-10000

()

(d)
(f)
(f)

(g)

Viewing
Lease

(j)
(c)
(D

20
50
50
100
100
5000-10000
100
1000


, . 16.5. ,
Microsoft Access ,
Branch DreamHome (. 16.5).
16.5. ,
Microsoft Access
Staff DreamHome

Staff

Client
PropertyForRent

fName, IName
rentFiniah
city
rent

f Name, IName
position

DreamHome,
Oracle

Staff DreamHome.
Oracle,
.

596

IV.

Oracle
. , Oracle UNIQUE, UNIQUE, . Oracle UNIQUE
.
. , CREATE TABLE. . .AS SELECT UNIQUE
UNIQUE .
, , . , - .
, . , ,
Staff Dreamffome, , , . 16.6,
.
,
Oracle , Branch DreamHome (. 16.6).
16.6. ,
Oracle Staff
DreamHome

Staff

f Name, IName
supervisorstaffMo
position
staffNo

Client

PropertyForRent

Viewing
Lease

fName, IName
ownerNo
staffNo
clientNo
rentFinish
city
rent
clientNo
propertyNo
clientNo

5.4.
. , KOTOI
.

>

16.

597

,
. ,
, ,
. , . ,
, .
,
.
,
.
, Oracle.

6.

. , , .
,
14,
,
. . ,
10.4.4, DreamHome:
Branch,
Director Manager;
s t a f f ,
Supervisor Assistant.
2
, ,
3
.
,
. , .
. 6.4.7
, , . ISO SQL (. 6.4.10), ( ) Microsoft Access
(. 7) Oracle (. 8.2.5).
598

IV.

7.
. :> .
.
,
,
(. 10.4.4).
.
. , .
18, , , :
;
.
; , , .
( ),
,
. , . ISO SQL (. 6.6),
Microsoft Access (. 8.1.9) Oracle (. 8.2.5).

. ,
.


.
, ,
, .

.
( 4)
, .
16. 599

( 5) ,
. ,
, ,
.

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

.
(+-), .
+-, ISAM
. , , - ,
,
, - ,
.
, < , .
, .
. , ( ). Oracle : .
, . , ,
, , .
600

IV.


.

. : ,
, .
6
, ;
,
SQL.
, .
7 ,
.

16.1. , ? ?
16.2. .
16.3.
, , ?
16.4.
. ?

DreamHome
16.5., 5.3 ,
Microsoft Access , Staff DreamHome. ,
Microsoft Access , Branch DreamHome.
16.6. 16.5 Oracle
.
16.7. , DreamHome ( 15),
, .
16.8. DreamHome, 16.7.

16.

601

University Accommodation Office


16.9. , 15.11,
University Accommodation Office '( 1 ) , ,
16.10. University Accommodation Office
, 16.9.
EasyDrive School of Motoring
16.11. , 15.12, EasyDrive School of Motoring ( 2 )
, .
16.12. EasyDrive School of Motoring , 16.11.
Wellmeadows Hospital
16.13. , 15.14,
Wellmeadows Hospital ( 3 )
, .
16.14. Wellmeadows Hospital , 16.13.

602

IV,




...
.
.
.
. ,
,
. .

8.

.
.
,
. , . . ,
. , , .
, , .
:
, . ,
:

;
;
,
.
,
, , , . "" ,
, , . .
:
, . , , , 5.1. ,
, .
,
,
.
,
.
, . , Branch, :
Branch(branchNo,street,city,postcode,mgrStaffNo)

, , : city () postcode (
). , city,
postcode. , Branch
.
, :
Branch(branchNo,street, postcode,mgrStaffNo)
Branch(postcode, city)

city, ..
. ,
( ) ,
. ,
Branch.
, ,
.
; ,
, [116] [262].
,
.
1. " " (1:1).
604

IV.

2. " " (1:*)


.
3. " " (1:*)
.
4. " " (1:*) .
5. .
6. .
7. , .
. 17.1, , . 17.1-17.7.
Interview
clientNo {PK, FK}

Client

4 Attends
0..1

1..1

clientNo {PK}
Requests

0..*

viewing

Telephone

clientNo {PK, FK}


propertyNo {PK, FK}

telNo {PK}
branchNo {FK}

0..'

1..3

Takes

PrivateOwner
ownerNo {PK}

Property ForRent

POwns*0..1

A
Provides

1..*

propertyNo {PK}
ownerNo {FK}
branchNo (FKJ

Branch

+ Offers
1..*

1..1

branchNo {PK}

. 17.1. DreamHome
17.1. Branch DreamHome
branchNo

street

city

postcode

005

22 Deer Rd

London

SW1 4EH

007

16 Argyll St

Aberben

AB2 3SU

163 Main St

Glasgow

Gil 9QX

004

32 Manse Rd

Bristol

BS99 1NZ

005

56 Clover Dr

London

NW10 6EU

17.

605

17.2. Telephone DreamHome


telNo

branchNo

0207-886-1212

005

0207-886-1300

005

0207-886-4100

005

01224-67125

007

0141-339-2178

0141-339-4439

0117-916-1170

004

0208-963-1030

002

17.3. PropertyForRent DreamHome


postcode type

property street
No

city

14

16 Holhead

Aberdeen AB7 5SU

PL94

6 Argyll St

London

House 6
Flat

NW2

rooms rent owner


No
i

650 C046
400

C087

staff
No

branch
No

SA9

B007

SL41

B005

PG4

6 Lawrence St

Glasgow

G119QX

Flat

350 C040

PG36

2 Manor Rd

Glasgow

OI324QX

Flat

375 C093

SG37

PG21

18 Dale Rd

Glasgow

G12

House 5

600 C087

SG37

PG16

5 Novar Dr

Glasgow

012 9AX

Flat

450 C093

SG14

17.4. Client DreamHome


clientNo

fName

I Name

telNo

prefType

maxRent

CR76

John

Kay

0207-774-5632

Flat

426

CR56

Aline

Stewart

0141-848-1825

Flat

350

CR74

Mike
Mary

Ritchie
Tregear

01475-392178

House

750

012224-196720

Flat

600

CR62

17.5. Interview DreamHome


clientNo

staffNo

datelnterview

comment

CR56

SG37

11-Apr-OO

current lease ends in June

CR62

SA9

7-Mar-OO

needs property urgently

17.6. PrivateOwner DreamHome


ownerNo

fName

IName

C046

Joe

C087

Carol

C040
C093

606

Address

telNo

Keogh

2 Fergus Dr, Aberdeen AB2 7SX

01224-861212

Farre!

e> Achray St, Glasgow GS32 9DX

0141-357-7419

Tina

Murphy

63 Well St, Galsgow G42

0141-943-1728

Tony

Shaw

12 Park PI, Glasgow G4 OQR

0141-225-7025

IV.

17.7. Viewing DreamHome


clientNo

propertyNo

vfewDate

comment

CR56

14

24-May-Ol

too small
too remote

CR76

PG4

20-Apr-Ol

CR56

PG4

26-May-Ol

CR62

14

14-May-Ol

CR56

PG36

28--01

no dining room

8.1. " " (1:1)


, 1:1, . , ,
, . , , 1:1 Client
Interview (. . 17.1). Client . Interview
, ,
, .
Client Interview
(. 17.2). client Interview
1:1 , Clientlnterview
.
Clientlnterview , ,
. 17.8. Client , ,
Clientlnterview .

. 17.2. Client
Interview:
17.8. Client Interview:
Clientlnterview
client
No

fName IName

CR76

John

Kay

CR56

House 750

tel
No

pref
Type

max
Rent

0207-774-5632

Flat

426

Aline

Stewart 0141-848-1825

Flat

350

CR74

Mike

Ritchie

01475-392178

CR62

Mary

Tregear

012224-196720 Flat

600

staff
No
SG37

SA9

datelnter
View

comments

11-Apr-OO

current lease
ends in June

11-Mar-OO needs property


urgently

17.

607

8.2. "
" (1 :*)

( ) , . , !
1:*. , PropertyForRent ( ) . SQL ( , . 17.1 . 17.1-17.7).
SELECT p . * , .IName
FROM PropertyForRent p, PrivateOwner
WHERE p.ownerNo=o.ownerNo AND b r a n c h N o = ' B 0 0 3 ' ;

IName, , PropertyForRent, PrivateOwner,


SELECT p.*
FROM PropertyForRent p
WHERE b r a n c h N o = ' B 0 0 3 ' ;

PropertyForRent (
iName) . 17.9.
17.9. PropertyForRent:
IName, PrivateOwner
proper street
-tyNo

city

postcode type

rooms rent

owner IName staff branch


No
No
No

14

16 Hoihead Aberdeen AB7 55U

House 6

650

C046

Keogh

SA9

B007

PL94

6 Argyll St

London

NW2

Flat

400

C087

Farrel

SL41

B005

PG4

6 Lawrence
St

Glasgow

G119QX

Flat

350

C040

Murphy

PG36

2 Manor Rd Glasgow

G324QX

Flat

375

C093

Shaw

PG21

18 Dale Rd

Glasgow

G12

House 5

600

C087

SG37 B003

PG16

5 NovarDr

Glasgow

G129AX

Flat

450

C093

SG14

B003
SG37

, ,
. ,
,
. , 1:*

(, Farrel Shaw
PropertyForRent ), . IName PrivateOwner,
PropertyForRent ,
.
, .

608

IV.

,
, IName .
. , ,
. , .

8.3. "
" (1 :*)
,
. ,
. ,
DreamHome, ,
. SQL ( , . 17.1 . 17.1-17.7):
SELECT .IName
FROM PropertyForRent p, PrivateOwner
WHERE p.ownerNo=o.ownerNo AND branchNo='B003';
, -
PrivateOwner Branch
( branchNo) PropertyForRent.
,
branchNo PrivateOwner. ,
Branch PrivateOwner. SQL :
SELECT .IName
FROM PrivateOwner
WHERE branchNO='B003';

PrivateOwner . 17.3 . 17.10.


,
(. 2.3).
,
, (.. ,
. 17.3 . 17.10) .
Branch PrivateOwner
" " (*:*). , PropertyForRent
branchNo, 17.10. PrivateOwner
ownerNo fName

IName

Address

telNo

branchNo

046

Joe

Keogh

2 Fergus Dr, Aberdeen AB2 7SX

01224-861212

BOO 7

087

Carol

Parrel

6AchraySt , Glasgow GS32 9DX

0141-357-7419

B003

040

Tina

Murphy

63 Well St, Galsgow G42

0141-943-1728

BOOS

093

Tony

Shaw

12 Park PI, Glasgow G4 OQR

0141-225-7025

BOOS

17.

609

(, ).
PropertyForRent ( branchNo),
PropertyForRent Staff staffNo. SQL
SELECT o.lName
FROM Staff s, PropertyForRent p, PrivateOwner
WHERE s . s t a f f N o = p . s t a f f N o AND p.ownerNo=o.ownerNo AND
branchNo='B003 1 ;
, PrivateOwner
Branch, branchNo PrivateOwner.
Offers

Serves

. 17.3. : PrivateOwner
branchNo,

8.4. " " (*:*)



, , , *:*.
*:* : , . , , .
*:*
Client PropertyForRent Viewing. : DreamHome
, . , street,
SQL (. 17.1
. 17.1-17.7) :
SELECT p.street, . * , v.viewDate
FROM Client . Viewing v, PropertyForRent p

610

IV.

WHERE v.propertyNo=p.propertyNo AND c.clientNo=v.clientNo AND


comment IS NULL;

street Viewing,
PropertyForRent:
SELECT . * , v.street, v.viewDate
FROM Client c. Viewing v
WHERE c.clientNo=v.clientNo AND comment IS NULL;

Viewing . 17.11.
17.11. street PropertyForRent
Viewing
clientNo

propertyNo

street

viewDate

comment
too small
too remote

CR56

14

16 Holhead

24-May-Ol

CR76

PG4

6 Lawrence

20-Apr-Ol

CR56

PG4

St
6 Lawrence

26^May-01

St
CR62

14

16 Holhead

14-May-Ol

CRS6

PG36

2 Ma nor Rd

28-Apr-Ol

no dining room

8.5.
, .
, 1:*
() . . ,
DreamHome , .
Telephone
" " (3:1) Branch (. . 17.1 . 17.1-17.7).

, ,
Telephone Branch , ( . 17.4 . 17.12).

:

( , .. 3);

. 17.4.
: Branch

17.

611

17.12. Branch
branch
No

street

city

postcode

telNol

005

22 Deer Rd

London

SW1 4EH

0207-886-1212

007

16 Argyll St

Aberdeen AB23SU

01224-67125

163 Main St

Glasgow G119QX

0141-339-2178 0141-339-4439

004

32 Manse Rd

Bristol

BS99 1NZ

0117-916-1170

005

56 Clover Dr

London

NW10 6EU

0208-963-1030

telNo2

telNoS

0207-886-1300 0207-886^100

(
);
,
10 (, , ).
, . Branch
, Telephone, Branch,
.

8.6.

(lookup tables, reference tables),


(pick lists), 1:*, , . , ( )
Property-Type PropertyForRent (
. 17.5 . 17.13, 17.14).
:
: ,
, 1 , 5 ;
( ),
;

, .
PrapertyType
type (PK)

Type For
I '

. 17.5. , :

612

IV.

17.13. PropertyType
( )
type

description
House
Flat

17.14. PropertyForRent,
( )
property street
No
14

PL94
PG4

PG36
PG21
PG16

16 Holhead
6 Argyll St
6 Lawrence St
2 Manor Rd
18 Dale Rd
5 Novar Dr

city

postcode type rooms rent owner


No

Aberdeen
London
Glasgow
Glasgow
Glasgow
Glasgow

AB7 5SU

650

NW2

400

Gil 9QX

350

G32 4QX

375

G12

600

G129AX

450

C046
C087
C040
C093
C087
C093

staff
No

branch
No

SA9

B007

SL41

BOOS
BOOS

SG37
SG37

BOOS

SG14

BOOS

BOOS

, , description ()
(. 17,15). , . , ,
.
17.15. Property For Rent,
description
proper- street
tyNo
14

PL94
PG4

PG36
PG21

PG16

16 Holhead
6 Argyll St
6 Lawrence St
2 Manor Rd
18 Dale Rd
5 Novar Dr

city

post
code

type des
crip
tion

Aberdeen
London
Glasgow
Glasgow
Glasgow
Glasgow

AB7 5SU

NW2

Gil 9QX

G32 4QX F
G12

G129AX

House
Flat
Flat
Flal
House
Flat

rooms rent

650

400

350

375

600

450

owner staff
No
No
C046
C087
C040
C093
C087
C093

branch
No

B007
SL41 BOOS
BOOS
SG37 B003
SG37 BOOS
SA9

SG14

BOOS

8.7. ,

,
() .
,
17.

613

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


, . , , . ,
,

9.

.

.
,
,
.
. , () . :

;
, , ;

, , ,
(
), ;

;
, .
, , . , 614

IV.


.
, . ,
, , . , ,
,
. , , ,
, , . ,
.
, (, ).
, ,
DreamHome
.
1.
, , .
Microsoft Access,
, OLE. OLE
(Object Linking and Embedding ) ,
; Microsoft
Word Microsoft Excel, ( , ), . OLE
Microsoft Access, .
PropertyForRent, : picture
OLE comments Memo ( ). . 17.6 , PropertyForRent,
picture comments.
picture ,
,
BMP ( Bit Map
). , , . DreamHome , ,
, , .
2. World Wide Web (WWW, Web)
.
Microsoft Access,
Oracle, Web- Internet. ,
, Web-,
17.

615

Newly docotaled Ihrourfraut. WeB equipped


kitchen. Close to local amenities

, 17.6. , PropertyForRent
picture comments

Microsoft Internet Explorer Netscape Navigator,


Internet,
, Web,
2.

, , , ,
. ""

, ,
.
8
.
, .
, , .
: , .
9
.

616

IV.

17.1.


?
17.2.
? .

17.3.

,
Dream-Home, 9. ,
.

17.

617

|





SQL

621
655
723
777


...

, .
.
, .

.
, Microsoft Access Oracle.
Web.

,
, . ,
.
2 .
, , , . , , .
, , .
,
, ,
. , [250].


18.1 ,
, , . 18.2 ,
. 18.3 18.4 , -

Microsoft Access 2000 Oracle 8/8i. 18.5 , , Web.



DreamHome, 10.4 .

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

, , .
,

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

V.


.

,
. -
, .

. , ,
, . , , ,

, .
,
. , 24 7 . , , , ,
. , , .
,
.
.
,
.

18.1.1.
|. { ), : , , ,
! .
( ),
, ,
. (,
, )
(, ). , . , .
,
. , .
18.

623

, , ,
.
, . . 18.1 , . ,
, .
18.1.

- -

<

<

""

<

</

^
/

-S

624

V.

. 18.1

(
, ,
), ,



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

, .
. 18.1 , .

18.2.

, ,
, .
, ,
, .
. 18.2.
18.

625

, .
.
,
.
.
.
.
RAID-.

//
-

/


(,
)

. 18.1. ,

626

V.

j1

-' ; 1
|
|

1 ^

-i

'

'.

. 18.2.

18.2.1.
'

&

"

- -

'

. ( ), "* i .

, ,
.
. ""
. ""
, , , ,
, .
18.

627

. , , '
.
,
. , ,
. , .

() , , .
,
.
.

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

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

. SQL 6.6.


.
, . ,
628

V.

. , .
, . , , ,
. ,
.
. ,
, - . SQL , - , ,
.
, . ,
, , ,
, .
. 18.2.
18.2.

S337

Sales

SG37

SG14

Sales

SG14

SG5

Sales



.
, ,
.
, (, (Select),
(Update), (Insert), (Delete) (All)). :
SELECT UPDATE
0001
0010

INSERT
0100

DELETE
1000

ALL
1111

,
, ( ) *

. . 18.3 , Sales SG37, SG5.
18.

629

18.3.

propartyNo

type

price

ownerNo

staff Ho

15

0111

0000

100

1111

1111

0000

0111

0101

1111

1111

0001

0001

0001

SG37

0101

0101

SG5

1111

1111

0000

0000

Sales

branchNo

,
Sales Select ( 0001)
propertyNo, type price. ,
, 15 . SG14
( David Ford) - , , . , SG37 (Arm
Beech) Select Insert (
0001 + 0100 = 0101) propertyNo, type ownerNo, a
Select, Update Insert ( 0001 + 0010 + 0100 =
0111) price staf fNo. ,
100 . SG5 (Susan Brand)
Select, Update, Insert Delete ( 0001 + 0010 + 0100 + 1000 =
nil), .. All , .

, .
, , ,
.
,
. ,

. ,
, .

18.2.2. ()
.
. ,
, |, .

, . ,

630

V.

, .
, ,
. ,
.
3.4 6.4.

18.2.3.
.
( , , ) -;
?> , .
, . , , , .
,
,
.
19.3.3.
: . , - <
,
,
.
,

, . ,
, , .
,
,
. , , .
19.3.3.

18.2.4.

, , ,
. 3.3.
18.

631

18.2.5.
. ,
, ,

,
(
). ,
. ( ),
, .
.
,
, . ,
, ,
. .
, :
,
( );
, , ;
, ;
, , .
, ,
, ,
,
.
,
[206]. ,
. DES (Data
Encryption Standard). ,
IBM. , , . 64- 56 . DES , . ,
PGP (Pretty Good Privacy) 128- ,
.
64 , 632

V.

, .

, .
, 80
, , 128
. " " " " , (),
, ().


. , , , .
, , , .
, .
" ", ,
.
RSA (
).
, , , ,
,
. Web
18.5.

18.2.6. RAID (
)
, ,
. ,
.
, , , , , , , .

.
RAID.
Redundant Array of
Inexpensive Disks ( ),
"I"
"independent" (). RAID-
, , ,
.
18.

633


. , ( ), .
, .
-,
- ( ).
.
RAID- ( )
,
, (Reed-Solomon) [252].
, 0 1,
, 1
, . ,
, 1 . , , . , ,
.
.
RAID- , RAID. & .
RAID 0 ( ).
, .
.
RAID 1 ( ).
() .
. .
RAID 0+1 ( ).
.
RAID 2 ( ,
).
.
RAID 3 (, ).
634

V.

( )
.
, , .

RAID 1, , .
RAID 4 (, ).
; ,
. , .
RAID 5 (, ).


, RAID 3,
, . , ,
.
RAID 6 ( P+Q).
RAID 5, . .
, Oracle RAID 1
.
RAID 5, , RAID 1 RAID 04-1. RAID , [56] [57].

18.3. Microsoft Access


8.1 Microsoft Access 2000. , Access.
6.6 GRANT REVOKE SQL;
Microsoft Access 2000 , :
, (
Microsoft Access );
, ,
( Microsoft Access ).
, Microsoft Access.
" 18.

635


,
. ( ToolS^Security)
;
. , .
, Microsoft Access ,
, , , , . . 18.3,
, . 18.3, 6 ,
, .
I Jcui.mm' (id JM
;

[ .. :
f :


(
^ )

. 18.3. DreamHome
: ) Set Database Password (
); ) Password Required
( ),


Microsoft Access
, . Microsoft Access . Microsoft
Access . Access
; ( Admins)
( Users), fro . . 18.4 ,
.
Assistants, , Assistant,
Users Assistants.
,
/
. (User an(
Group Permissions). . 18.4 ,

636

V.

Microsoft Access. , . 18.5


Assistant, Staffl_View. ,
Staff ,
Assistant Staff,
.
18.4. Microsoft Access

Open/Run

, ,

Open
Exclusive

Read Design

Design

Modify
Design

Administer

: ,

: ,

Read Data

Update Data

( )

Insert Data

( )

Delete Data

( )
. -, . --
j | j
;

Assistant


Users Assistants

Assistants,

. 18.4. User and Group Accounts ( ) DreamHome

18.

637

| |
' :
Admin

Assistant
Staff 1_Vlew

-iB :
< /)>
Branch Managers
Branch Staff
Sanch Supervisors
properties by Price
Properties by Stall

|;

, ^-v.;..,-^

"

', "

"

! "

"

; jAdrtn

. 18.5. User and Group Permissions (), , Assistant


Staff l__View

18.4. Oracle
Oracle 8/81 8.2,
, Oracle.
Microsoft
Access: . ,
Oracle. Access,
, Oracle, , .
. . 18.6
Beech, .
Beech Connect Log On (. 18.7)
.

18.2.1, SQL
. Oracle,
.
( ),
.
.
Oracle :
;
.

638

V.

Aut Iwibcatori

password

. 18.6. Beech,

I; ifeefHame:

JBeech

= gaeswerd;
! Siring:
| "
OK
.,
>~. - - - . . - , - -

, Jl)renrnHome|
j
;

Caf>t
' ' ' . - .
..-:-..
-.:.- . "

. 18.7. Log On , .




. ,
. Oracle 80 .
( ) :
Grant System Privileges/Roles Revoke System Privileges/Roles
Oracle Security Manager;
GRANT REVOKE SQL (, 6.6).
18.

639

,
ADMIN OPTION, GRANT
ANY PRIVILEGE.

, , ,
, . . , Staff.
( , )
;
. , ,
ALTER ANY CLUSTER.
, . ,
. SQL, , WITH GRANT OPTION ( GRANT), ,
, ; ,
. . 18.5
, .

.
. , Beech
PropertyForRent:
GRANT INSERT ON PropertyForRent TO Beech;
(
),
. , ,
PropertyForRent Assistant, , , Beech. , .
. 18.8
Assistant Oracle Security Manager.
, , , , .

18.5. Web
Web 28

Web. , ,
Web, 28 i
.
640

V.

18.5. ,


ALTER TABLE


DELETE. .
DELETE
SELECT

INDEX


CREATE INDEX

INSERT


INSERT



INSERT

REFERENCES

,
.

SELECT


SELECT



SELECT

UPDATE


UPDATE.
.
UPDATE
SELECT



UPDATE

DELETE

DELETE

Internet TCP/IP
HTTP.
. Internet
( )
. , , ,
, Internet
.
. , ,
Internet. , , Internet
:
, ();
();
,
();
18.

641

,
( );
(
, ).

'
equences
Snapshot
i--Q Synonyms
a- LJ Tables
i- BRANCH
*gBfpROPERTVFORRNT|
STAFF

ALTER
DELETE
INSERT
SELECT

NSERT ON MANAGER.PRQPERTYFORRENT
SELECT'ON MANAGEF1 PROPERTYFORRENT
UPbAfEONMANAGER.PROPERtYFORRENt

Create ;-.'] ::>1;^ |^'HideSaL : = j ..; '' = ' ;'l

sjsJantMDT IDENTIFIED;
GI^JT-IHSERT ON "MANAGER"."PROFCRTYFORRENT'
TO "ASSISTANT"; ;= -
GI^NT SELECTION "MAi-tACiER^.'I'ROPEBTYfGf

. 18.8. Assistant Insert, Select Update


propertyforRent

,
- Web. , Web-. ,
Web
,
,
. , , ,
.
, Web,
, , ,
. , HTML- ActiveX, JavaScript/VBScript, Java.
, :

642

V.

;
;
;
,
;

;
,
;
, , .
. Internet
. , .

18.5.1. -
Web - ,
Web- Web-. Web-
, . Web-. -
: .


-
, . , , Web -.
Web-,
. Web-, , - , . - , , . -,
, CompuServe
America Online, .


- . , -
Web-.

18.5.2.
, Web-


18.

643

. Web- , , , ,
.
,
. , .
Internet , Internet ( ,
). ,
, , ,
. .
. , ,
, . , , . ,
IP-.
( IP- . IP-,
, .)
.
, FTP Telnet.
,
.
. TCP UDP (User
Datagram Protocol ).
.
-. ,
. -
.
. " "
.
,
, 18.2,

18.5.3.

( ) ()
( ).
:
644

V.

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

;
( ,
);

;
, .

,

, ,
.

18.5.4.
, , , , , .
, , ( Certificate Authority). ,
. Internet.

, ,
, ,
(,
). , .
, ,
. , Internet,
,
,
18.

645

.
, , ,
. .509.

18.5.5. Kerberos
Kerberos ( , ). Kerberos
, . ,
Kerberos, . Kerberos ,
: .
, , Kerberos .

18.5.6.
HTTP
,
Internet, SSL
(Secure Sockets Layer ), Netscape Internet. SSL , SSL. SSL Netscape Navigator Internet Explorer, Web-
, . ( HTTP)
TCP/IP* , . SSL
, , , FTP NNTP.
Web S-HTTP (Secure HTTP ), HTTP.
S-HTTP Enterprise Integration Technologies (EIT),
Verifone 1995 . SSL , ,
S-HTTP .
SSL S-HTTP ,
.
IETF (Internet Engineering Task. Force
Internet) .
, Web-, SSL, -

646

V.

https:, http:. SSL/S-HTTP


Web- .
,
,
. , , ,
:
Web- ;
Web- , , ;

(, ),
;
,
( , , ).
Web SSL S-HTTP ,
. , SSL S-HTTP, .

18.5.7.

SET (Secure Electronic Transactions ) ,

Internet, Netscape, Microsoft, Visa,
Mastercard, GTE, SAIC, Terisa Systems VeriSign. SET
Internet
. , , ,
, ,
, ,
, ,
. , ,
(, Visa), , .
SET , ,
.
. 18.9.
SET Microsoft Visa International, STT (Secure
Transaction Technology ),

Internet. STT DES,
RSA, , .
18.

647


(Secure Electronic Transactions SET)
,
,

.
,
.

6.

.

5. > ,


; '

2. ;

,


.
' ?

.

3;


,
,- " : '
.; .

. 18.9. SET

18.5.8. Java
28.8 Java,
Web. ,
Java, 28.8 .
Java,
( ""), ,
, , .
"" : ,
- .
Java Java (Java Virtual Machine - JVM), .
, , .
Java
"".
: -. , Java,
JVM Security Manager.

648

V.



;
, , / , . Java
,
( ).
, " "
, . ,
- , Java, , , . JVM , .
Java
, , Sun Microsystems ( Java),
. , Java,
(, ) .

-
JVM / ,
. ( ) , , ,
, . , :
;
/ ;
-
(, ); ;
- ;
.

Security Manager
Java . Java
(, Web- Web- Java)
. Java
Security Manager. , Web- Java Security Manager, , ,
Security
Manager. Security Manager
"" , , ,
18.

649

-, . , ,
, , .
.
(, ),
, , .
, , .class . ,
HTML- , , CODEBASE .
CODEBASE.
.
.
. ,

.
, Internet .
, , CLASSPATH.

, -
-. Appletviewer, JDK (Java Development
Kit Java), ,
. , Internet Explorer 4.0 Microsoft
, , . Java,
,
. , , .


"" API-
Java 1996 .
, ,
. -, ,
, ,
. -, , , , .
650

V.

API- Java (Java Security API),


JDK 1,1, API-
, , , / ( , ).
,
.

18.5.9. ActiveX
ActiveX ,
Java. Java
, . ActiveX, , -
, , .
ActiveX Authenticode.
.
.
ActiveX, ( ,
), , , . .


.

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

: , , /, , RAID.

( ), . ,
, .

,
. , , -

18.

651

. ,
.

( , ,
),
. , ,
,
.
,
,
.
,
.
Microsoft Access Oracle : .
, , ,
, .
Web -, , ,
, Kerberos, SSL (Secure Sockets Layer) S (Secure HTTP), SET (Secure Electronic Transactions) STT (Secure
Transaction Technology), Java ActiveX.

18.1. " "?


18.2. ,
, .
18.3. :
) ;
) ;
) ;
) ;
) ;
) RAID.
18.4. Microsoft Access
Oracle?
18.5. Web?

652

V.


18.6.

, , ,
.
18.7. ,

Internet.
18.8. DreamHome, 10. , , .
18.9. Wellmeadows Hospital, . ,
, .

18,

653

...

.
.
,
.

.
.
.
.
.

.

.
,
.

.
.
.

Oracle.

2 ,
.
,
, : , . ,
,
. .

,
.
,
.
. ,

, . , .

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

, , , , 19.1.
19.2
, .
19.3 , . 19.4
,
( ),
, . 19.5 Oracle.
, , .. ,
. 23 , (
, ).

19.1.
. ,
, ' .

656

V.

, . ,
(, INSERT UPDATE
SQL) , . , , .

DreamHome (. . 3.4 3.5):
Staff

( s t a f f N o , fName, IName, position, sex, DOB,


salary, branchNo)
PropertfyForRent
(propertyNo, street, city, postcode, type, rooms,
rent, ownerNo, staffNo, branchNo)

, ,
,
. ,
. 19,1 ( ).
read(x) write (). . , (. 19.1)
read ( s t a f f N o = , salary), ,
salary , .
,
(read write), , (salary =
salary*! . 1).
19.1.


d e l e t e ( s t a f f N o = )
for all PropertyForRent records, pno

r e a d ( s t a f f N o = x,

salary)

begin

salary = salary * 1.1


w r i t e ( s t a f f N o = x,

read(propertyNo = pno, s t a f f N o )

new_salary)

if ( s t a f f N o = x) then
begin
s t a f f N o = newStaffNo
write(propertyNo = pno, s t a f f N o )
end
end

, . 19.1
( ), , . ,
S t a f f , PropertyFarRent,
, , , , , newStaffNo.
,
19.

657


.
, , . , , . 19.1, , PropertyForRent
staffNo newStaffNo,
.
newStaf fNo.
.
(coramiti
, . , .
,
.
(roll back), .
. , , , , ( 19.4.2). . ,
, ,
, .
,
. , ,
. .
BEGIN TRANSACTION,
COMMIT ROLLBACK ( )1. ,
. COMMIT . , ROLLBACK.

. . 19.1.
, , ACTIVE,
COMMITTED ABORTED, , .
PARTIALLY COMMITTED.
. , ( 19.2.2) , .
,
, ,
. FAILED . ,
COMMITTED.
5

ISO SQL BEGIN TRANSACTION


SQL, (. 6.5).

658

V.

FAILED. , , ACTIVE,
,
.

19.1.1.
,
. ,
ACID (Atomicity, Consistency, Isolation,
Durability , , , ),
[149].
. , " ".
, ,
.
.
.
.
, .
, , .
. , ,

,
, .
, . , - .

EN ^TRANSACTION

BEGIN_TRANSACTION

. 19.1.

19.

659

. .
,
. .
. () . .

19.1.2.
2. . 19.2
(. . 2.6),
, , .
. , .
,
.
, , .
,
. , ,
, , , . , .

19.2.
, , ,
.
.
.
, ^ .

19.2.1.


, .
,
, .
660

V.

. 19.2.

.

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

, , -
19.

661

. ,
:
, .

DreamHome, ,
.

19.1.

.
. . , . 19.2. . TV 10
balx, 100 , 2 100 .
, ,
, 190 , .
, T t 2
, 100
. :, 100
, 200 ,
1. : bal x , 90 , , . "" 100 , .
2, T! bal x 2 .
19.2.

TI

ti

bal x

begin_trausaction

100

read (balx)

100

ta

begin_transaction

t3

read (bal x )

balx - balx +100

100

balx = 1 -10

write (balx)

200

t5
tt

write (balx)

commit

commit

90
90

19.2.
( "" )
,
,
662

V.

. . 19.3 , .
bal x , .
4 1 200
, ,

, 100 .
3 bal x (200 )
10 , , 190 ( 90 ). bal x , , .
,
19.3.

T3

balx

ti

begin_transaction

100

read(bal x )

100

t3

bal x = bal x +100

100

write (bal x )

200

begin

transaction

read (bal x )

t,

bal x = balx-10

tv

write (bal x )

tl

200

rollback

commit

100

190
190

; , (, ). , 3 4 ,
. , 3 bal x ,
4 .
, ,
. ,
, ,
, . .

19.3.
,
,

. , , ,
(, ), 19.

663

,
. . 19.4. 6 ,
, 5.
(100 ),
(50 ) z (25 ). 5 1
1. 6
( 10 ). ,
Ts bal x 1 , .
19.4.
- 5

begin

baly

bal,

sum

50

25

sum = 0

100

50

25

read (bal x )

100

bal x = balx-10

sum = sum + bal x

100

write (balx)

read(bal y }

90

50

read (1 )

sum = sum + bal y

90

50

begin transact ion


read(balx)

25

100
'
.

bal : = b a l j + 10

90

write (bal z )

90

50

read(bal z }

90

50

ISO

sum = sum + 1

90

50

-'

185

90

50

35

185

commit
tn

transaction

balx
100

t!

ta

T6

commit

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

19.2.2. ^
,
, , . 664

V.

,
.
, ,
, (
"" "" , , ). , ,
, , , . , , [245].
.
J

. ' , .

, , , . S
, 1 2, ..., ,
, ,
. TI S.
. , ! , .

.
, (: 2),
1( 2 ( 2 , T^). , , . ,
. , , (..
).
' . , ,; .
, 19.1-19.3,
,
( ) ( ).
.
19.

665

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

.

, .
,
,
.
Slt . 19.5.
, 7 . 1 T s
toaly 7 , S2, .
,
S3, (. 19.5), .
write (bal x ) write (bal x ) 7.
read(bal x ) read (bal. y ] 7.
read(bal x } write (baly) 7.
S 3 , Si S2 S;, .

666

V.

19.5. : s:;
sa, s^
S3,
! 2

-,


ti
ta
i
t

begin_transaction
read(bal x )
write (bal x )

begin_ransaction
read (bal x )
write (balx)

ts

tl
tl
ta
tB

read(baly)
write(baly)

..

commit
read (baly}

1
tu

write (baly)

commit


ti
ta

begin_transaction
read (bal x )
w r i t e (balx)
begin__transaction
read(ba! K )

ts
t

read(baly)

write (bals)

t7
tl
-9

write tbaly)
commit
read (baly)
write (bal y )
commit

tip
til

tl2


ti
ts

t3

tt

ts

tt

begin__transaction
read (balx)
write (bal x )
read(baly)

write (baly)
commit

t,

tl

begin_transaction
read (bal x )

ts

write (balx)

tio

read ( b a l y )

tu
tl2

19.

write (baly)
commit

667

.
. ,
( ,
, ),
( ). s
G = ( N , E ) , N, .
, .
TI>Tj, 3 , .
Ti~Tj, ^ , ']\.
Ti-s-Tj, Tj , .
, S, TI>Tj, S 1 , S,
TI Tj. ,
.
19.4. ,

,
. 19.6. 100 bal x
1. 10
10%. ,
. 19.3, , .
19.6.

10

TS

ti

begin_transaction

t2

read(bal x )

t3
t4
t

bal x = bal x + 10
write(balx)

begin_transaction
read(bal x )

t7

write (bal x )

te

read(baly)

tg

baly = baly*l.l

tio

write (baly)

668

V. >

. 19.6

tn
I
t
tl4

9
read(bal y )

10
commit

baly = baly - 100


write (baly)
commit

. 19.3.
. 19.6


, ,
, .
.
, ! S2, ,
Tlt 2 , ..., , , .
: S^ Td
S 2 .
Ti
S3: T j t
S2 , Tj.
: 5 T i f
S2.
,
. , . , ,
. 19.7, , . 12 13
, , , . ,
, , .
19.

669

19.7. ,

TU

ti

begin_transaction

tj

12

TU

read {balx)
begin_transaction

t4

write (bal x )

commit

ts
ts

t,

write {balx}
commit

ta
t,
tin

begin_transaction

write (bal x )
commit

, , NP- ( ), , - [404].
. , .
, . .

,
, .
, . , , ,
. ,
, ( , ).
, . 19.6.
, commit
. 10 balx, 9, .
, 10,
1,
. . , . .
. ,
. T-J : TJ
, ,
: ^ fj. TJ.
670

V,


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

19.2.3.
, . i-' . , ( >; )-
% ,
.
,
:
()
() , . , .
-~ . .
, , .
. .

19.2.8, " ". .
. - "
, ,
-; .

' 19.

671

.
, , |
.
,

.

. , ,
, , .
, .
, , .
,
, ,
, .
- , .
, ,
. ,
, . , , .

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

, .. .
,
. 19.5.
672

V.

I 19.5.
, . 19.6. , , :
S (write_locK(T 9 , b a l j , read(T 9 , balj , write (,, bal x ) ,
unlock(T 9 , bal x ) , write_lock(T 1 0 , bal x ) , read{T 10 , balj ,
write (T 10 , bal x } , unlock {T 10/ bal x ) , write_lock (T 10 , bal y ) ,
read(T 1 0 , b a l y ) , write (T 10 , bal y ) , unlock (T 1 0 / bal y ) ,
commit (T 10 ) , write_lock ( , bal y ) , read(T 9 , bal y ) ,
write(T 9 , b a l y ) , unlock{T 9 , bal y ) , commit ( ) }

bal x 100
, bal y 400 ,
bal x 220
, bal y 330 ,
9 10. 10
T s , bal x 210 ,
bal y 340 . S
bal x , 220 , a bal y 340. ( ,
S .)
, , / (,
balx) . (baly) , bal x
. ,
,
.

,
. (2PL).


.
, .

: , , , ,
. , . , , , 19.

673

.
, ,
.
.
, . , .
, .
,
.
,
. .
,
, 19.2.1.

19.6.

. 19.8.
, 2 1. , 100
. bal x . , 1
2 ,
^ , ^ (wait) 2 .
2 ,
19.8.

TI

ti
t2
t3

begin_transaction
write_lock (balx)

balx

begin_transaction

100

write_lock(balx)
read (bal x )

t4

WAIT

ts

WAIT

write (bal x )

t6

WAIT

commit/unlock (balx)

t7

read(bal x )

ts

bal x = balx -10

ts
tlo

674

bal x = balx+100

100
100
100
200
200
200

write (bal x )

200
190

commit/unlock (bal x )

190

V.

19.7.


. 19.9.
^ bal x .
, 100 ,
. 1 , 100 . 3
1. , , 4,
4 . 4 .
19.9.

ti

bal x

begin transaction

ta

I
tt

begin___transact ion

write_lock (balj

t6

WAIT

100

w r i t e lock (bal x )

100

read (balx)

100

bal x = bal x +100

100

write (bal x )

200

rollback/unlock (bal x )

100

' '
t,

read(balx)

100

bal x = bal x -10

100

write (bal x )

90

commit/unlock (bal x )

90

n;

19.8.

. 19.10.
5
,
. 5 bal x . bal x 6
,
, .. .
19.

675

19.10.

ti
t
ta


begin transaction

begin transaction

sum = 0

balx

baly

balj.

sum

100

50

25

100

50

25

100

50

25

read lock (bal*)

100

50

write_lock (bal x )

t4

read (balx)

bal x = balx-

WAIT

100

50

-..

write (balx)

WAIT

90

50

25

write_lock(bal z )

WAIT

90

50

25

t,

read (bal z )

WAIT

90

balz - bal z + 10

WAIT

90

.-

: ,

w r i t e (ba! E )

WAIT

90

50

35

WAIT

90

50

35

read (bal x )

90

50

sum = sum + bal x

90

50

90

read lock (baly)

90

50

tl!

read(baly)

90

tl.

sum = sum + bal y

90

read l o c k ( b a l E )

'

tlfl

til

'

commit/
unlock ( b a l x , bal z )

tie

read (bal z )

til

sum = sum + bal s

tao

commit/unlock (bal x ,
baly, b a l z )

0
90
.

50

-.
35

50
90
90

1'

51

140

175

175

, , [108]. , , , .

19.9.
, . 19.11,

. 14 bal x , bal y , , bal* , . 15
balx, , , . , 16 balx .
676

V.

14. T l s 14 ( , 14),
. , 16
15 . , ,
,
19.11.

14

ti

begin_transaction
write lock(balx)

:>

.s

T1S

read(bal x }

read_lock (bal y )
5

read(baly)

bal x = baly + bal K

t.

write (bal x )
unlock (baljt)

begin_transaction
write_lock (bal x )

t,

tie

read(bal x )

balx = balx + 100

,,

write (bain)

tl2

unlock (balx)
t

tic

rollback
begin transaction

tie

read_lock ( b a l x )

t17

rollback

tie

rollback

tl?

,
.
, , .
,
.
, 15
, 14 . . ,
, .
19.

677

2PL, - , . 2PL.
, ,
. ,
.
, ,
. (
19.2.4.) ,
,
- ,
. ,
, .
, , . ,
,
" , ".




( ) , . ,
( ),

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

678

V.

,
, . , .

.
-, .
-
,
. ,
, , ,
. ()
,
-, ,
-. -
.
, , .
, , .
[290].

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

19.2.4.
. , ,
( ) , .
. 19.12 , 17 1, , . t 2
17
bal x , t s 18
19.

679

baly. t fi 17
1, ,
18. t 7 19, , 1
,
1 . , . ,
. .
19.12.

tj,

begin_transaction

t2

write_lock(bal x )

t3
t4

read (balx)
balx = bal x - 10

ts

w r i t e (balx)

TIB
begin_transaction
write_lock (bal v )
read(baly)
bal y = bal y + 100

ts

write_lock (baly)

write (bal y )

t?

WAIT

write^lock(bal x )

ta

WAIT

WAIT

t9

WAIT

WAIT

t 10

WAIT

, : . , . . 19.12 , , T 1S .
,
17 . ,
.
: , , . - , - ,
, . , ,
.
,
. 680

V.

- , ,
.

-
-. ,
,
, .
, -.
,
, , .
, .



,
19.2.5. [264]. , "-", ,
.
.

. , "-", :
.
, , .


(Wait-For Graph WFG).
. Tj , TJ , IV G-- (N, ), N, .
, .
Ti-^Tj, , -,.
, [157]. . 19.4 , . 19.12. , (17-1-17), , .

19.

681

. 19.4. ,


,
.

. ,
. ,

. , . .
, ,
, ( ).

, .
.
1. , .

.
. , ,
,
. :
) ( ,
, ,
);
) , ( ,
, , );
682

V.

) ,
(
, , , ). ,
.
2. . , . ,
, , .
,
.
3. . , , .
, 19.2.3,
, , . , ,
.

19.2.5.
. , .
, ,
. , , .
(timestamp),
,
. - ,
, ,
. .
-
, .
?; . , ;
| .

.
19.

683

. ,
,
{ )
: .
,
,
, . , /, . ,
.
, .
.
(read_tiraestamp), /
, , (write_timestamp), /
, () . , , ts ( ) , .
1. read(x)
(),

()
:
ts(T)
<
write_timestamp (). ,
, .
, , ,

.
,
.
(ts{T) > write_timestarap (x))

:
read_timestamp() = m a x ( t s ( T ) , read_timestamp(x)) .

2. write(x)
(),
: t s ( T ) < read_timestamp (x),
, . ,
, ,
. 684

V.


.
(),

:
ts(T)
<
write_timestamp (). ,
() .
, .
,
: write_timestamp() = t s ( ) .
, , ,
, , . , ,
, .
. ,
.


, [303]. , ,
.
(),
: ts{T) < read_timestamp{x).
,
.
(),
: ts(T) < write_
timestamp (x). ,
, , , . .
. .
,
: write_timestamp() = t s ( ) .
,
-
, . , , . 19.7,
bal x , 11( 19.

685

, 12.
,
, . ,
- .
,
, .

I 19.10.
. 19.13 ,
19 ts(T l 9 ), 2 0 t s ( T j 0 ) , 31 t s ( T 2 1 ) ; ts(T 1 9 ) < t s ( T a o ) < t s ( T 2 1 ) .
19.13.

ti
t

T19

21

begin transaction
read (balx)
balx =
bal,c + 1 0
write (balx)
read (baly)
baly =
baly + 20
read (baly)

i,
i

read (balx)
balx = balx + 10
write (balx)

begin__transaction
read (baly)
baly =
baly + 20

write (baly) n

baly =
baly + 30
write (baly)
1 = 100
write (balz)

i
'- i
;

1
t

baly =
baly -t- 30
write (baly)
balz = 100

write (1)

12 = 50

balz = 50

write (balz)

write (balz)

read (baly)
baly =
baly + 20
write (baly)

tie

begin transaction
read (baly)

write (baly)
1

20

commit

commit
begin transaction
read (baly)
baly =
baly + 20
write (baly)

commit '

.
t e , ;, , .
ti4.

686

V.

t14 , Ti9,
, T2i t12.


. 19.5 (Conflict Serializability CS), , (View Serializability VS),
(Two-Phase Locking 2PL) (TimeStamping
TS). , , , ,
, 2PL
TS, , 2PL TS, .
, , (2PL TS), ,
2PL, TS, .

. 19,5.
(CS), , (VS), (2PL) (TSJ

19.2.6.


, ,
. ,
, - ,
.
, 19.4 [24], [59],
[60]. , [256], [257].
19.

687

19.5 Oracle .
, , ,

.
,
, ,
,
.

. -
, ,
.
,
Xi, x2, ... , i- .
x i t
, read^timestamp (xi), ,
Xi , write_timestarap (X;J,
, Xi.
t s ( T ) .

.
1. , write ().
, , 3 , , t s { T ) < ts{T-|}. ,
Tj. , Tj
, .
, Xj
, ts(T)
(..
write_timestamp(xj} < t s ( T ) ) read_timestamp(xj) > t s ( T ) , .
Xi
read_timestamp(x t ) = write_timestamp (Xi) = t s ( T ) .
2. , read ().
,
Xj
, ts (), , . write_timestamp(Xj), , write_timestamp(xj) < t s ( T ) . read_timestamp (^5 = m a x ( t s ( T ) ,
read_timestamp (-,)). , .
688

V.

, .

. ,
Xi .,
.

19.2.7.

, , ,
. , ,
, , [201]. , .
, . , , . , , , ,
, .
, ,
- .
, .
, , .
,
.

. , , .
. ,
, .
, , , -
.
, . , . , , ,
.
.
, , . , ,
.
19.

689


, . , start (). (validation ()) ( f i n i s h ( T ) , ).
, .
1. S
: finish (S) < start (T).
2. - S, :
) , , ,
;
)
: start () < finish(S)
< validation().
2, , , , . 2,<5 ,
,
.
, . ,
, . ,
,
,
. , , .

19.2.8.

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

V.

( ; , ).
,
.
( ) , ,
.
,
. ,
.
, .
, .
,
. , .
, . ,
95% ,

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


, , . 19.6.
19.

691

. 19.6.

, 1-
, 2- . , ,
. - , -. ,
(),
(^ 2) (, 2) .
, , .
, ,
, ,
, , -
. ,
i
(2), () ,
, ( ) , . , , .
692

V.

, , -. , ?, ,
, , .


,
, , .
, [139]. ,
, . (, ^) , , , ,
.
(Shared ), (eXclusive ). (IS) ,
(IX) , . , (SIX), ,
IX. , SIX IS. ,
,
. 19.14.
19,14.
,

IS

IS

IX

SIX

IX

SIX

X
X

</ ~ ; *


.
, .
19.

693

,
.
,
.

, , .
. , - ,
.

19.3.
. , .
,
,
.

,
. ,
. , ,
, , , .

19.3.1.
, : , ,
. ,
.
. , ,
- .
,
, , .
, . , , ,
. ,
( ) .
,
( ),
. , 694

V.

RAID -, ,
( ) (. 18.2.6).
,
,
. ,
() . , .
, , .
, ,
, .
, , , ,
.
, ,
.
,
.
, , .
,
, : ,
, .
,
.

19.3.2.

. ACID ( ) .
,
,
. ,
( ), , ,
, , .
,
(, . 19.1, ). .
2

Redundant Array of Independent Disks ,

19.

695

, .
.
salary.
.
, .
.
salary .
.
.
, ,
.

(, ) , . .

, , .
,
(redo) (
), .
,
, (undo) ( ), . ,
. ,

, .
, , , .
, .

19.11.
. 19.7
..., 6. t a , t f
. , 2 3
.
, - Ts
. , . , , () 4 5,
. 696

V.

,
2
T3
T4
Ts

to

to

t,

, 19.7.

,
, . -

2, 3 , 4 5.


,
.
, , , , .

, , () ,
,
.
(First-In-First-Out FIFO) (Least Recently Used LRU). , ,
.

(pinCount dirty)
. , ,
.
,
.
,
1. , (
), pinCount (pin count
). , ,
. , .
" 19.

697

2. dirty , .
3. , dirty
.
pinCount 1. , , pinCount 1. , , ,
dirty , .. ""
( ). pinCount ,
,
(.. dirty ).
,
.

, ( ).
, "" , . .
, , ,
. .
, , ,
. , , , , , , ,
, ,
. , , , .
, , , , , , (
). ,
, ,
, , i
, ,
. 7
, '
.

698

V.

19.3.3.
:
,
;
,
;
,
;
,
, .


, ( ) .
.

(.. ).
, . ,
, ,



, .
, . .
,
;
( , ,
, );
,
( , );
, ..
( );
, .. ( );
,
(
).
, .
, (, , ..). (, ,
, ..).
19.

699


. . 19.15
, 2 . pPtr nPtr
.
19.15.

Tl

10:12

START

10:13

UPDATE

!;=

10:14

START

'

T2

10:16

INSERT

STAFF
SG37

T2

10:17

DELETE

STAFF
SA9

.,,.-,

10:17

UPDATE

10:18

START

10:18

COMMIT

10:19

CHECKPOINT

10:19

COMMIT

10:20

INSERT

STAFF
SL21

PROPERTY
PG16

nPtr

.,

pPtr

2.
'

PROPERTY

10;

COMMIT


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

700

V.

,
.
,
(, 70%). ,
.
,
. .
,
, . ,
, , .



.
, , , .
.
; .
. .

.
.
.
. ,
.
,
,
.
, ,
. ,
, , , . ,
1 , .
: , , , [, .
19.

701

19.12.

19.11. , t c
, ,
2 , .
.
4 5, . , 6,
.
,
. , 15-20 .

19.3.4.
, , , .
.
(, ),
, , . , , .
( , 16) , ,
, ,
, .

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

V.



, . ,
,
. ,
. .
.

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

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

, , .
19.

703

, . , , ,
.
.
.

.
,
.
.

.
, ( ) .
.

,
( )
. , ,

, , .
,
,
.
,
. ,
,
,
, .
. ,
, ,
, , . ,
, , , . , , . , ,
, .
704

V.

, ,
.
, .


, ,
[210]. . , .

. ,
. . : , ,
,
. :

.

19.4.
,
, ,
, . .
, , .
, .
24.1 ,
. (CAD), ()
(CASE), , .
, , , .
.

. ,
, .
, , , , .. 19.

705

.
,
.

.
,
.
.
.
.
,
, , , .

.
,
.
. , , , .

(, ). . ,
, .
, , , . ,
, [136].

. , .

19.4.1.
.
,
. .
706

V.

(Moss) 1981 .
,
,
.
. , ,
, , , .. , ,
{ ). . 19.16
T l t ,
.
(2), (5) (6). : (3)
- (4).
. ,
3 4 2, 2
^.
.
, .
.
. . (6)
.
, . , ,
, .
.
,
, , . , 3 ,
2 . ,
:. , .
(ACID), -
( ) .
,
. , . , ,
, , 19.

707

19.16.

begin_transaction Ti

Complete_Reservation

begin_transaction T2

Airline_reservation

begin__transaction T3

First_flight

reserve_aii:line_seat (London, Paris} ;


commit T 3 ;
begin_transaction T4

Connecting_flight

reserve_airline_seat(Paris, New Y o r k ) ;
commit 4 ;
commit T2,begin_transaction Ts

Hotel_reservation

book_hotel(Hilton);
commit ,begin_transaction Ts

Car_reservation

book__car () ;
commit T 6 ;
commit Ti;

. ,
. , ,
.
.
. , .

.
, .
. .
. ,
-
.

. , ,
- .
708

V.

, . , , SAVE
3
WORK . ,
,
, , ROLLBACK WORK
__^. ,
, -
.

19.4.2.
. () , .
(sagas), - (GarsiaMolina) (Salem) 1987 , . ,
,
, .
,
, . , , , . , , T l s
2, ..., C lt 2, ..., ,

.
1. T lf 2, -.., .
2. 1 2 , ..., Ti, Ci. lt .,., -,
.
, ,
, :
3, 4 , , 6

-
, . 19.16. ,
, .
, . 3

SQL
.

19.

709

,
, . . ,
.
. ,

.

19.4.3.
, 19.4.1, ,
, . . , . , *

.
, .
,
[322], [323]. .
. L 0 , Lj
Ln, L 0
, a L n . , (L0) . ,
Li , , Li.! . ,
.
, , , 8, . 19.18. , .
7
, . 19.17.
, ,
.
19.17. 7

7:

71, balx 5
T7J, balv 5

710

T8i, baly
, 1 2

V.

19.18.

t,

begin_transaction

ta

read(bal x }

ta

bal x = bal x +

t<

write (balx)

begin transaction

i
t,

read (baly)

tT

baly = baly + 10

ta

write (baly)

t,

read (baly)

tio

baly = bal y - 5

tn
t

write (baly)
commit

read(bal x }

tn

bal x = balx - 2

tia

W r i t e (balx)

tii

commit

19.4.4.
, , ( ), , , , ..
, (ACID) ,
: (split_transaction)
(join_transaction) [253]. , , (, ).
(, ) , .

, ,
, ACID,
.
,
,
. ,
, , .

19.

711

1. AWriteSet n BWriteSet BWriteLast. , , , , .


2. AReadSet n BWriteSet = 0. ,
- .
3. BReadSet n AWriteSet = shareSet. , .
, . ,
, , , . BWritebast ShareSet ,
.
,
, ^
.
, , ,
.
.
. ,
.
. .

19.4.5.
, ,
. , - ,
.
,
. ,
ACID , .
, , , (, , ).
,
DreamHome. ,
, ,
712

V.

. , , . ,
. ,
, .
: . ,

,
. , [267].
. ,
.
.
,
.
. ,
.
, , ..
,

. , , ,

. ,
. ,
. , , .

[20], [140], [186], [200] [281].

19.5.
Oracle
OracleSi [237].
Oracle
, 19.2. , .
19.

713

Oracle ,
.
, Oracle , , . ,
- ,
, ,
. . ,
Oracle: , .
Oracle 8.2.

19.5.1. Oracle
6.5 ,
. Oracle , ISO SQL
(READ

COMMITTED SERIALIZABLE).

READ COMMITTED. (
).
, ( ). , , ..
.
SERIALI2ABLE. , ,
,
,
INSERT, UPDATE DELETE.


, ,
. , ,
,
. , READ
COMMITTED .
SERIALIZABLE, , ,
. .
, Oracle , .
READ ONLY. ,
, , .
Oracle ALTER SESSION SET TRANSACTION SQL.

714

V.

19.5.2.

Oracle. ,
,
(System Change Number SCN) .


Oracle, .
Oracle
. ,
. , ;
.



Oracle (SCN),
, . Oracle
SCN
. SCN
,
. SCN , ,
, .

SQL, - .
Oracle , , , .
, .
,
Oracle ,
.
19.2,
. , ,
SQL . ,
,
.
,
, ,
,
19.

715


. Oracle
,
.
Oracle , . >
DDL. ,
.
DML. ; , ,
.
. .
. , , .
. .
. (Parallel
Cache Management )
.

19.5.3.
Oracle
, . , , . , ,
,
, .

19.5.4.
Oracle
, .
, . Oracle [237].


Oracle (Recovery MANager RMAN)
,
, :

;

;
;

.
716

V.

RMAN .
, .


Oracle Oracle ,
; .
Oracle , 19.3; ,
. Oracle
,
(INIT.ORA), , .


Oracle

(SCN).
, -
(, ). Oracle , ,
, .


Oracle . , Oracle
( )
.
.
, .

,
.
,
.
, .

19.

717

( ), ,
. ,
.
() ().
.
.
, ACID (Atomicity, Consistency, Isolation, Durability
, , , ).
,
.
, .
,
.
, , . . ,
.
, , . ( ) ( ). ,

.
, .
, , .

.

, ,
.
.
,
, . , -
, .
,
, , , .

/ . .
718

V.

, /
.
,

.
, . - .
, . ,
.

.
, .
, .
, , , .

19.1. ? ?
19.2. ,
(ACID) .

.
.
19.3. ,

.
19.4. ,
,
19.3.
?
?
19.5. , . .
19.6. ?
19.7. ?
19.8.
?
.

19.

719

19.9. .
,
, , ?
19.10. , .
, .
19.11. .
19.12.
?
19.13. , .
?
19.14.
? ,
, ,
. ?
?
19.15. .
19.16. :
) ;
) ;
) ;
) .

19.17. , .
? ? -
, 19.4?
19.18. , , , . , ,
a) readd1!, bal x ) , read{T 2 , balj , w r i t e ( T l f balj ,
write (T 2 / bal*)
commit (T a ) , commit ( T 2 ) ;
) read{T 1 ( bal x ) , read(T 2 , bal y ) , write (, bal x ) ,
readd2/ ba.lx} , read (T^ bal y ) , commit () , commit (T2);
) read(T 1 ( bal x ) , w r i t e ( T 2 , bal x ) write (Tlr balx) ,
abort (T 2 ) , commit di);
) write (T!, balj , read(T 2 , bal x ) , write di, bal x ) ,
commit (T 2 ) , abort (Tj ;
e) readd!, balj , write(T 2 , bal x ) , write{T l f bal x ) ,
read(T 3 , bal x ) , commit (TJ , commit (T 2 ) , commit (T 3 ).

720

V.

19.19. (-), .
19.20. .
) ,
? , , :
S = [R,(Z), R 2 (Y), W 2 (Y), R 3 (Y), R^X), W a (X), W^Z), W 3 (Y), R2(X), Ra(Y), W^Y),
W 2 (X), R 3 (W), W 3 (W)]

R i ( Z ) W i ( Z )
() 2 1;
) , ? .

?
19.21.
, .

13

Xg

X4 r X j

* 4

Xy

Xj

i6

X 4 , Xi>

Xg

19.22. . ?
19.23. ,
.
19.24. , 19.1-19.3,
,
.
19.25. . 19.5 (Venn),
, , , . ,
.
, ,

.
19.26. ,
? ?
19.27. ,
?
19.

721


...

.
.
.
,
.
.

.
,
.
.

.

.
.
.
Oracle.

,
, .
, . ,
,
.

-
, COBOL. 5 .
1 , ,
3QL, , , , . -

,
. , - ,
. ,

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


20.1 , 20.2 , . ,
, , ,
. 20.3 , ^
,
. 20.4 ,
.
,
.
20.5 , .
, , . Oracle.
, , .
,
. ( 23.7) !

27.5 , !
-*
, , i
, .
, !
, 4.1,
, . ,
Dreamttome,
10,4 .
724

V. ;

20.1.
: . , .
, ( SQL), ,
, . .
. .
.
,
, .
, [270].
, ,
[307].
, [162]. '
,
.
. . , .
, , ,
(. ). . , ,
. , , (,
), .
: . 20.4.1.


.
20.

725

I 20. 1 .
,
SQL :
SELECT *
FROM S t a f f s,

Branch b

WHERE s.branchNo = b.branchNo AND


(s. position = 'Manager' AND b.city = 'London');
, :
1- Ofposition^'Manager1 ) (city** ' London1 ) (Staf . branchNo. Branch . bcanchNo) \ Staf f X
2-

" (position- 1 Manager ' ) (city. ' London' ) ( S t a f f

3.

(CTposicion, 'Manager' ( S t a f f

X S caEE . branchNo-Brench . brnnchKo

Branch)

X s t a f f .branchNo>Hranch.branchWo Wcity- ' London' () )

, ,
Staff 1000 , Branch 50. ,
50 ( )
.
,
. ,
- , .
, . ,
( , , ,
), ,
,
.
Staff Branch, (1000+50)
, (1000*50) . (1000*50)
, .
:
(1000 + 50} + 2* (1000 * 50) = 101 050

staff
Branch branchNo, 10004-50
. , 1000
(
).
1000
, :
2*1000 +

726

{1000 + 5 0 )

= 3 050

V.


Staff , , 1000 .
50 . Branch , . 50 . Staff Branch, 50+5
. , :
1000 + 2 * 5 0 + 5 + (50 + 5) = 1 160

, ,
87 .
Staff 10 000,
500,
870 ! , ,
.
,
. ,
,
, .
:
( ), , , . 20.1.
20.2 , . .

.



. . , .
, ,

. , , .
,
,
.
; , .
- 1 .
,
" 20.

727


( SQL)

. 20.1.

.
. , , , .
,
, ,

.
.
, .

20.2.
.
i
*
.
, , .
728

V. ;

1.

, [2]. , .
, ,

. , :
SELECT StaffNumber
FROM Staff
WHERE position > 10;

.
1. StaffNumber,
Staff ( staffNo).
2. WHERE "> "
position, .

,
. , . .
- ( )
.
, .
.
- .
. 20.2 , SQL,
20.1. .
.

2.

,
. ( SQL WHERE),
,

Staff

b.eity.'London'

Branch

. 20.2.

20.

729

.
[181].
.
, (AND). ,
v (OR). :
(position 'Manager' v salary > 20000) branchNo = '

, ,
, .
.
, v (OR),
,
(AND). , :
(position == 'Manager' branchNo = ' ' ) v
1
(salary > 2 0 0 0 0 branchNo = ' }
, ,
, .

3.
,
. ,
. , . ,
. , Staff (position = 'Manager'
position = 'Assistant') , (Manager),
(Assistant). ({position = 'Manager 1 position =
'Assistant') v salary > 20000) (salary >
20000),
FALSE. ,
.

, .
.
1. [327]. , .
yaej
,
.
,
.
2. [263]. rpatj
, ,
.
-i
730

V. ;

0. , ,
0, . -> , , ( < b + ), 0 -> -,
( > ).

I 20.2.
SQL:
SELECT p.propertyNo, p.street
FROM Client . Viewing v, PropertyForRent p
WHERE c.clientNo = v.clientNo AND c.max_rent >= 500 AND
c.prefType = ' F l a t ' AND p.ownerNo = ' C 0 9 3 1 ;

(. 20.3, ) . , . , (v.propertyNo = p.propertyNo).

. 20,3, :
) ; )

" 20.

731

:
SELECT p.propertyNo, p.street

FROM Client c, Viewing v, PropertyForRent p


WHERE c.max_rent > 500 AND c.clientNo =
v.clientNo AND v.propertyNo =
p.propertyNo AND c.prefType = ' F l a t 1 AND c.max_rent < 2 0 0 ;


. 20.3, . .maxRent 0,
, , , . ,
,
500 200 .

4.

, ,
. , , .. ,
.
, . ,
, :

() =

false = false
true =
(~) = false
( v q) =

() =

false =
true = true
(-p) = true
{ q) =

v
v
v
v

, ,
:
CREATE VIEW staffs
AS SELECT staffNo, fName, IName, salary, branchNo
FROM Staff
WHERE branchNo = 'B003';
SELECT *
FROM staffs

WHERE (branchNo = 'B003' AND salary > 20000);


, 6.4.3,
:
SELECT staffNo, fName, IName, salary
FROM Staff
WHERE (branchNo = '' AND salary > 20000}
AND branchNo " B O O S 1 ;

732

V. ;

WHERE (branchNo =
' AND salary > 20000).
. , , , Manager
20000 :
CREATE ASSERTION OnlyManagerSalaryHigh

CHECK ({position <> 'Manager' AND salary < 20000)


OR (position = 'Manager 1 AND salary > 2 0 0 0 0 } ) ;

, :
SELECT *
FROM Staff
WHERE (position = 'Manager' AND salary < 1 5 0 0 0 ) ;

, WHERE , 15000 ,
, .

5.
, .
.

20.3.

,
, . , 20.1 ,
, , . 20.3.1 , ,
, . , , 20.3.2 : ,
'. , .

20.3.1.

,
, . () , . 20.

733

[3].
R, S ,

R = { 1( 2 , > } S
= { 1( , ..., }. , q , , L l f L 2 j M, MI, 2 N
.
1.
( ).

<Wr(R> = o p (o q (o r (R)))
. :
-'' salary>15QOQ ( S t a f f )

ObranchNo- ' ' ( salary>15000 ( S t a f f ) )

2. .
0p(Oq(R) ) = Oq(Op(R))

:
a

O~branchNo-'BOOV ' ealacy>15000 ( S t a f f ) )

= O B a i a r y>iSOoO (ObranchNo- ' 0003 ( S t a f f ) )

3.
.
... (> = 0 L ( R )
:
1'lNamellbranchNo, name ( S t a f f I

= 1 11Narae ( S t a f f

4. .
, ,
:
1 ..... ^(OptRn-Opdl^ ..... fi m {R}> { 1( ,..., ^}
:
HfName.lName (^lName= ' Beech' { S t a f f ) )

- 'Beech' (HfName, IName I S t a f f ) )

5. - ( ).
R Xp S = R
R X S = S X R

-, .
, staff
Branch :
Staff

X s t a i f .branchNorBranch.branchNo

Branch

Xst a Et.branchNo. Branch. branchNo

Staff

6. - ( ).

, ( ;
) :
734

V. ;

O p (R Xlr S)

= {0 P (R}) XT S

Op{R x S) = ( a p ( R ) ) x s
{A 3 f A 2 , ..., A n }
,
( q), R, q
S, - :

<Vq(R XT s) = ( a p ( R ) } xt C a g ( S ) )
cWR x s) - ( o p ( R ) ) x (o q ts)}
:
1

^position- Manager' city.' London'


a

Bj

t c

Mana

( jo - i *i"'

er

9 '

(Staff) )

(Staff

Xscf t .branchNtwBranch.branchMo

>< sta.brancHto.aranch.branchN3

(Ocity.'LDJoii'

Branch)

(Branch) )

7. - ( ).
L = L3 u L2,
LI R, L2 S, , L, -
:
:
Hposition.city.branchNo ( S t a f f
(llpositioti,branchtfo (Staff } )

><

Staff.branchNo=Branch.branchNo

X staff -branchNo=Branch.branchtto

Branch)

\llcity, UranchNo '

,
L, = M! u 2, R, 2 S,
:
:

f ~ f ^*<*1
''^!'4}-! ^
position, cicy l^LdiO. '-"^staEE.branchNO'Branch-branchMo ci.eiiii.il/

Imposition, city ( \llpoaition, branchNo ( S t a f f ))

^^staf .branchNo-Branch.hranchWo

(licity,

(Branch)) )
8. (
).
R U S = S U R
R S = S R

9-
(, ).
CF p (R U S)

CTp(S)

U Cp(R)

O p (R S) = Op(S) O p (R}
C p {R - S) = C p (S) - O p ( R )

" 20.

735

10. .
u s ) - n L ( s )
11. - ( ).
:
(R !>< S) ><1 = R X (S X }

(R X S) X = R X

(S X )

q S ,
- :
(R S) ^

= R ixfe (S IXq )

:
Staff

t^staff-staffNo=PropertyForRent . ataffNo

PrOpertyForRent) ><UnerNC-owner.owr.erNo Staff.IKame^Owner.lKarre Owner


=Star

t ^ s t a f f - s t a f f M o ^ P r o p e r t y F o r R e n t . s t a f f N o Staff.lName=lName

(PropertyForRent

xWierno Owner)

,
,
( S t a f f . IName) PropertyForRent Owner:
PropertyForRent >^ r0 pertyForReiit.cwnerNo=Qwner.ownerNo Staf.lBame=Owner lHame Owner

12. ( ).
(R U S} U = S U

(RUT)

{R S) = S

(ROT)

20.3.

, , ,
' '.
SQL :
SELECT p.propertyNo, p.street
FRQM Client c. Viewing v, PropertyForRent p
WHERE c.prefType = ' F l a t ' AND c.clientNo = v.clientNo AND
v.propertyNo = p.propertyNo AND
c.max_rent >= p.rent AND c.prefType = p.type AND
p.ownerNo = ' C 0 9 3 1 ;
, , ''
. SQL :
736

V. >

Jlp.propertyNo.p.street .prefType ' F l a t ' .clientNo-v.clientNo v.propertyNop.propertyNo


c.raax__Eent >-p.rene .prefTypep. type p.ownerfto-'31

I \C

VJ

X p) )

, . 20.4, .

.
1. . 1, , .
. 2 6, .
. 20.4, .
2. , 4.1.3,
,
, :
a R . aiS . b (R x S) = R >< R . aiS . b s
. . 20.4, .
3. 11, , p.ownerNo = ' ' ,
20.4, .
4. 4 7, , , .
. 20.4, .
,
, ,
.prefType=p. type
p.type = ' F l a t 1 ,
.pref Type= ' F l a t ' . , .
, . 20.4, .

" 20.

737

"

. p,itr*M

"*

/\ '

/\.

a)

6)

Q.cuntNe-v.oUintND

L
i
_Z ii_ _2 L..
aprtlTyp*

jLL~ *_J!L;L-n_lL.L
/

/ \ \

(Mint, P-typ*

v.dbntNo

parent

e)

/ \ \

J.4.
20.3: ) ; )
, ; ) , / ; ) ,
; ) ,
; ) , c.prefType =
'Flat' p. type

738

V.

20.3.2.

. ,
.
1. .
. 1 ,
2, 4, 6 9,
. ,
. ,
, .
2. , .
,
-;
OR. 0 s . b ( R X

S)

R . 0 s . b S

3. - , - .
,

. , :
(R Xfe. a e s.b S)

Xls.c 0 T . d

11 12,
- (
). ,
, .
.
4. .
, ,
, . 3 ,
4, 7 10, .
( ). ,
, .
5. .

, ' 20.

739

. , , ,
.
, .
23.7 ,
. 27.5 ,
- , ,
.

20.4.


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

20.4.1.

, . , , .
R
nTuples ( R ) , () R (.. ).
bFactor(R). R (..
R, ).

740

V. )

nBlocks ( R ) . , R, R
, :
nBlocks(R) = [nTuples{R}/bPactor(R)J
R
nDistinct A (R). R.
min A (R) , max A {R). R.
SC a {R). R. , , . ,
R
,
, SC A (R) , . 20.1.
20.1.
R

SC A {R) =1
SCA(R) = [nTuples {R}/nDistinct A( R) ]

R

R

, . SC A {R) , . 20.2.
20.2.
R

SC A (R) = [nTuples ( R ) * ( (max A (R) -) / ( m a x A ( R ) minA(R)) ]

(>)

{ ) tnTuples(R) * { (c-max A (R) ) / ( m a x A ( R ) min A (R))]


s c f t ( R ) = [ ( n T u p i e s ( R ) / n D i s t i n c t A ( R ) } *n]

(<)

{A in

S C A ( R ) = s c A ( R ) *SC B (R)
sc A (R)=sc A {R)+sc B {R) -sc A (R)*sc B (R)

{Ci,c2,...,cn})

( )
(A v )

I
nLevels ft ( I ) . I.
nLf Blocks A {I). - I.

. , ,
20. .

741

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

20.4.2. (S = ap(R))
4.1.1,
, R.
S, R,
. , R , . ,
,
(AND), v (OR) - (NOT). , , , , . , .
( , ).
( , ).
.
, .
, .
, () .
, () .
, ^-.

. 20.3.
20.3. -

(
)

[nBlocks(R)/2]
;
nBlocks(R)

(
)

[log:(nBlocks{R)} ]
;
[loga(nBlocks(R) ) ] + [SC A (R)/bFactor (R)
-1

1
nLevelsA(I) +1

nLevels A (I)+ [nBlocks (R)/2]

742

V.

. 20.3


()
()
*-

nLevelsA(i) + [SCA(R) /bFactor ) ]


nLevelsA(l) + [SC A (R) ]
nLevelsA(I) + [nLfBlocksA(l) /2+
nTuplea (R) /2]



,
S, R. . , ,
, :
nTuples(S) = SC A (R)

( )

* S nDistinct a (S)
:
nTuples (S), nTuples (S}< nDistinct g (R}/2;
[(nTuples (S) + n D i s t i n c t a ( R ) ) / 3 ] ,
nDietinct s (R)/2 nTuples {S) <> 2*nDiatinct B ( R ) ;
nDistinct B {R), nTuples (S) > 2*nDistincC B (R).
,
, , [251],
Oracle 20.6.2.

1. ( )

, . , 20.1.
.
, ,
.
[nBlocks(R}/2]
,
, :
iBlocKs(R)

" 20.

743

20.1.

// .
// predicate - .
// . ,
// 1. ,
// R, predicate
//
for i = 1 to nBlocks(R) {
//
block = read_block(R, i) ;
for j 1 to nTuples(block) { // i
if (block.tuple[j] predicate>)
then < >;

2. ( )
(=) ,
R,
:
[log 2 (nBlocks(R) ) ]
20.2. :
[logj(nBlocks(R) )] + [SC A (R}/bFactor(R)] - 1
,
. , SC A (R) , [SC & (R) /bFactor (R) ] ( ,
.
20.2.

// .
// predicate - .
// .
// nBlocks , ,
// 1. (found),
// , ,
// , ,
//
next = I; last = nBlocks; found = FALSE; keep^searching = TRUE;
while (last >= 1 and (not found) and (keep_searching) ) {
i = (next + last) /2; //
block = read_block (R, i) ;
if (predicate < ordering_key_field(first_record (block) ))
then
//
last = i - l f
else if (predicate > ordering_key_f ield(la.st_record (block) ))

744

V.

then

//
next = i + 1;
else if (check_block_for_predicate(block, predicate, result))
then
//
found = TRUE;
else
//
keep_searching = FALSE;

3.
, . , 1.
, , ,

4.
(=), , , .
,
, .
:
nLevels A (I) + 1

5.

(<, <=, >, >=), , =. , , .
, ,
.
:
nLevels A { I ) + [nBlocks ( R ) /2 ]

6.
()
,
, , . :
nLevels f t (I)+ [SC A {R) /bFactor (R) ]

20.

745


, , , SC A (R) .

7.
()
,
, , . , ( ). :
nLevels A (I) + [ S C A ( R ) ]

8.
*-
(<, <=,
>, >=), +-, < <= - , > >= . ,
- .
:
nLevels A (l) + [nLfBlocks A (I) /2+nTuples ( R ) /2]
+-
20.3.
20.3- *- ,

//
//
//
//
//
//
//
//
//
//
//
//

+-.
+- ,
, . -,
: , .
: (key) ()
(, NULL) .
: key! <: key 2 < key3 < ... < keyn.!.
- .
predicate - .
(found) , ,
,
(return_address) ,

//

node = get_root_node (} ;
while (< ->) {
1=1;
// ,
while (not (i > n or predicate < node [i] .key) } {
i = i + 1;

746

V.

node = get_next_node(node[i) .p) ; // node[i].p ,


//
// - . ,
//
1-1;
found * FALSE/
while (not (found or i > n)} {
if (predicate = node[i].key)
then {
found = TRUE;
return_address = node[i].p;
}
else
i = i + 1;


, .
, , . 20.2 , .
, .
, , .

, .
1. , , ,
2-8, .
.
2.
( ), ( ).
, .
3. , , , ,
, ,
,
. , ,
.
,
.
20.

747


v (OR)
, ,
. , , ,
20.4.5, . ,
, .

,
. ,
.

20.4.
staff .
( staffNo)
, .
branchNo,
.
+- Salary.
s t a f f , . 20.4.
20.4. Staff,
,

n T u p l e s ( S t a f f ) =3000
b F a c t o r ( S t a f f ) =30

nBlocks(Staff)=

100

nDistinct b r a n chNo(Staf f ) = SOO

SCbranchM ( S t a f f ) = 6

nDistinct p D ! ! i r ion(Staff) = 10

SCpo.itionfStaff)

nDistinct E a l a r y (Staf f ) = 500

SC B a i a c y(Staff) = 6

= 300

min s a i a c y (Staf f ) = 10000


max s a i a t y(Staff) = 5 0 0 0 0
nLevelSbranchNo(I) = 2
nLevels s a i a i y ( I ) = 2
nLfBlocks s a l a r y (I) -.= 50

s t a f f N o 50
, () 100 . -

748

V.

;
S1 <7 8 t a ffNo,' S G5< ( S t a f f ) ;

S2

S3

^posiCion-'Manager1 ( S t a f f ) ;

Obranehuo.'' ( S t a f f ) ;

S4 O sa i arys20 ooo ( S t a f f ) ;

CJposition-'Manager' branchNo.'BOOJ' ( S t a f f ) .

1.
. staffNo , ,
, 1 .

:
SC.t.f , (Staff )*1,
2. , , 100
. :
SCposltioil ( S t a f f ) =300.

3. , , ,
. , : 2+ [6/30] =3 . : SC braneh! j 0 (Staff )=6.
4.
Salary.
+-, ,
: 2 + [50/2] + [3000/2] =1527 .
, ,
.
:
SCaalary ( s t a f f } = [3000* (50000-20000) / (5000010000)]=2250.
5. ,
branchNo.
S3, 3 .
,
(position^ 'Manager'). , : SCbrar.chNo ( S t a f f ) =6.
,
position .
: r>istinctpaBitian(T) = [ ( 6 + l Q ) / 3 ] =6. , : ^^ () =6/6=1, , DreamHome
.
20.

749

20.4.3. (T=(R txF S))


, , , . ,
,
( ). . 4.1.3, - , ,
F, ,
, R S. F R. a 0 S ., 0
.
(=), . R S,
.
.
.
.
-.
.

[219].
. 20.5.
.
20.5. -

nBlocks(R)-(nBlocks(R)*nBlocks{S))


n B l o c k s { R } + [ n B l o c k s ( S ) * (nBlocks
(R}/(nBuffer-2))]
nBlocks(R)+nBlocks{S}


R s

(nBuffer-2)

,
R

,
:
nBlocks(R)+nTuples{R)*(nLevels f t
(D+l)

750

,

s

V.

. 20.5

nBlocks{R)+nTuples(R)*{nLevelsA
<I) + lSCA(R)/bFactor(R)]>

n B l o c k s ( R ) * [loga { n B l o c k s ( R ) ] 4
n B l o c k s ( S ) * [logs (nBlocks(S)]

nBlocks(R)+nBlocks{S)

3{nBlocks{R)+nBlocks ( S ) )

2 ( n B l o c k a ( R ) + n B l o c k s ( S ) ) * [lognBu
ffer-1{nBlocks(S))1]+nBlocks(R)+nBlocks(S)


R S, RXS,
:
nTuples(R) * nTuples(S)

,
,
. , ,
nTuples(T) nTuples(R) * nTuples(S)
, . , ,
(R.A = S . B ) .
1. R,
S R. ,
S:
nTuples(T) < nTuples(S)
2. , S,
nTuples(T) < nTuples(R)
3. , , :
nTuples(T) = SC A (R)*nTuples(S)

nTuples{T) = SC B (S)*nTuples ( R )
, s S SC A (R) 20.

751

R .
S, .
,

1.

,
.
R,
S. , ,
, ,
, ,
, 20.4.
20.4.
// .
// , 1.
// R S
//

for iblock = 1 to nBlocks(R) {


//
Rblock = read_block(R, iblock};
for jblock = 1 to nBlocks(S) {
//
Sblock = read_block(S, jblock);
for i = 1 to nTuples(Rblock) {
for j = 1 to nTuples(Sblock) {
if (Rblock.tuple[i]/Sblock.tuple [j]
< >)
then < >,-

R ,
S R,

nBlocks(R) + (nBlocks(R) * nBlocks(S))
, ,
,
. ,
,
.

(, R) . 752

V.

nBuf fer ,
nBuf fer-2 R S. R - nBlocks ( R ) , S [nBlocks (S) * (nBlocks (R) / (nBuffer-2) ) ] .

:
nBlocks(R) + [ n B l o c k s ( S J * { n B l o c k s ( R ) / ( n B u f f e r - 2 ) ) ]
R,
:
nBlocks(R) + nBlocks(S)
( ) ,
, .

2.


( -),
. R
S . 20.5.
,
. ,
R, .
(. 20.19).
20.5.

/ / R S ,
// .
, I S,
I [1] , 1 [ 2 ] , ... , I [m]
t I

R [ i ] . A .

// R , 1.
// R S
for iblock = 1 to nBlocks(R) {
Rblock = read_block(R, iblock);
for i = 1 to nTuples(Rblock) {
for j = 1 to ra {
if ( R b l o c k . t u p l e [ i ] . A = I [ j ] )
then < >,}

" 20.

753

,
R S. R nBlocks(R),
.
S
, . , S ,
nBlocks(R) + nTuples(R) * (nLevels A (I) + 1)
S , :
nBlocks(R) + nTuples{R)*(nLevels A (I) + [SC A (R) /bFactor (R) ] )

. -
, . R 5, . ,
.
, ,
, . , " ", .. , ,
,

. -

nBlocks(R) + nBlocks(S)
(, R) , ,
:
nBlocks ( R } * [log 2 (nBlocks(R}]
-
20.6.
20.6. -
//
//
//
//
//
//

R S .
" ".
. R S
{ ,
, )

Sort (R) ;

sort (S) ;
//
754

V.

nextR = 1; nextS = 1;
while (nextR <= nTuples(R) and nextS <=nTuples(S)) {
join_value = R.tuples[nextR].A/
// S ,
// , ,
while (S.tuplestnextS].A < join_value and nextS <= nTuples(S))
nextS = nextS + 1;
//
//
//
//

, R S.
S join_value
R
join_yalue. ( M:N)
while (S.tuples[nextS].A = joinjvalue and nextS <= nTuples(S))
m = nextR;
while (R.tuples[m].A * join_value and ra <= nTuples{RJ) {
S.tuples[nextS]
R.tuples[m] >;
m m -f 1;
}
nextS - nextS + 1;

}
// R S
// join_value. R
// join__value
while {R.tuples[nextR].A = join_value and nextR <= nTuples(R))

nextR = nextR + 1/
}

4.
( ) R
S . : ,
, R
S -,
. R S
,
.
. , R - h (^ R l f R 2 , ..., ^,, S
slt S2, -, Sm, R S
, a h (R.B)^h (S . ) , R.B^S.C. h ( R . B ) =h{S. ) ,
, R.B=S.C, .
, ,
R S.
20.

755

,
, RJ.. RI ,
Si RI. - R A -, ,
. 20.7.
:
3{nBlocks(R) + nBlocks(S) }
R S
, R S . ,
. , , - . , .

2(nBlocks(R)+nBlocks(S) )*[lognbuffer-l{nBlocks(S) ) - l ]
+nBlocks (R) +nBlocks (S)
20.7.
// ..
//
//

// R S
for i = 1 to nTuples (R) {
hash_value = hash_function (R. tuple [i] .A);
R. tuple [i] - R,
hash value>;
1
for j = 1 to nTuples (S) {
hash_yalue = hash_f unction (S .tuple [j ] .A) ,< S. tuple [j ] . S,
hash value>;
}
// ( )
for ihash = 1 to M {
R,
ihash>;
RP = Rpartition [ihash] ;
for i = l to 'nax_tuples_in_R_partition (RP) {
//
// hash_function2 () , hash_f unction ( )
new__hash = hash_funct:ion2 (RP. tuple [i] .A) ;
new_hash ,
>;

756

V.

// S
// R
SP = Spartition[ihash];
for j = 1 to max_tuples_in_S_partition(SP) {
< S -
h a s h _ f u n c t i o n 2 ( S P . t u p l e [ j ] . A > ) ;
< >;
< -
>;

[101], [102], [307] . ,


, [272]; [97]
, .

20.5.
.
, -
staffNo Staff branchNo Branch.
100 .
,
. 20.6.
20.6. , ,

nTuples (Staff ) = 6000


bFactor (Staff ) = 30
nTuples (Branch) = 500

nBlocks (Staff ) = 200

bFactor (Branch} = 50

nBlocks (Branch) = 10

nTuples (PropertyForRent) = 100000


bFactor (PropertyForRent) = 50

nBlocks (PropertyForRent) = 2000

. 20.7
, :
Staff t> staE fKo PropertyForRent;
J2 Branch >brancMto PropertyForRent.
,
,
. , .
20.

757

-, .
.
20.7. - ,
20.5

400200

20010

4282

nBuffer - 2
R

2 010

6 200

510

25 800

24 240

2 200

2 010

6 600

6 030

.
* R .
* R .

20.4.4. (S = * .., (R))


, S,
R,
. , .
1. .
2. ,
.
, ,
, .
: .
, .

758

V.


,
, :
nTuplea(S) = nTuples (R)
(S = ()),

nTuples (S) = SC A (R)
, ,
(, , ),
:

nTuples{S) < min (nTuples (R) , ,rinDistinct A (R) }


i=l

1 .
. , .
R
. nBlocks (R) . nBlocks (R) * [Iog2 (nBlocks ( R ) ],
:
nBlocks ( R ) + nBlocks (R) * Elog 2 (nBlocks (R) ]
20.8.
20.8.
// .
// R 1( 3, ..., .
// S
//
//
for iblock = 1 to nBlocks (R) {
block = read_block (R, iblock);
for i = 1 to nTuples (block) {
copy block, tuple [i] .a.lf block, tuple [i] . a2, s, block, tuple [i] . amj
to output
}
// ,
if {1( a2, s, am} < >
then
S = ;
else {
20.

759

sort(T);
// ,
i =1; j = 2;
while (i <= nTuplea{T)} {
output T[i] to S;
// ,
while ( [13 T[j]) {
j = J + 1;
\

. )

i = j; J = i + 1 ;

2.
, . R . : , .
R, (nBuffer-1)
. R , h ( ) . - h ( ) ,
(nBuffer-l) .
, , , - . . :
(nBuffer-1)
;
( ) 2 ();
-, ;
- ,
, ,
, , ;
- .
, ,
R
, nb,
nBlocks(R) + nb
,
, . ' .
760

V.

20.4.5.
(T=RuS, T=RnS, T=R-S)
,
(RuS), (RnS) (R-S),
, (..
), 4.1.2,
. ,
, , .
, .
R, ,
S.
, -.
:
nBlocks{R)+nBlocks(S)-fnBlocks(R)* [loga (nBlocks (R) ] -t-nBlocks (S) *
[log 2 (nBlocks{S}]
, . ,
R S,
. .


,
,
:
max(nTuples{R), nTuples(S)) < nTuples(T) < nTuples(R) + nTuples(S)


< nTuples(T) < nTuples(R)
SQL, :
SELECT AVG(salary)
FROM Staff;

AVG ( ).
S t a f f Salary.
.

20.

761

SQL,
:
SELECT AVG(salary)
FROM Staff
GROUP BY branchNo;
B AVG,
.
, .
, .
( ) .

20.5.
() , ,
( ).
, .
.
, . , .
, 20.4.2 :
O"poeition-'Manag*r' ealary?200DO ( S t a l l

, Salary ,

:
Opoaition-'Manager 1 ( C salary>2DOOO { S t a l l


Salary;
, , .
, . , , .

, .
.
,
, . ,
762

V.

.
. ,

, -.
.


, , , . 20.5, . ( ).
, . , "" , ,
,
.
,
. ,
. 20.5, , , . 20.5, [134].
, - . . 20.5, (
), - .
,
. , , . ,

( ).
:

. ,
- , ,
, .
, System R [270].
, , .. , .

20.6. Oracle
,
Oracle Si [241].
, .
27.5 Oracle , , . Oracle,
.
Oracle 8.2.

20.

763

04

EX

/ \D

/\

A
A

a)

A
A
w

6)

/\

' A

/\ /\

. 20.5, : ) ; ) ; )
; ) ()

20.6.1.
Oracle , : .


Oracle ,
(. 20.8). ,
( ), . , , ( ) .
, Oracle
SQL,
.
, PropertyForRent
, (propertyNo),
rooms city:
SELECT propertyNo

FROM PropertyForRent
WHERE rooms > 7 AND city = 'London';

764

V.

20.8.

1
2
3


ROWID (ROW IDentifier )

4
5

6
7

9
10

11

12
13

-
MIN

14

ORDER BY

15


.
city,
WHERE (city = ' London'}. 9.
rooms, WHERE (rooms > 7 ) .
11.
,
SQL. 15.
propertyNo ,
WHERE
.
city.


Oracle
, Oracle 7. , ( , ). ,
;
20.

765

QPTIMIZER^MODE. , ( ).



, , .
Oracle ; .
, , ,
DBMS_STATS
PL/SQL. Oracle
,
. ,
Manager SQL:
EXECUTE DBMS_STATS.GATHER_SCHEMA_STATS('Manager');

. , ,

. ,
, .
.
, .
,
,
.

. , , 10% , .
Oracle
. COMPUTE STATISTICS CREATE INDEX ALTER INDEX. Oracle,
, . 20.9. .
ALL_
, ,
, .
D3A_
.
USER_
.
766

V.

20.9. Oracle

ALL_TABLES

TAB_HISTOGRAMS

TAE_COLUMNS

TAB_COL_STATISTICS
TAB_PARTITIONS

,
,

INDEXES

IND__COLUMNS

CONS__COLUMNS

CONSTRAINTS

LOBS

LOB {Large OBject


)

SEQUENCES

SYNONYMS

TRIGGERS

VIEWS

, ,
. SQL , , Oracle , ,
,
:
;
;
;
, f
-.
,
:
SELECT /*+ INDEX(sexlndex) */ fName, IName , position
FROM Staff
WHERE sex = ' M 1 ;

,
Staff , ,
, . , ,
Staff
20.

767

, , .
sex, . , sex.

,
SQL, , SQL. CREATE OUTLINE
, ,
. ,
, .

20.6.2.
,
. , , .
. , . 20.6, rooms
PropertyForRent, . 20.6, ,
.
: (1), (10) ( 100).
, rooms > 9, (1/10) *100 = 10 .
( . 20.6, , 1 ).

10

10 10

10 10 10 10

10 10

14 20 20 20

9 1 0

. 20.6. rooms
PropertyForRent: ) ; )

768

V.

, . . 20.7 :
, , (
), ,
;
, , ,

( ).
, , .
rooms, , . 20.7, .
( 1-2, 3-4 ..), ,
.
; , , , . rooms > 9.
, , ,
. , , , . 2*1 = 2;
, .
, , . 20.7, .
, 20 (100/5). ;
, , . rooms > 9, , ,
, ,
(1/5) *20 = 4. ,
, ,
. Oracle , .
20

20

20 20 20

20

10

1 2

20

II

4
40

II

6
28

II

8
8

9 10

ll_

91 0

. 20.7, rooms PropertyForKent:


) ; )

20.

769

, , , .
,
.
, SQL Server Microsoft, ,
. Oracle .
DBMS_STATS PL/SQL. ,
WHERE SQL .
rooms, .

20.6.3.
Oracle , , EXPLAIN PLAN.
,
. EXPLAIN PLAN (
PLANJTABLE). .
STATEMENT_ID. STATEMENT_ID, EXPLAIN PLAN.
OPERATION. . SQL (SELECT, INSERT,
UPDATE DELETE).
OPTIONS. ,
QBJECT_NAME. .
ID. , .
PARENT_ID. ID ,
ID.
POSITION. ,
PARENT__ID.
COST. ( , , NULL).
CARDINALITY. , .
20.9.
.
( , ID
).
20.9. EXPLAIN PLAN
SQL>
2
3
4
770

EXPLAIN PLAN
SET STATEMENTJ[D ='PB'
FOR SELECT b.branchNo, b.city, propertyNo
FROM Branch b, PropertyForRent p
V.

5 WHERE b.branchNo = p.branchNo


6 ORDER BY b.city;
Explained.
SQL> SELECT ID||( '|jPARENT_ID| ' '||LPAD(' ', 2*(LEVEL 1))||OPERATIONj |' '| jOPTIONS| J

2
3

' '||OBJECT_NAME "Query Plan"


FROM PlanJTable

4
5

START WITH ID = 0 AND STATEMENT_ID = 'PB'


CONNECT BY PRIOR ID = PARENT_ID AND STATEMENT_ID = 'PB';

Query Plan
0
1
2
3
4
5

0
1
2
2
4

SELECT STATEMENT
SORT ORDER BY
NESTED LOOPS
TABLE ACCESS FULL PROPERTYFORRENT
TABLE ACCESS BY INDEX ROWID BRANCH
INDEX UNIQUE SCAN SYS_C007455

6 rows selected.

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

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

20.

771


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

- , -
.
, . ; , ;
; ; .

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

, , . , .
,
.
.
, -
,
, , .
772

V.


20.1. ?
20.2.
,
?
20.3. ?
20.4. .
20.5.
?
20.6. ?
20.7. ,
:
a) ;
b) ;
c) -.
20.8. , .
20.9. ,
?
20.10.
?
20.11. ?
20.12.
?
20.13. . .
20.14. .

20.15. ,
20.1, , Staff 10 000
, Branch 500 , 500 ( ), 10 .
20.16. Hotel,
"" 3, , :
a)SELECT r.type, r.price
FROM Room r. Hotel h
WHERE r.hotel_number = h.hotel_number AND h.hotel_name = 'Gr
osvenor Hotel 1 AND r.type > 100;
6) SELECT g.guestNo, g.name

FROM Hotel h. Booking b. Guest g

WHERE h.hotelNo = b.hotelNo AND h.hotelName = 'Grosvenor Hot


-L

- ..

20.

773

a) SELECT r.rootnNo, h.hotelNo


FROM Hotel h, Booking b, Room r
WHERE h.hotelNo = b.hotelNo AND h.hotelNo = 'H21' AND b.room
No = r.roomNo AND
type = 'S' AND b.hotelNo = ' H 2 2 ' ;
20.17. Hotel, ,
20.3.2 .
a)SELECT r.roomNo, r.type, r.price
FROM Room r. Booking b, Hotel h
WHERE r.roomNo = b.roomNo AND b.hotelNo = h.hotelNo AND
1
h.hotelName = 'Grosvenor Hotel AND r.price > 100;
6)SELECT g.guestNo, g.guestName
FROM Room r. Hotel h, Booking b, Guest g
WHERE h.hotelNo = b.hotelNo AND g.guestNo = b.guestNo AND
h.hotelNo = r.hotelNo AND
1
h.hotelName = 'Grosvenor Hotel AND dateFrom >=
1
'l-Jan-01 AND dateTo <= '31-Dec-Ol';
,
.
20.18. Hotel
:
roomNo/hotelNo Room , ;
Room
hotelNo, ;
price Room +-;
Room type;
,
. 20.10.
20.10. ,

bFactor (Room) = 200
bFactor(Hotel) = 40
bFactor(Booking) = 60

nTuples(Room) = 10000
nTuples(Hotel) = 50
nTuples(Booking) = 100000
nDistincthocelNo(Room} = 50
nDistincttype(Room) = 10
nDistinctprlce(Rooin) = 500
tnin pl:lce (Room) = 200
nLevelshoCem0(I) = 2
iced) = 2

(Room) = 5 0
nLfBlockSprice(I) = 50

)
:
S1 OroomWol=i hoteiHo=Hi (Room);
S2 Ctype,1D. (Room);

774

V.

S3 ahoteiNosH3 (Room) ;
S4 CTprice>1{30 (Room) ;
S5 cjtype=,s, hoteiso- (Room) ;
S6 fft ^.fi. v price < 100

) :
Jl Hotel >< hoteiNo Room;
J2 Hotel >< hoteiwo Booking;
J3 Room ><

tclomNo

Booking;

J4 Room >< hoteiNo Hotel;


J5 Booking X hoteiNo Hotel;
J6 Booking ><\ ? Room.
) :
PI rihcteiNo (Hotel);

2 nho

4 ~
5 FThoteiNo,

price

(Room}.

20.19. 20.4.3
,
(nBuffer-2)
R .

20.

775

<


SQL

...
SQL
.

SQL.
,
SQL.
,
SQL.
ODBC (Open Database Connectivity
),
.
5 6 SQL (Structured Query Language
), , . 5.1.1
, SQL, 1992 , ,
:
, IF. . .THEN. . .ELSE, GO TO DO. . .WHILE.
SQL
,
SQL
. , , , . SQL , SELECT,
.
SQL
.
SQL. SQL . ,
. -
SQL -

.
. ISO SQL
ADA, , COBOL, Fortran, MUMPS, Pascal PL/1.
(API Application
Programming Interface). , . API-
, ,
. , ,
.
API- ODBC (Open
Database Connectivity ).
( Oracle, INGRES, Informix
DB2) SQL.
, Oracle API-;
Access API- (ADO ActiveX Data
Objects), ODBC.

SQL: SQL, , SQL


, SQL, SQL
. SQL ,
. SQL 21.1,
SQL 21.2. 21.3 ODBC, , SQL.
, SQL
, DreamHome, 10.4 . SQL
, 5.2.

21.1. SQL
SQL,
SQL,
, Oracle 8.
SQL,
Oracle ISO.

21.1.1. SQL
SQL ,
, ..
SELECT. INSERT, UPDATE, DELETE CREATE TABLE
( ).
778

V.

21,1. CREATE TABLE


vi ewing.
Viewing , Oracle
SQL:
CREATE TABLE Viewing (propertyNo
clientNo
viewDate
comments

VARCHAR2(5)
VARCHAR2{5)
DATE
VARCHAR2 ( 4 0 ) ) ,-

NOT NULL,
NOT NULL,
NOT NULL,

,
21.1.
21.1. SQL,
Viewing,
/* Viewing */
#include <stdio.h>
^include <atdlib.h>
EXEC SQL INCLUDE sqlca;
mainO
EXEC

SQL BEGIN DECLARE

SECTION;

char *username = "Manager/Manager";


char *connectstring = "DreamHome";
EXEC SQL END DECLARE
SECTION;
/* */
EXEC SQL CONNECT
:username USING :connectfitring;
if (sglca.sqlcode < 0) e x i t ( - l ) ;
/* */
printf("Creating VIEWING t a b l e \ n " ) ;
EXEC SQL CREATE TABLE Viewing (propertyNo VARCHAR2(5) NOT NULL,
clientNo
VARCHAR2{5) NOT NULL,
viewDate
DATE
NOT NULL,
comments
VARCHAR2(40));
if (sql'ca. sqlcode >= 0}
/* */
printf("Creation s u c c e s s f u l \ n " } ;
else
printf("Creation unsuccessful\n");
/* */
EXEC SQL COMMIT WORK RELEASE;

SQL,
, .
SQL ,
EXEC SQL,
ISO ( MUMPS 'OSQL'}.
, SQL.
/ 21. SQL

779

SQL , . Ada, PL/I (;). COBOL


' END-EXEC'.
Fortran .
SQL . .
SQL , .
(CONNECT, CREATE TABLE,
COMMIT DISCONNECT) , .
Oracle , COMMIT, DDL COMMIT .
COMMIT (. 21.1)
. , RELEASE, COMMIT, Oracle,
, .

21.1.2. SQL (SQLCA)


SQL (SQL Communication
Area SQLCA). SQLCA , . SQLCA , SQL - . 21.2 SQLCA
Oracle. SQLCA,
:
EXEC SQL INCLUDE sqlca,-

SQLCA. SQLCODE,
. S QLCODE
, .
SQLCODE , ( sqlwarn
).
SQLCODE
. SQLCODE
, .
SQLCODE ,
, , SELECT
( ).
780

V.

21.1 SQLCODE (sqlca.sqlcode < 0), CONNECT CREATE TABLE.


21.2. SQL (SQLCA)

/*

SQLCA (SQL Communications Area - SQL).

. Oracle SQLCA
SQL.
V
struct sqlca{
char
sqlcaid[8];
/* "SQLCA" */
long
sqlcabc,/* SQLCA */
long
sqlcode;
/* SQL */
struct{
short
sqlerrml;
/* */
char
sqlerrmc[70];
/* */
} sqlerrra;
char sglerrp[8]; /* */
long sglerrdfej,- /* sqlerrd[2] - */
char sqlwarn[8];
/* sqlwarn[0] "W" */
/* sqlwarn[l] "W", */
/* sqlwarn[2] "W",
NULL */
/* sqlwarn[3] "W"
*/
/* sqlwarn[4] "W"
UPDATE/DELETE WHERE */
/* sqlwarn[5J "W"
PL/SQL */
/* sqlwarn[6] */
/* sqlwarn[7] */
char sqlext [8]; /* */

WHENEVER

SQL. , SQL ,
Oracle
. WHENEVER ,

SQL.
WHENEVER :
EXEC SQL WHENEVER <condltion>.

21. SQL

781

WHENEVER (
condition) ,
( action). , ,
, , .
condition .
SQLERROR (SQLCODE < 0).
SQLWARNING (SQLCODE > 0).
NOT FOUND ,
.
action .
CONTINUE .
DO
.
, SQL, (
).
DO BREAK,
break. .
DO CONTINUE,
continue. .
GOTO label
, label.
STOP
.
, SQL:
EXEC SQL WHENEVER SQLERROR GOTO errorl;
EXEC SQL INSERT INTO Viewing VALUES ( ' C R 7 6 ' ,
1
Not enough s p a c e ' ) ;
EXEC SQL INSERT INTO Viewing VALUES { ' C R 7 7 ' ,

'Quite like it 1 ) ;

'PA14',

'12-May-2001',

'PA14',

'13-May-2001',

SQL :
EXEC SQL INSERT INTO Viewing VALUES { ' C R 7 6 ' , ' P A 1 4 ' ,
Not enough s p a c e ' ) ;
if (sqlca.sqlcode < 0} goto errorl;
EXEC SQL INSERT INTO Viewing VALUES ( ' C R 7 7 1 , 'PA14',

'Quite lilce i t ' } ;


if (sqlca.sqlcode < 0} goto errorl;

'12-May-2001',
'12-May-2Q01',

21.1.3.
,
. .
782

V,

SQL
. , WHERE
SELECT.
, . , , ,
.
SQL
(:). , ,
increment, , 1
'SL21 .
SQL:
EXEC SQL UPDATE S t a f f SET salary salary + :increment
WHERE staffNo = 'SL21';

SQL
, .
SQL BEGIN
DECLARE SECTION ... END DECLARE SECTION.
,
SQL. ,
, , :
EXEC SQL BEGIN DECLARE SECTION;
float increment;
EXEC SQL END DECLARE SECTION;
, SQL, .
SQL Oracle (. 8.2.3)
. 21.1. ,

SQL . ,
,
, .
21.1. Oracle
SQL Oracle
c h a r ( ) , varchar(n)


char [n + 1]

integerl, integer2, smallint

short

integer

int

integer

long

float4

float

float

double

date

char[26]

money

double

21. SQL

783




NULL (, 3.3.1). , NULL
.
SQL . , . .
,
.
, -1, ,
NULL.
,
, , (..
).
, (:). , NULL Address 1
021', :
EXEC SQL BEGIN DECLARE SECTION;
char address[51];
short addresslnd;
EXEC SQL END DECLARE SECTION;
addresslnd = -1;
EXEC SQL UPDATE PrivateOwner SET address = :address:addresslnd
WHERE ownerNo = ' C O 2 1 ' ;

, BEGIN DECLARE SECTION addresslnd short. addresslnd -1 ,


(address) NULL. UPDATE
address. Oracle INDICATOR .
, NULL,
.
SQLCODE .

21.1.4.
SQL
21.1.1 SQL,
.
784

V.

SELECT, ,
.
,
, , SQL . (. 24.2).
SQL , ,
.
SQL :
,
;
,
(, ).


SQL ,
SELECT, 5.3,
INTO,
, . INTO
SELECT. SELECT INTO . , 1
'21 :
EXEC SQL SELECT fName, IName, address
INTO :firstName, :lastName, ;address :addresslnd
FROM PrivateOwner
WHERE ownerNo = ' C O 2 1 ' ;

fName f irstName, IName lastName, address address ( NULL, addressInd).


,
, BEGIN DECLARE SECTION.
,
SQLCODE .
WHERE , SQLCODE NOT FOUND. , WHERE , NULL
, ,
SQLCODE ,
. , ,
, .
21. SQL

785

21.2.
,
, .

'

21.3. , . PrivateOwner . .
address,
NULL.
21.3.
/* PrivateOwner */
tfinclu.de <stdio.h>
^include <stdlib,h>
EXEC SQL INCLUDE sqlca?
main()
{

EXEC SQL BEGIN DECLARE


SECTION;
char ownerNo[6];
/*
*/
char f irstName [16] ,- /* */
char lastName [16] ,- /* */
char address [51] ,/* */
short addresslnd;
/* NULL */
char *username = "Manager/Manager";
char *connectString "DreamHome";
EXEC SQL END DECLARE
SECTION;
/* */
printf{"Enter owner.number: ");
scanf("%s", ownerNo);
/* */
EXEC SQL CONNECT
:username USING :connectString;
if (sqlca.sqlcode < 0} exit-(-I);
/* SQL
SELECT*/
EXEC SQL WHENEVER
SQLERROR
GOTO error;
EXEC SQL WHENEVER
NOT FOUND
GOTO done;
EXEC SQL SELECT fName, IName, address
INTO :firstName, :lastName, :address :addresslnd
FROM PrivateOwner
WHERE
ownerNo = :ownerNo;
/* */
printf("Name;
%s %s\n", firstName, lastName);
if (addreaslnd < 0)
printf("Address:
NULL\n");
else
print ("Address: %s\n", address) ,goto finished

786

V.

/* - */
error:
printf("SQL error %d\n", sqlca, sqlcode) ,goto finished;
done:
printf("No owner with specified number\n");
/* or */
finished:
EXEC SQL WHENEVER
SQLERROR
continue;
EXEC

SQL COMMIT

WORK

RELEASE;


, SQL
, . 8.2.5
PL/SQL, Oracle,
.
.
.
, ,
, . , FETCH, SELECT.
DECLARE CURSOR SELECT,
, cursorName
selectstatement. :
ISXEC SQL DECLARE "cursor^ame CURSOR FOR select Statement^'1

,
,
, 'SL41',
EXEC SQL DECLARE propertyCursor CURSOR FOR
SELECT propertyNo, street, city
FROM PropertyPo.rRent
WHERE StaffNo = 'SL41 1 ;
OPEN , , ; . Oracle
, .
SELECT , , , . OPEN
:
f E X E ' S Q L OPEN

21 . SQL

787

, , :
EXEC SQL OPEN propertyCursor FOR READONLY;

FETCH
. , .
[ EXEC /SQL FETCH
INTO {hostVariable,^iindicatorVartable]

[,

cursorName .
INTO
SELECT DECLARE CURSOR. ,
:
EXEC SQL FETCH propertyCursor
INTO :propertyNo, :street,

:city;

FETCH propertyNo
propertyNo, street
street .. FETCH
,
, , . ,
, SQLCODE NOT FOUND
( ).
,
, OPEN
, FETCH, , .
FETCH SQLCODE NOT FOUND.
CLOSE OPEN:
EXEC, SQL CLOSE.cursorName
cursorWame ,
. :
EXEC SQL CLOSE propertyCursor;

.
. 21.3.

21.3.
,
,
.

21.4. .
788

V.

. , , Prope rt ForRent
. ,
. , .
.
21.4.

/*
** ,
**
*/
^include <stdio.h>
^include <stdlib.h>
EXEC SQL INCLUDE sqlca;
main()

*/

EXEC SQL BEGIN DECLARE


SECTION;
char staffNo[6];
/* */
char propertyNo[6]; /*
*/
char street[26];
/* ,

char city[16j;

/* ,

char *username = "Manager/Manager",char *connectString = "DreamHome";


EXEC SQL END DECLARE SECTION;
/* */
printf("Enter staff number: ");
scanf("%s", staffNo);
/* */
EXEC SQL CONNECT
:username USING :connectString;
if (sqlca.sqlcode < 0) exit (-1) ;
/* SQL,
*/
EXEC SQL WHENEVER
SQLERROR
GOTO
error;
EXEC SQL WHENEVER
NOT
FOUND GOTO done;
EXEC SQL DECLARE propertyCuraor CURSOR FOR
SELECT propertyNo, street, city
FROM PropertyForRent
WHERE
StaffNo = :staffNo
ORDER
by propertyNo;
/* , ,
*/
EXEC SQL OPEN propertyCursor;
for (;;) {

21. SQL

789

/* */
EXEC SQL FETCH propertyCursor INTO :propertyNo, : street ,
:city;
/* */
printf ("Property number: %s\n", propertyNo) ;
printf ("Street: %s\n" , street);
printf ("City:
%s\n", city);
}
/* - */
error :
printf("SQL error %d\n" , sqlca. sqlcode) ;
done:
/* */
EXEC SQL WHENEVER
SQLERROR
continue;
EXEC SQL CLOSE propertyCursor;
EXEC SQL COMMIT WORK RELEASE;

21 .1.5.
, . (),
, (. 6.1.4), . ,
UPDATE DELETE CURRENT.

. , ,
.
, , ISO,
. Oracle
.
Oracle
DECLARE CURSOR:
' EXEC SQL .DECLARE cu'reorffame CURSOR selectStatement FOR UPDATE .
yOF columnWame' [, . .-;. ] ... .
'
FOR UPDATE OF , selectstatement,
. ,
SELECT. UPDATE,
, :
VEXEC SQL' UPDATE::'TabieName
SET c01unuiWame;== dataValue- !,...]
WHERE CURRENT .OF- curso.rWame
cursorWame
. WHERE ,
.
790

V.

. SET DECLARE
CURSOR. ,
s t a f f t f o ,
property-Cursor. ,
FETCH.
EXEC SQL UPDATE PropertyForRent
SET s t a f f N o = ' S L 2 2 '
WHERE CURRENT OF propertyCursor;

. :

BXEC/SQJL, DELETE FROM


: 'WHERE CURRENT OF
cursorName
. ,
,
FETCH. ,
, propertyCursor.
EXEC SQL DELETE FROM PropertyForRent
WHERE CURRENT OF propertyCursor;

, DECLARE CURSOR FOR


UPDATE OF. Oracle , CURRENT OF - .

21.1.6. ISO
SQL
,
SQL Oracle ISO.

WHENEVER
ISO SQLWARNING WHENEVER.

SQL
ISO SQL , .
SQLCODE,
. SQLSTATE, ,
; . 21. SQL

791

SQL SQL, 00
: ,
. ) 22012
22 ( )
012, .
Oracle 8 SQLSTATE, DECLARE SECTION :
char SQLSTATE[6];

SQL SQLSTATE, .
, SQL ().

ISO
, . ,
DECLARE CURSOR, ISO, :
EXEC SQL DECLARE cursortfame fIMSENSITIVE)
CURSOR FOR selectStaCement
- ;

[FOR (READ. ONLY j UPDATE

INSENSITIVE .
SCROLL

. FETCH :
'EXEC SQL FETCH EIf&tchQrientation} FROM] cursorNarne
INTO hostVarlable I, ... ,\
. .,
fetchOrientation .
NEXT. , .
PRIOR. ,
.
FIRST. .
LAST. .
ABSOLUTE. ,
.
RELATIVE. .
SQL
, ,
FETCH
, .
792

V.

21.2. SQL
SQL, SQL. SQL
, SQL , .
SQL
. , , , , .
.
,
. ,


SQL. ,
SQL. ISO SQL, SQL , SQL
. , SQL , .
EXEC SQL BEGIN DECLARE SECTION;
char TableName.[20] ;
EXEC SQL END DECLARE SECTION;
EXEC SQL INSERT INTO :TableName

VALUES { ' C R 7 6 ' ,

'PA14',

'05-May-2001',

'Not enough space'};

, SQL
INSERT , . , . , :
EXEC SQL DECLARE cursorl CURSOR FOR
SELECT *
FROM :TableName;

' *' ,
,
table_name. . ,
. , Branch Staff (. . 3.3 3.4)
, Branch Viewing (. 3.8) , .
, FETCH, , , . , SQL,
, .
21. SQL

793

21 .2.1 . EXECUTE IMMEDIATE


SQL ,
SQL, ,
. . , , EXECUTE IMMEDIATE,
:

SQL, ,
host Variable,
stringLiteral. , SQL
EXEC SQL BEGIN DECLARE SECTION;
float increment ;
EXEC SQL END DECLARE SECTION;
EXEC SQL UPDATE Staff SET salary = salary + : increment
WHERE s t a f f N o = ' S L 2 1 1 ;

SQL:
EXEC SQL BEGIN DECLARE SECTION;
char b u f f e r [100] ;
EXEC SQL END DECLARE SECTION;
sprintf ( b u f f e r , "UPDATE S t a f f SET salary = salary + %f
WHERE staff No = ' S L 2 1 ' " , increment);
EXEC SQL EXECUTE IMMEDIATE : b u f f e r ;

UPDATE ,
EXECUTE IMMEDIATE. , increment
SQL,
SQL. , UPDATE
EXEC SQL, (;).

21 .2.2. PREPARE EXECUTE


EXECUTE IMMEDIATE
, SQL, , , (. 21.1). , EXECUTE IMMEDIATE ,
SQL . SQL
, .
SQL SQL , PREPARE EXECUTE.
PREPARE SQL. . SQL, .
794

V.

*~4

""1
f.

EXECUTE IMMEDIATE
*EXECUTE

PREPARE

h
H

I-

I#*

. 21.1. : ) SQL;
) SQL
, , . PREPARE :
;;

EXEC .;SQL : 'PREPARE/"statementName'FROM' [hostVariable'


EXECUTE :

;: EXEC '-'SQ.L' 'EXECUTE' > t a Cemen tName"


, [USING hostVariable '
-J3ING DESCRIPTOR' SQL, , USING hostVariable
EXECUTE.
USING DESCRIPTOR, . USING
hostVariable SQL - ( ). -
, hostVariable/'stringLiteral PREPARE,
. - ,
. ,
, EXECUTE.
SQL .
, UPDATE,
SET WHERE :
21. SQL

795

EXEC SQL BEGIN DECLARE SECTION;


char b u f f e r [ 1 0 0 1 ;
float newSalary;
char s t a f f N o [ 6 ] ;
EXEC SQL END DECLARE SECTION;
s p r i n t f ( b u f f e r , "UPDATE Staff SET salary = :sal WHERE staffNo =
:sn");
EXEC SQL PREPARE Stmt FROM :buffer;
do {
printf("Enter staff number: " ) ;
s c a n f ( " % s " , staffNo};
printf("Enter new salary: " ) ;
s c a n f ( " % f " , newSalary};
EXEC SQL EXECUTE stmt USING znewSalary, :StafNo ;
printf("Enter another ( Y / N ) ? " ) ;
scanf{"%c", more);
}

until (more ' = ' Y ' ) ;


sal sn
-. ,
,
PREPARE (. 21.1).
EXECUTE. , SQL.

21.2.3. SQL (SQLDA)


- EXECUTE. , SQL (SQL Descriptor Area SQLDA). SQLDA
,
. Oracle
. SQLDA Oracle, SQLDA, ISO. SQLDA Oracle
; Web- , SQLDA INGRES
(URL Web- ).
, ISO, 21.2.7.
SQLDA Oracle 21.5.
SQL, .
DESCRIBE BIND VARIABLES ( bind variables) SQLDA , ,
.
DESCRIBE SELECT LIST SQLDA ,
, ,
,
,.
796

V.

21.5. SQL (SQLDA) Oracle

/*

SQLDA (SQLDA
*/
struct SQLDA{
long N,/*
char **V; /*
long *L; /*
short *T; /*
short **I; /*
long F;
/*

Descriptor Area - SQL)


, */
*/
*/
*/
*/
,

DESCRIBE */

char **S,- /* */
short *M; /*
*/
short *C,- /*
*/
char **X; /*
*/
short *Y; /*
*/
short *Z; /*
*/

SQLDA ( N, M )
SQLSQLDAAlloc() Oracle ( ). ( , F, S, , X Z) DESCRIBE. , ( V, L I),
FETCH. .
N. - SELECT, SQLDA.

SQLSQLDAAlloc (). DESCRIBE
N F .
F. - SELECT, DESCRIBE.
V. ,
SELECT.
SQLSQLDAAlloc {)
, ,
. -

OPEN, SELECT
FETCH.
21. SQL

797

.
SELECT. - OPEN,
SELECT DESCRIBE,
. NUMBER
, SQLNumberPrecV6 Oracle.
NUMBER
char ,
2 (
).
. SELECT. Oracle : . Oracle, a
, . , , . , , , STRING.
DESCRIBE -
. OPEN. Oracle . 21.2.
DESCRIBE SELECT
Oracle.
,

FETCH. , Oracle

OPEN ( DESCRIBE
-),
FETCH ( DESCRIBE
SELECT). .
NUMBER . , , 2 1
21.2. Oracle
SQL Oracle

VARCHAR2

char [n]

NUMBER

char []

INTEGER

int

FLOAT

float

STRING

char [n+1]

CHAR

96

char [n]

798

V.

(VARCHAR2), 3 (INTEGER), 4 (FLOAT,


) 5 (STRING).
DATE
. (DD-MMM-YY) , 12, 1 (VARCHAR2) 5
(STRING),
(L) 7 9 10.
, SELECT (.. 1) , NULL. ( 0) OPEN FETCH;
SQLColumnNullCheckU Oracle.
1. , . -
, SELECT
FETCH.
S. ,
- SELECT.
, S
SQLSQLDAAlloc () Oracle. DESCRIBE
.
.
, -
SELECT. SQLSQLDAAlloc {) Oracle.
. SELECT. DESCRIBE.
X. ,
.
-. ,
X SQLSQLDAAlloc
Oracle. DESCRIBE .
Y. ,
.
-.
SQLSQLDAAlloc (} Oracle.
Z.
. X Y, . DESCRIBE.

21.2.4, DESCRIBE
DESCRIBE SQL, (.. , PREPARE).
S3LSCT DESCRIBE SQLDA 21. SQL

799

, /-, SQL. ,
SELECT, DESCRIBE F SQLDA
0. DESCRIBE :
EXEC - SQL DESCRIBE BXHD VARIABLES FOR statement
. EXEC -S.QL DESCRIBE SELECT LIST FOR statementttame
selecCDescriptorName
statement Name
SQL, bindDescriptorName selectDescriptorName SQLDA. , SELECT ( , SQLDA ):
sprintf (query, "SELECT propertyNo, rent FROM PropertyForRent") ,EXEC SQL PREPARE stmt FROM -.query;
EXEC SQL DESCRIBE SELECT LIST FOR Stmt INTO sqlda;
sqlda , . 21.2.

SQLDA


DESCRIBE (NUMBER
2

l-fc 1 UH

DESCRIBE

FETCH

-1

DESCRIBE

*1

10

10

10


SQLSQLDAAIIocO

..

DESCRIBE

. 21.2. SQLDA ,
DESCRIBE/FETCH

800

V.

21.2.5.
SQL
21.1
, . SQL
, .
DECLARE, OPEN
FETCH CLOSE, :
|EXSp:;SQL DECLARE cursorName CURSOR"FOR selectStatemerit
v-' SQL -OPEN cursorffarae {USING hostVariable IindicatorVarlablej '.[,..;.} | USING DESCRIPTOR descriptorWame} ..
ijEpCEC SQL FETCH cursorMarae {INTO hostVariable [indicatorVari^bleJ
..[, .'. .] -VI, USING .DESCRIPTOR descriptor-Name}:,. '= . . " / ' - ;; "
/|BXBC" SQL.CLOSE cursorName
OPEN ,
-,
hostVariable USING descriptorName (.. SQLDA), USING DESCRIPTOR. SQL ,
FETCH descriptorWame

hostVariable/indicatorVariable). SQLDA
( )
FETCH.
, I
. ,
SQLDA, , , .
, SQL .
1. DECLARE SECTION
.
2. SQLDA, , SQLDA,
.
3. () SQLDA.
4. SQLDA, , -,
- SQLDA, .
5. .
6. PREPARE,
.
7. DECLARE.
21. SQL

801

8. -, .
) DESCRIBE SQLDA, .
) -
, DESCRIBE.
) , DESCRIBE.
9. OPEN SQLDA, , , SQLDA, .
10. DESCRIBE
SQLDA, .
11. ,
DESCRIBE.

12.
,
13. FETCH
,
SQLDA, ,
.
14. , , -, SQLDA.
15. CLOSE,
SQL Oracle
Web-, (URL
).

21.2.6.

21.1.5
SQL
UPDATE DELETE. SQL.

21.2.7. SQL
ISO
,
SQL Oracle
ISO,

SQLDA
ISO SQL (SQLDA) , - . 802

V.

SQLDA (
). SQLDA
:
UAt,LbCATE. DESCRIPTOR.descriptqrWame "{WITH MAX - occurrences]
' DESCRIPTOR':descript:or#ame .
SQLDA
:
| 'DESCRIPTOR deecrijptorWame. {ho&tVariable' = COUNT j
. VALUE itemWumber- hoBtVari'abiel = i temWaraei [, . . . 3 }
ISET DESCRIPTOR descriptprWame' (fcOUNT *'hostVariable j
VALUE itemjmber. iteinNamel. '''tiostVariablel { , . . . ] }
ISO.
TYPE. ( ISO
. 21.3).
LENGTH. .
INDICATOR. .
DATA. .
21.3. ISO

ISO SQL

ISO SQL

CHARACTER

CHARACTER VARYING

12

NUMERIC

DECIMAL

INTEGER

SMALLIKT

FLOAT

REAL

DOUBLE PRECISION

DATE


ISO, GET DESCRIPTOR.
PRECISION. .
SCALE.
( ).
NAME. .
NULLABLE. ,
NULL ( 1, NULL, a
0, NULL).
, count
EXEC SQL GET DESCRIPTOR :sqlda :count = COUNT;
, :
EXEC SQL SET DESCRIPTOR :sqlda VALUE 1 INDICATOR -1 DATA :data
21. SQL

803

DESCRIBE
ISO DESCRIBE ,
.
DESCRIBE INPUT () SQL, DESCRIBE
OUTPUT SELECT. DESCRIBE
.
SELECT:
char

*selectStatement = "SELECT staffNo FROM Staff


WHERE branchNo = :branchNoData" ;
int staffNoType = 12, staf fNoLength = 5, branchNoType = 12,
branchNoLength. = 4;
char *branchNoData = 'B001 1 ;
Char staffNoData[6] ;
EXEC SQL ALLOCATE DESCRIPTOR 'inSQLDA 1 ;
EXEC SQL ALLOCATE DESCRIPTOR 'outSQLDA';
EXEC SQL PREPARE s FROM : selectStatement ;
EXEC SQL DESCRIBE INPUT s USING DESCRIPTOR 'inSQLDA';
EXEC SQL SET DESCRIPTOR 'inSQLDA1 VALUE 1 TYPE = : branchNoType ,
LENGTH branchNoLength, DATA = :branchNoData,EXEC SQL DECLARE staff Cursor CURSOR FOR S;
EXEC SQL OPEN s t a f f Cursor USING DESCRIPTOR 'inSQLDA 1 ;
EXEC SQL DESCRIBE OUTPUT a USING DESCRIPTOR 'outSQLDA';
EXEC SQL SET DESCRIPTOR ' OutSQLDA1 VALUE 1 TYPE = : staf fNoType ,
LENGTH staf fNoLength, DATA = : staf f NoData;
for (;;} {

EXEC SQL FETCH staffCursor INTO DESCRIPTOR 'outSQLDA';


EXEC SQL GET DESCRIPTOR 'outSQLDA' VALUE 1 :StaffNoData =
DATA;
printf ("Staff No: %s\n" , staffNoData) ;

, () Oracle.

21.3. ODBC (Open Database


Connectivity)
,
SQL
, . , 11-,
, SQL.
SQL API-, ' API Application Programming Interface ( ).

804

V.

. API-
,
, , SQL, ..

, , API-,
.
, , API- .
,
,
,
. , , , ,
.
, Microsoft , Open Database Connectivity (ODBC). ODBC
SQL, SQL . ( )
,
,
, . , , "/",
.

.
ODBC . , .
API- .
SQL
.

.
, .
ODBC '
/ ISO CLI (Call-Level Interface),
ODBC .
28.9.1 JDBC Java,
ODBC.
21. SQL

805

21.3.1. ODBC
ODBC .
,
, SQL .
.
.
.
SQL, /Open ISO CLI.
ODBC .
.
ODBC SQL .
. .
ODBC .
Microsoft DLL (DynamicLink Library ).
. ODBC,
SQL
. , . , .
, . ,
,
ODBC.
, , XBase. , SQL.
ODBC
(. 21.3, ) ODBC, . ODBC (. 21.3, )
,
.
ODBC, . Windows ODBC DLL. (), .
. ,
. , , , , .

806

V.


ODBC

. 21.3. ODBC: ) ; )

21.3.2. ODBC
ODBC ODBC API ODBC SQL.
ODBC SQL. , ODBC API, Microsoft ODBC Reference Guide, ODBC , /Open
[329] ISO CLI [175]. ODBC , .
ODBC 3.0 , , .
ODBC
, ODBC, a
, SQL, .

SQL

DDE) CREATE TABLE DROP TABLE.

(Data

Definition

Language -


(Data
Manipulation
Language DML) SELECT, INSERT, UPDATE
SEARCHED DELETE SEARCHED.
(, > + ).
CHAR, VARCHAR LONG VARCHAR.

21. SQL

807

SQL
SQL .
DDL: ALTER TABLE, CREATE INDEX, DROP INDEX, CREATE
VIEW, DROP VIEW, GRANT REVOKE.

DML: SELECT.
: , , SUM MIN.
: DECIMAL, NUMERIC,
DOUBLE PRECISION,

SMALLINT,

INTEGER,

REAL,

FLOAT,

SQL
SQL .
DML: , UPDATE
DELETE, SELECT FOR UPDATE .
: (, SUBSTRING ABS), , .
: BIT, TINYINT, BIGINT,
VARBINARY, DATE, TIME, TIMESTAMP.

BINARY,

VARBINARY,

LONG

SQL .
.

21.4. ODBC
, ,
SL41.

21.6 ,
ODBC. .
ODBC.
SQLAllocEnv{), ODBC.
ODBC, , .
SQLAllocConnect ) . .
, .
, .
SQLConnect ().

.
808

V.

SQLAllocStmt ( ) . ,
, SQLSTATE , ,
, SQL.
,
.

SQL SELECT
SQLExecDirect () ODBC. SQL
, ODBC
,
.
-. SQLBindParameter ()
ODBC, . SQLBindCol, . SQLFetch.
21.6. , ODBC
^include "SQL.H"
^include <stdio.h>
^include <stdlib.h>
^define MAX_STMT_LEN
main()
HENV
HDBC
HSTMT
RETCODE
UCHAR
UCHAR
UCHAR
UCHAR
SDWORD

100

hEnv,

*/
*/
*/
*/
SELECT */

propertyNo */
street[26];
/*
street */
/*
cityE 16] ;
city */
propertyNoLen, streetLen, cityLen;

hDbc;
hStmt;
;
selStmt [MAX_STMT_LEN]
propertyNo[6];

SQLAllocEnv(&hEnv) ;

l*
/*
/*
/*
/*
/*

SQLAllocConnectfhEnv, SrhDbc) ; /


*/

*/

re = SQLConnect (hDbc,
11
DreamHome " , SQL_NTS ,
/ */
"Manager", SQL_NTS,
/
"Manager", SQL NTS) ;
/ */
. SQL_NTS ,
,

21. SQL

809

*/
if ( == SQL_SUCCESS j | rC == SQL_SUCCESS_WITH_INFO) {
SQLAllocStmt(hDbc, SdiStmt); /*
*/
/* SELECT, */
IstrcpytselStmt, "SELECT propertyNo, street, city FROM
"^Property For Rent where staffNo = 'SL41' ORDER BY propertyNo"};
if (SQLExecDirect(hStmt, selStmt, SQL_NTS) != SQL__SUCCESS)
exit (-1) ;
SQLBindColthStmt, 1, SQL_C_CHAR, propertyNo,
(SDWORD)sizeof(propertyNo), kpropertyNoLen);
SQLBindCoKhStmt, 2, SQL_C_CHAR, street,
(SDWORD)sizeof(street), bstreetLen);
SQLBindCoKhStmt, 3, SQL_C_CHAR, city,
(SDWORD)sizeof(city), fccityLen);
/* */
while ( == SQL_SUCCESS || rC == SQL_SUCCESS_WITH_INFO)
{

rC = SQLFetch(hStmt);
if (rC == SQL_SUCCESS j| rC == SQL_SUCCESS_WITH_INFO)

/* , */
SQLFreeStmt (hStmt, SQL_DROP) ,- /*
*/
SQLDiscormect (hDbc) ,/*
*/
}
SQLFreeConnect(hDbc);

SQLFreeEnv(hEnv);

/*
*/
/*
*/

SQL, .
SQL ,
SQLPrepare ()
SQLExecuteO ODBC (. 21.2.1).

SQL ,
.
, . SQL
, , . SQL , .
SQL ,
.
810

V.

SELECT
,
. .
. DECLARE CURSOR. OPEN . ,
, . FETCH , CLOSE
. UPDATE DELETE.
SQL SQL . SQL
, SQL
,
. SQL, ,
EXECUTE IMMEDIATE.
,
PREPARE EXECUTE. EXECUTE/FETCH -.
SQL (SQL Descriptor Area SQLDA) ,
SQL. DESCRIBE
SQL, SQLDA. F SQLDA
, , SELECT. SELECT, ,
.
ODBC (Open DataBase Connectivity) Microsoft SQL. ODBC SQL .
ODBC ( )
,
, SQL.
ODBC
"/", -
. ODBC.
ODBC .

21. SQL

811

(
21.1. SQL, SQL
SQL?
21.2. .
21.3.
.
21.4. - .
21.5. SQLCA SQLDA?

, , 3.
21.6. SQL
SQLDA DESCRIBE SELECT LIST FOR DESCRIBE BIND VARIABLES FOR:
) "SELECT * FROM Hotel";
) "SELECT hotelNo,

hotelName FROM Hotel WHERE hotelNo =

:hn";

) "SELECT MIN(price) FROM Room WHERE hotelNo = :hn AND type = :t".

21.7.

, , .
21.8. ,
, ,
, .
21.9. ,
5%.
21.10. , ,
Grosuenor Hotel .
21.11. ,
, .
21.12. SQL
, . ,
ISO SQL.

812

V.




-
-
-

815
869
927
961
1005
1049



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

.
,
.
.

,
, , .
, Internet, ,
"" . 5' .
.
, .. ,
.
,
, -

, , ,
.
,
.


22.1
, ,
. 22.2
, . 22.3 , . ,
, ANCI-SPARC,
2. 22.4 ,
, IV , . 22,5
,
,
22.6 ,
. ,
DreamHome, 10.4 .

22.1.
, , . , .
. ,
, , , , ..,
, , , [93].
, , , , ,
. , .
. , ,
, . , , .. .
816

VI,

22.1.1.
, ,
, .
. ^ ( ), .

.
, , -
; .
( ) ,
. , .
,
(.. ), , .
.
( )
( ).
, .
.
.
.
.
.
.
.
.
, , , . 22.1.

22.1. DreamHome
, DreamHome . , , , ,
21.

817

,
, ,
. ,
,
, ,

.
, DreamHome ( )
, .
1

.'

. 22.1,

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

[91]. , , , , 22.5.

818

VI.



.
. .- , .
, , .
, ,
, , .
. 22.2. , 2, , . 22.1, , .
1

. 22.2.


, , .
. ,
,
; ( ) .
21.

819

,
, . , . ,
, , .

. ,
,
, , , . . 22,3. :
;
;
.

, .
, ,
,

.
, ,
. , (SMP), ,
, , RISC- .
, 64.
.
. , .
, . ,
, . , ,
, . .
820

VI.

, 22.3. : )
; ) ; )

21.

821

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

,
(1012 ), ,
.
.
,

, ,

.
30. ,
.

22.1.2.

, ,
.
, , .



, , ,
. ,
DreamHome
. ,
. DreamHome
, , , ,
, . . , ,
.
!
,
VI.

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

. ,
,
. ,
, . , , , .

,
,
.

,
- ,
( ). , , , .

1960- , ,
, .
(Grosch).
,
, . ,
, , , .
,
. - (
) .

21.

823



. .
. -
.
( ) ( ).


; , , , , , .
, , .
,
, , ,
.

( ). ,
. , . , , .

.
,
, . .
, .

.
,
.
, , .

. 23.4.5.
824

VI.


,
,

. . ,
, .

,
.

. , ,
.

.

, , ,
, . 22.4.
.
, , . 22.1.
22.1.

22.1.3.

. .
,
, .. , , - .
21.

825

.
, , .
.
, , .
.

, .

. , :
;
;
.
, ,
.
, ,
. ,
,
. , (, SELECT
SQL FIND GET
). , , . .
, . 3.1 15 ,
. , , , . ,
.
. [124].
, ,
, , .
. -,
. ,
826

VI.

. , , . -,

. , , .

Open Group (Specification Working


Group SWG), [143].
(
, ), ,
.
SQL (SQL API),
,
.
,
- .
, .
, , , , - .


,
,
.
. ,
, .
,

,
. . ,
,
.

.
21.

827

-
, .
, ,
. ( ) .
, . '
[41] [273].
, . ,
. ,
.
. .
, . ,
, . , .
UniSQL Cincom Corporation.
[83].
22.3.3.

22.2.

. , >
^ .
,
.
, .
,
,
828

VI.

, . ,
.
. , : , , . (Local Area Network LAN)
,
. (Wide Area Network WAN)
, . (Metropolitan Area Network MAN), .

.
33,6 / ( ) 45 / ( ).

10 / ( Ethernet) 2500 / ( ATN),
. ,
, ,
, , .
( ), "-" . "-"

. , , -,
.
"-", , , . . 22.2.
(ISO) (
), [168]. ,
, . ,
OSl (Open System Interconnection), , .
, ,
,
.
, ,
, ,
[151] [299].

21.

829

22.2.


(
)


(
)

33,6 /
( )
45 / ( )

2500 / (
ATM)


"-"

1:5

1:10


(CCITT) , .25
.
.25.
, . RDA (Remote Database
Access ISO 9579) DTP (Distribution Transaction Processing ISO 10026). Co X/Open DTP 23.5.
.


!| . , , -'-,
; .
.
TCP/IP
TCP/IP (Transmission Control Protocol/Internet Protocol / )
Internet ( ). TCP
. IP
, (IP-). IP- . , .
830

VI.

IP- . TCP/IP
, , -, , .
TCP/IP ,
, Internet.
SPX/IPX
SPX/IPX (Sequenced Packet Exchange/Internetwork Package
Exchange / ), Novell NetWare.
TCP, SPX ,
IPX NetWare. IP, IPX . IP, IPX 80- , 32 , 48 (
32- , IP).
, IP, IPX
( ).
IPX .
. . NetWare 5 SPX/IPX Novell , Internet, TCP/IP, .
NetBIOS
NetBIOS (Network Basic Input/Output System -) 1984 IBM Sytek
. NetBIOS NetBEUI
(NetBIOS Extended User Interface
NetBIOS) . NetBIOS
,
, NetBIOS NetBEUI, TCP/IP SPX/IPX.
NetBEUI , , Microsoft. , NetBEUI
, TCP/IP .

(Advanced Program-to-Program Communications -- ) , IBM, .


"/" ,
, IBM.
, ,
( ). 21.

831

, IBM ( ),
. (Systems Network Architecture) IBM,
LU 6.2, LU 6.2
.
DECnet
DECnet ,
Digital,
Ethernet, , - .
PDF, VAX, Mac, .
AppleTalk
AppleTalk , Apple 1985 ,
LocalTalk Apple, ,
Ethernet Token Ring. AppleTalk LocalTalk
Macintosh , LaserWriter.
WAP
WAP (Wireless Application Protocol ) ,
, Web- . 1997 Phone.com (
Unwired Planet), Ericsson, Motorola, Nokia ,
TCP/IP
, .


, , .
:
_ = 0 -t- (__/_)

0 . , , 1 ,
10 000 / , 100 000
100 , :
_ = 1 + (100 000 * 100/10 000) = 1001

, :
_ = 100 000 * [1 + {100/10 0 0 0 ) 3
= 100 000 * [1.01] = 101 000
,
100 000 , , 832

VI.

. , , , .
22,5.3.

22.3.
2 , . ,

.

22.3.1.
, ,
, ,
2. ,
.

,
.
,
.
, .
, .
, .
,
.
23.

22.3.2.

ANSI-SPARC , 2.1,
. ,
, . - ,
. . 22.4.
:
;
;
;
, ANSI-SPARC.

21.

833

'

. 22.4. ,

,
.
.


, , .
-

834

VI.

ANSI-SPARC , , . . .


, . , .


.

ANSI-SPARC,
.
.

22.3.3.
22.1.3 . . ,
. . 22.5 , , (Global Conceptual Schema
GCS).
. , ,
.
, .
,
[208J.
. .
[208] [273].

22.3.4.
,
, :
;
;
;
.

21.

835


1
/I

. 22.5. ,

, . 22,1, . 22.6. 2
, 1.


, ,
. , ,
.
. , , ,
/ .


,
. .

836

VI.

, 22.6.


,
.
, ,
, .
,
, , . , .
. , R ,
[326]. R
, ,
, .
. ,
( ),
,
.
, . , .
21.

837


.
22.5.1.


.
,
22.5 23.

22.4.

14 15 . , . ,
.
. , , . : . , .
. ,
.
. .
. ,
. , ,
. ,16.2, , 20% 80% . "80/20"
[325].
,
.
,
. :
;
, ;
.
:
, ;
( );
.
838

VI.

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

22,4.1.
:
, (),
. , .



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

()
, .
, , .
21.

839

,
. , ,
, .
, .



. , , .
.
. . , ,
.
,
.
23.6.


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

. 22.3.
[244] [301].

22.4.2.

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

840

VI.

. , , . , .. , ,
.
. , ,
, ,
.
,
.
. , ,
, , .
.
, .
22.3.

.
1

21.

841


.
,
.
1. . R ,
R!, R 2 , ..., Rn, ,
R, , , .
, - .
2. . ,
R .
.
3. . di R i(
- .
, , .
.
,
.


: . , (. 22.7).

. 22.7. : ) ; )

, : (. 22.8)
( ).

DreamHomc, . 3.3-3.9.

842

VI.

. 22.8. : )
; )

( )
/ . , -''
| .
,
.
, . (. 4.1.1).
,
, , , ,
, . R,

d p (R)
, .

22.2.
, :
(' Flat') (' House ').
PropertyForRent type :
PI=
2 =

o-cypi.iHouBe. (PropertyForRent)
=,F l a t , (PropertyForRent}

(5 ?2). , . 22.4, ,
type 'House'. (. 22,5) ,
type 'Flat'.
, , .
.
. P l t 2 .
. PropertyForRent
:
u P2 = PropertyForRent

21.

843

. ,
type,
'House' ' F l a t 1 .
22.4. , PropertyForRent
property street
No
14
PG21

city

16 Holhead Aberdeen
18 Dale Rd Glasgow

post
code

type

rooms

rent

owner
No

staffNo

branch
No

AB7 5SU

House

650

C046

SA9

B007

G12

House

600

C087

SG37

BOOS

22.5. 2 PropertyForRent
property street
No

city

postcode

type

rooms rent

owner
No

staff
No

branch
No

PL94

6 Argyll St

London

NW2

Flat

400

C087

SL41

BOOS

PG4

6 Lawrence St

Glasgow

Gil 9QX

Flat

350

C040

SG14

BOOS

PG36

2 Manor Rd

Glasgow

G32 4QX

Flat

375

C093

SG37

B003

PG16

5 Novar Dr

Glasgow

G12 9AX

Flat

450

C093

SG14

B003

, . ( ) , , . ,
, . .
.
(.. ) ,
[51].
, . , , , , -
. ,
, PropertyForRent
, {type =
1
House' , type = ' Flat' } , {type
' House ' } . ,
(city = 'Aberdeen') .
( )
. ,
.

844

VI.

, .

(. 4.1.1). R

a l f ... , R.

I 22.3.
DreamHome , ,
staffNo, position (), sex (), DOB
( ) salary ( ). , , staffNo, fName (), IName ()
branchNo ( ). ,
staff
:
Si :

H a t a E f N o , position, , DOB, s n l a r y ( t a f f
n a t a f f K O i fName, IName, branchNo ( S t a f f )

&2

, . 22.6 22.7. (
staffNo), . ,
, .
, . .
. staff S l f S 2 .
. Staff
:
xi S2

Staff

. , staffNo,
.
22.6. S, Staff
staffNo

position

sex

DOB

salary

SL21

Manager

l-Oct-45

30000

SG37

Assistant

lO-Nov-60

12000

SG14

Supervisor

24-Mar-58

18000

SA9

Assistant

19-Feb-70

9000

SG5

Manager

S-Jun-40

24000

SL41

Assistant

13-Jun-65

9000

21.

845

22.7. 32 Staff

staftNo

fName

IName

branchNo

SL21

John

White

8005

SG37

Ann

Beech

B003

SG14

David

Ford

B003

SA9

Mary

Howe

BOO 7

SG5

Susan

Brand

B003

SL41

Julie

Lee

BOOS

.
,
. , ,
1( 2 4 R, (a l f a 2 , 3 ,
4), :
.^

3 I
I

-2

^4

; ,
. , , , . , ,
.

.
. ,

. , , .
(splitting)
1984 [225].
, . , .
, . , , [244].

846

VI.


, . ( )
.
. . , ;
| '
^ .
. R,

( , ... , a ( R ) )

, R, a l f ... , .

22.4.
22.3 Staff

. :
Si:
S;. :

I ' s t a t f N o , position, , DOB. salary ( Staf I )


1'etatfNo.

fName,

IName, bronchNo

S 2 branchNo (
, ):

(S2i, S22 S2a),


, ' 1 (. 22,9),
, ' 0 0 5 1 (. 22,10),
, ' 0 0 7 ' (. 22.11). Sj
. 22.8. .
. Staff
Sit S 2 ; ( ) S1(
S21, S 2 2 S 2 3 . Staff
:
21 .

847

51 txa (S 2 i U 22 U S 2 3 ) = Staff
. ,
, ,
,
5 2 ,
.
22.8. Staff. S,
staffNo

position

sex

DOB

salary

SL21

Manager
Assistant
Supervisor
Assistant
Manager
Assistant

M
F
M
F
F
F

l-Oct-45

30000

lO-Nov-60

12000

24-Mar-58
19-Feb-70
3-Jun-40
13-Jun-65

18000
9000
24000
9000

SG37
SG14
SA9
SG5

SL41

22.9. Staff. S21


staffNo

fName

IName

branchNo

SG37

Ann

SG14

David
Susan

Beech
Ford
Brand

BOOS
B003
BOOS

SG5

22.10. Staff. S22


staffNo

fName

IName

branchNo

SL21

John
Julie

White
Lee

B005
BOOS

SL41

22.11. Staff. SK
staffNo

fName

IName

branchNo

SA9

Mary

Howe

B007



. ,
.
.
.
. ,
.
848

VI.

"" , , ""
. (.
4.1.3). R S, R :
= R

1 < i < w

w ,
S, F , .

22.5.
, , Staff PropertyForRent. , , Staff
branchNo.
.

SE

ObranchNo='B037' ( S t a f f

, PG4
SG14.
, .
PropertyForRent
:
Pi = PropertyForRent > sCafHo Si,

3 < i < 5

(3, 4 5). ,
' 1 (. 22.12), ,
'005' (. 22.13),
' 0 0 7 1 (. 22.14). , . (
) .
22.12. PropertyForRent
Staff.
property
No

street

city

postcode type

PG4

6 Lawrence St

Glasgow

Gil 9QX

G36

2 Manor Rd

Glasgow

G32 4QX

PG2I

18 Dale Rd

Glasgow

PG16

5 Novar Dr

Glasgow

staff
No

rooms

rent

owner
No

Flat

350

C040

SG14

375

C093

SG37

G12

House

600

CO87

SG37

G129AX

Flat

450

C093

SG14

21.

849

22.13. Property For Rent no


Staff. 4
property

street

city

No
PL94

postcod

type

rooms

rent

e
6 Argyll St

London

NW2

Flat

400

owner

staff

No

No

C087

SL41

22.14. Property For Rent no


Staff, 5
property

street

city

postcode

type

rooms

rent

ownerNo

staffNo

House

650

C046

SA9

No
PA14

16Holhead

Aberdeen AB7 5SU

,
.
, , , , ,
.



. , Branch
, .
(, ), .



.
1. , 14-16,
.
2. . ,
Dream-Home ,
,
.
. , .
3. ,
.
850

VI.

4. , ;
.
ER- , , , .
5. , ""
" ", . , "" " ",
.
6.
(..
, ,
).

22.5.

, 22.1.1, ,
.
. ,
,
.
. :
. ,
, , .
.
.
.
.
,
,
. , [137],
. , , ,
, , . ,
.

22.5.1.

.
, ( ) ( ).
/21.

851


,
.
.
,, 22.15 S t a f f , ,
22,4.
22.15. Staff 22.4

^2
S

2i

"


n,tMo, position, sex, DOB, salary ( S t a f f }

36 5

n s : a f Ho, fName, IName, brs-ncbNo ( S t a f f )


^^'. ( S 2 )

!,^0-> (S2)

a br ar.chH 0 =.EOD7. ( S 2 )



. , , .

. ,
( position 'Manager'),
, SQL;
SELECT fName, IName
PROM STAFF
WHERE position = 'Manager 1 , SQL, .


, , . :
SELECT fName,
FROM S21
WHERE staffNo
UNION
SELECT fName,
FROM S2;
WHERE staffNo
UNION

IName
IN (SELECT staffNo FROM Sa WHERE position = 'Manager')
IName
IN {SELECT staffNo FROM S WHERE position = 'Manager')

VI.

SELECT fName, IName


FROM S23
WHERE s t a f f N o IN (SELECT s t a f f N o FROM Sa WHERE position = ' M a n a g e r ' } ;

.
,
( ), position fName/lName
. ,
,
.


. ,
. . , ,
.


.

, , . :
SELECT fName, IName
FROM S21 SITS 3
WHERE staff No IN (SELECT staffNo FROM 5 AT SITE 5 WHERE
position='Manager')
UNION
SELECT fName, IName
FROM S 2 2 AT SITE 5
WHERE s t a f f N o IN (SELECT s t a f f N c FROM Sj_ AT SITE 5 WHERE
posit i o n = ' M a n a g e r ' )
UNION
SELECT fName, IName
FROM S2, AT SITE 7
WHERE s t a f f N o IN (SELECT s t a f f N o FROM Sj. AT SITE 5 WHERE
position= ' Manager'} ,-

SQL
AT SITE, , . , ,
. , ,
, .


.
,
21.

853

. ,
, . , , .
.:
;
(
);
-
, .
,
, . , Branch, S1(
SI.Branch. , .
Branch, S lt
SI .Branch. F3 .2. .
, , , (
), .
SI .Branch.F3 .2 Sj LocalBranch.
.
R* . , . ,
. .
.
, .
. , .
. , .
. , (
22.3.4).
,
ManagerSLondon.LocalBranchSGlasgow

LocalBranch, Manager London Glasgow.

22.5.2.
,
. 854

VI.

, .
, .
, .

22.6.
, , s l t S2, S 21 , S23 S 23 . , TSj, TSS Ts7, 3, 5 7. . , ,
. . 22.16. , ( ).
22.16.

ti
1
I

begin transaction

t4

end transaction

TSs

begin__transaction

begin transaction

read (fName, IName)

read (fName, IName)

print (fName, IName!

print (fName, IName)


end transaction

read (fName, IName)


print (fName,
IName)
end_transaction

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


, ( , ) , ,
, . ,
19.2.2 .
, , ,
21.

855

. ,
.
.
, .

, .
, ,
- ,
,
. ,
.
,
. ,
. , . .
.


19.3.2 ,
, , , ,
. , , .
, : , , , , . :
;
;
;
.

, , ' , . , , ,
. , , , S: S2.
S x , S 2
.
856

VI.

- , S:. .


, (Distributed Relational Database Architecture DRDA)
IBM, DRDA , , .
1. .
2. .
3. .
4. .

SQL, .
. 22.9.
1. .
( SQL) . , .
2. . ()
SQL ()
. SQL ,
. ,
, .
3. . ()
SQL (
) .
SQL
, . SQL .
,
, .
4. . ()
SQL ( ) .
. SQL
, (,
/, ).

22.5.3.
,
, . 21.

857

, , . ,

.

, ,
, . , , . ,
, . :
;
, ;
.
,
.
:
, ;
, ;
, .
,
. -

SELECT'
FROM Staff
WHERE salary > 20000

UPDATE Staff
SET salary = salary*! .05;
UPDATE PropertyForRent
SETrent=rent*1.06;
COMMIT;

UPDATE Staff
SET salary = salary"!.05;
UPDATE PropertyForRent
SET
rent-rent'l.Oe:
COMMIT;

UPDATE Staff
SET salary = salary*1.05;
UPDATE PropertyForRent
SETrenl=rent*1.06;
SELECT*
FROM Staff s, PropertyForRent pfr
WHERE s.staffNo = pfr.staffNo;
COMMIT;

'

Puc. 22.9. DKDA: ) ; ) ; ) ; )

858

VI.

, ,
.
, .
- .
, .
.

, [268]. .
[107].
. , [265].
, .

22.7.
DreamHome,
:
Property (propertyNo, city) 10 000 ;
Client (clientNo, maxPrice) 100 000 ;
Viewing (propertyNo, clientNo) 1 000 000 .
, , 200 000 ,
SQL:
SELECT p.propertyNo
FROM Property p INNER JOIN

(Client INNER JOIN Viewing v ON c.clientNo = v.clientNo)


ON p.propertyNo = v.propertyNo
WHERE p.city = 'Aberdeen 1 AND c.maxPrice > 2 0 0 0 0 0 ;
, 100 , 10 , 200 000 ,
100 000 . ,
, 10 000
, , 1 .
[265]

(. . 22.4). , 22.2.
1. Client :
= 1+(100 000 * 100/10 000) = 16,7 .
2. Property Viewing :
21.

859

= 2+[(1 000 000 + 10 000) * 100/10 000] = 28 .

3. Property Viewing ,
, ,
, maxPrice >
200 000 . : .
= 100 000 *

(1+100/10 0 0 0 } + 100 000 * 1 2 , 3 .

4. ,
maxPrice > 200 000 ,
,
. .
= 10* (1 + 100/10 000) + 10* 1 = 20 .

5. Property Viewing ,
, propertyNo clientNo, maxPrice >
200 000 . ,
100 .
= 1 + (100 000 * 100/10 0 0 0 ) = 16,7 .

6. maxPrice > 200 000



:
= 1 + {10 * 100/10 0 0 0 ) = 1 .

22.17.

client

16,7

Property Viewing

28

Property Viewing , ,
,
maxPrice >
200

,
maxPrice > 200 ,
,

860

2,3

20

VI.

. 22.17

Property viewing , 16,7


, propertyNo clientNo,
maxPrice > 200

maxPrice > 200



1 2,3 ,
! ,
, . 23.7.

22.5.4.
, .
. ,
. ,
, 22.1.3.

22.5.5.

, , , . , " ",
.
, . ,
, ,
, ,
. ,
, .
. .
, , .
, SQL 21.

861


.
,
. DreamHome Lease,
, ,
, ,
,
.
,
.
, , .
, , , .
,
.

22.6. ,

( ),
[91]
. ,
, . , .

jjO , 1.
. :

-;
;
.
2.
,
. , , ,
,
.

862

VI.

3.
:
;

.
4.
. .
, , , , .
5.

.
6.
.
,
.
7.
, ,
.
8.
. , :
, , .
9.
.
10.
, .
11.
,
12.

,
21.

863

. ,
.
.
, .


( ), .
,
.
,

. ,

, ( ) .
,

, , ,
.
, ,
.
. ,
, , , , - .
, .
. ,
. ,
.
,
, . ,
, . ,
.
, ,

864

VI.

,
,
, , ,
.
,
,
. .
: .
, . . , .
: ,
, ,

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

, , . -
/ . , . , ^
.
.

22.1. " "


.
22.2.
. ?
22.3. . ?
22.4. ,
.

21.

865

22.5. ? ?
22.6. ?
22.7.
?
22.8. .
.
22.9.
. ,
, ,
.
22.10. ?
22.11. . ,
?
22.12.
? .
22.13. ,
.
. ?
, .
22.14. ,
DRDA IBM. . , .

,
,
.
:
Employee

(NIN, fName, IName, address, DOB, sex, salary, taxCode,


deptNo)
Department (dep_tNo, deptName, managerNIN, businesaAreaNo, regionNo)
Project
(projNo, projName, contractPrice, projectManagerNIN, deptNo)
WorksOn
(NIN, projNo, hoursWorked)
Business
{busines sAreaNg, tousinessAreaName)
Region
(regionNo, regionName)

, .
Employee. , ;
NIN.
Department. , ; deptNo. managerNIN
, . .
866

VI,

Project. ,
; proj No. projectManagerNIW, , , deptNo.
WorksOn. , ,
;
(NIN, projNo}.
Business. , ; businessAreaNo.
Region. , ;
regionNo.
:
Region I: 'Scotland' ().
Region 2: 'Wales' ().
Region 3: 'England' ().

, 'Software Engineering1 (), 'Mechanical Engineering'


() 'Electrical Engineering' ().
, , , . .
, (
Personnel), ( Payroll).
22.15. "-" (ER-)
.
22.16. 22.15 ER-,
, :
) ;
) ( );
) .
, .
22.17. 22.16 Dreamffome, .
22.18. 22.16 EasyDrive School of
Motoring, 2 .
22.19. 22.16 Wellmeadows, 3 .
22.20. 22.5.1 ( )
. .
22.21. , ,
, ,
. - , , ( ) .
21.

867

...


.

.

.
:

* (2);
().
-
.
X/Open DTP.
,
.
.
.
.
Oracle.

. . ,
,
,
. , 19
,
.
,
, , -

.
, .
.


23,1 . 23.2 ( 19.2.2),
, , ,
19.2.3 19.2.5, . 23.3 , , , . 23.4
, ,
. 23.5 X/Open DTP,
. 23.6 ,
, . 23.7
. 23.8
.
23.9 Oracle. . DreamHome,
10.4 .

23.1.

22.5.2 , , , ,
, .
19.1.2 ,
, .

, .
- ,
.
,
, . 8/0

V.

. .
- . , , ,
, .
( ).
, s l f ,
1. (,) S:
, ,
.
2. S x S2 S 3 .
3. S2 S3 . TCj . . 23.1.

,
, .

23.2.

,

. , .

'
;

. 23.1.
23.

871

23.2.1.

, ,
. ,
:
;
, ;

;
, ;
[199].
19.2.1 , , . , .
,
, .

, , . ,

. , . , , , . 23.6
, ..
, .

23.2.2.

, 19.2.2, .
,
( ) , , . ,
. ,
! *, , ^ < 1, * < *
Sx, 3 .
872

V.


, 19.2
. , ,
, .
, () .
,
.
, ,
, . ,
. ,
19.2. ,
, , . , , , .
, , , . 23.3.

23.2.3.
, (2PL), . ,
,
.


, [4],
[122]. , , . 5 .
1. 51
, , . . ,
' .
23.

873

, .

. , .
2. , , ,
.
3.

- , , , . ,
, .
, . , .

, . ,
, .
,
.
, . , , .
. , () 2 + 3 , :
;
;
;
;
.



.

.
(primary copy), a
(slave copy).
, ,
,
[293].
874

V.

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


,
,
.
, . ,
.
,
" " (Read-One-Write-All
ROWA).
, ,
.
,
,
. ,
(- ) ( ), .
, , 5 , :
;
;
;
23.

875

;
.
4, , . System R* [220].


, . ,
, . , ,
, .
,
. , .
, , .
, [303].
, . , , ,
( + 1} / 2 ]
[ ( + 1)/2] . , . , .

23.2.4.
, , 19.2,5. ,
( ) . , , . ,

( 19.2.5) . ,

.


<_, _> [204].
, .


.
, .
/ , .
-
, , , , . , 1 <10, 1> 2 <15, 2>, 2 .
, 2 <5, 2>, 2
<11, 2>.

23.3.

,
( , s ), (. 19.24). (
),
23.1.

23.1.
, 1( 2 3, :
\ 5 S3;
2 S 2 S 3 ;
3 S3 .
( ) ( ) ,
read_lock{Ti, ^) ^
x j ? a write_lock (Tit KJ ) Tj
Xj .

tj

Si

S2

S)

read_lock(Ti, x j

write_lock(T 2 , )
write_lock (T 2 ,

read_lock (T 3 j :

write lock (TI, yi)


write_lock (T 3 , x j

write

write_lock(T 2 ,

lockfTi, )

Z3)

( . 23.2).
, . ,

, . 23.3, , :

23.

877

Puc. 23.2. Slr S2 u S3

, 23.3. Si, S2 S3

, ,
. ,
. : , .



(Deadlock Detection
Coordinator DDC). DDC
.
DDC . DDC
. , DDC , ,
, . DDC , ,
, .
, DDC
, .

. , , .


. , [217]. . 23.4 878

V.

, or Si S8. , .
DDi:j, Si Sj. , .
, , 5 S a .

. 23.4.


,
. , .



, , [229]. ^,
. 1 S t
, Ss, , ^ ^. , S2 , Text TV
, (. . 23.3) s l f S3 S a ,
. 23.5. , Te5tc,
. , ,
TI Slt S a ,
, S2.
, Text.
. ,
.
, 23.

879

S,

S2

S3

. 23.5.

Text .
. , , . ! ,
:

-> Text

->

, .
,
, Sx, Tk, , ,
t s ( T i ) < t s ( T 4 ) . , ts (Ti) < ts (T k ),
51 Sk. s k , Text . , (

), , . .
, ,

.
, . 23,5, :
i:

> 3 ^ \ > Text:

^2

T! 3 TMt

Sa:

-> 2 -> 3 - T ext

^
, 1( .. S2.
S2 :
, -* ,

880

, ->

V.

, S 2 , , S3. S3 :
Sj:

-+ 3 -> T! -> 2 -> -= Text

, .

. ,
, , ,
.
S

23.4.

,
, .

23.4.1.
22.5.2 ,
:
;
;
;
.

.
, ,
.
.
.
,
- . ,
,
, .
. 23.6. ,
. 23.6, , 1 2 : 1, 4, 5 2, 3 (. 23.6, ).
,
, . , , 5
S2
(-). :
23.

881

. 23.6. : ) ; )

S2 ;
;
;
S2 -.
-,
, S-i
S2, .

23.4.2.
,

.
, . ,
,
,
, .
,
.

.

, , .

, .
, , ,
, 5 882

V.

, S2
. .


,
,
, .
, 19.3, , .
, ,
. ,

, ,
. ,
- . , , . ,
: (2) ().
, , ( )
. , . ,
, ( ). ,
, ,
.

23.4.3. (2)
, : (voting phase)
(decision phase). ,
, .

-,
. . ,
. , ,
. . ,
,
, . ,
.
.
-. .
23.

883

.
1
1. begin_commit . PREPARE.
-.

2
2. ABORT, abort
. GLOBAL_ABORT.
-.
3. READY_COMMIT,
, .
,
commit
. GLOBAL_COMMIT. -.
4.
end_transaction.
, .

. ,
(ABORT)
GLOBAL_ABORT. ,
, .
.
1. PREPARE :
) ready_commit
, . READY_COMMIT;
) abort
. ABORT.
.
2.
-.
3. GLOBAL_ABORT,
abort . .
GLOBAL_COMMlTt
commit .
, , .

884

V.


, -
. . , (COMMIT) (ABORT), . 23.7.

GLOBAL_COMMIT GLOBAL_ABORT. -
,
, (termination protocol).
, .

COMMIT:
beg!n_commit
PREPARE

READY_COMMtT:

READY
/?

GLOBAL_COMMIT
.
:


end of transection

PREPARE:
ready^commit
GLOBAL_COMMIT
GLOBAL ABORT
GLpBAT-_COMMFT:
commit

COMMIT:
begin_cornmit
PREPARE

ABORT:

ABORT
abort

PREPARE:
abort
ABORT

. 23,7. : )
; )

23.

885


, -.
, , , .


: INITIAL, WAITING, DECIDED COMPLETED,
, . 23.8, . - .
.
- WAITING.
,
. ,
,
,
- DECIDED.
. , .
=:< |

INITIAL ':'"

PREPARE

1
'

. 23.8.
: ) ; )

886

V.


,
. .
,
: INITIAL, PREPARED, ABORTED COMMITTED,
, . 23.8, . - , .
- INITIAL. PREPARE. ,
, INITIAL. .
PREPARE ( -), ABORT.
- PREPARED, . , .
,
.
.
, . .
, ,
-.

, - ,
, .
(
),
.
.


,
, ,
. , ,
, .

23.

887


-.
1. INITIAL. .
.
2. WAITING. PREPARE
-, , , . .
3. DECIDED. .
,
. ,
.

- , , ,
(.. ).
-.
1. INITIAL. .
,
-
.
2. PREPARED.
.
, .
3. ABORTED/COMMITTED.
. .


( -),
, . ,
. , SL i
( ), ( ). ,
. Si si+1, S i+2 , ... ,
Sn, . Sk , Sk ,
, .
, . 888

V.

, . ,
.
-,
.
. ,
, ,
.

( ),
. , ,
, -
, . 23.9, .
,
, . .
,
(. 23.9, ). 1, 2, ..., , 1
, .

,
, . 2. 3. 2, , 4, ,.
, , , .. . , -1, -2 ..,
.
, .
, ,
,
[30].
, ,
, . 23.9, . PREPARE
,
.
23.

889

.
( ),
, [282].

GC/GA
/
..
' UN-""- 2 "- "- fr>

]
1
PREPARE

RC/ABORT

RC/ABORT

GC/GA

GC/GA

GC/GA
1

6)

2
"

. 23.9. :
) ; ) ; )

. ; PJ ; RC
Ready_Commit; GC Global_Comtnit; GA Global_Abort

890

V.

23.4.4. ()
, , , . , , - ,
, ,
, .
, . ,
[282]. , . ,
, .
.
.
.
(
-).
,


. , . PRE-COMMIT. , , ,

, . . ,
.
, , .

. 23.10. , - , ,
PRE-COMMIT , , .

23.4.5.

, , .
, ,
23.

891


PREPARED

PREPARED

. 23.10. :
) ; )

- , ,
, .
, .
, .
,
.
.


,
, , , . 23.1.
, 1 , 10 . Ik> ' ,
5 . ,
bal x 100 .
bal x 90 . 1, , , .
1 80 .

892

V.

23.1.

ti

,
begin_transaction

2
begin_transaction

t2

balx = balx - 10

bal x = bal K - S

t3

write (bal-J

w r i t e (bal x )

t4

commit

commit

t5

begin_transaction

ts

balx = balx - 5

t?

write (bal x )

te

commit


,
, , ,
. 23.2. , ,
( 1) .
: , 1
60 , 2 ,
bal x 50 . ,
bal x , 100 .
1 40 , 50,
, .

-10 , .
23.2.

ti

begin_transactio
n

begin_transaction

ta
tj
tt

bal x = bal x - 60

balx = balx - 50

write {balx)

write (baly)

commit

commit

, , ,
[95], [96].
, - . ,
,
.
, , ,
[282].
23.

893

, , ,
. .


, , , ,
. ,
, 23.2. , , .
.


, ,
, . ,
,
.
.

, . 19.2.4 . , . , - ,
.
. ,
.
,
.

23.5.
/
Open Group ,
,
. 1996 /
Company Ltd. ( 1984 ) Open Software Foundation
( 1988 ). / Distributed
894

V.

Transaction Processing (DTP)


, .

, , .
,
,
( ACID), 19.1.1. X/Open DTP
: , (Transaction
Manager ) (Resource Manager RM).
, ,
, . , .. , . , ,
,
.
.
, ,
, . . .
/Open , . 23.11. . , ( ), .
. , , SQL ISAM.


(,

BEGIN, COMMIT,
ABORT


PREPARE, COMMIT, ABORT

. 23,11. X/Open

.
tx_open tx_close. .
tx begin. .
23.

895

tx_commit tx^abort. .
.
_ xa_close. .
xa_start xa_end.
.
xa_rollback.
.
_. / .
xa_commit.
.
xa_recover. ,
, . ,
( , ), .
{ ) , . , ,
, .
xa_forget.
, .
, .
tx_begin();
EXEC SQL UPDATE Staff SET salary = salary*!.05 WHERE
position = 'Manager1 ,EXEC SQL UPDATE Staff SET salary = salary*!.04 WHERE
position <> 'Manager';
tx_commit <);

tx__begin() Call Level


Interface (CLI)
.
SQL ( ). ,
,
,
UPDATE SQL. ,
tx__commit { } ,

. , .
896

V.

BEGIN,
COMMIT,

ABORT

' ,"~

'

.i

^.

pecypco&j/i

. - . ;

5
"'
'

"-.

. 23.12. /

, , , . X/Open DTP . 23.12. ,
(Communication Manager ).
,
.
.
. ISO ROSE (Remote Operations
SErvice) RFC (Remote Procedure Call). ( --) /Open OSI-TP (Open Systems Interconnection Transaction Processing).
X/Open DTP , (. 19.4).

.
X/Open
. , , . CICS Encina IBM
( IBM AIX Windows NT, TXSeries IBM),
Tuxedo BEA Systems, Oracle, Informix SQL Server.

23.6.
22.1.2,
,
, , , . , , 23.

897

, -, . , , ,
.
. .

23.6.1.
. ' . .
, ,
. ,
( ,
), ,
"" , .
, ,
.
, .


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

, . .
.
.
,
, , ,
.
898

V.


,
. ,
, , [43].
.
, .
. ,
. 22,1.3, , .
. , . ,
( ).
.
, , .
. ,
, .
. , .
.
, .


,
'.
"/", " " " ". ( ) ,
"/"
"/" ,
( )> . (
, )
.
" " , . , , . , .
,
, , .
.
23.

899

(). , ,
. , DreamHome .
,
,
.
. , , , . ,
, ,
, tte . . 23.13, .
.
, ,
, , .
. , ,
DreamHome.
, () , . . 23.13, .
.
.

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

PropertyForRent, Client Lease. ,
,
,
, .
900

V.


( )


( )


( )


( )

(-)


(-)


(-)


(-)


(-)

{ )

. 23.13. "/"; ) ; )

23.

901

" "
"/",
. " "
. , . ,
, , , , ..
, , . ;
, , . " "
, , , . 23.14,
" " ( )
: " .
.
.
, .
, .
, , DreamHome
" ", , ,
,
, .. ,
. . ,
. , , , , . . , ,
, .
(
)

Billing
ownerNo leaseNo
087
40.

LN34
LN7B

Billing
status

;
--

ownerNo leaseNo

status "'-.

087
40

, -,
- -'

LN34V;
LN76'-:.

. 23.14, ", "

902

V.

,
, , , . 23.15.
,
. .

23.6.2.

, , .
, .
.
.

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

, . ,
. -

Glasgow
(-)

Aberdeen
(-)

London
(-)

Edinburgh
(-)

. 23.15. ,
( )

23.

903

. 23.16, . ,
.
,
.
, , .
, . 23.16, . ,
, .


. ,
, .

,
, , , , ,
, 23:00. , Staff
() , , s t a f f , . S t a f f , , . Oracle
23.9.2.

. .
,
.
,
Transactiorf :;t
Update Relation A-

Update Relation
Update. Relation.!?' ...
Commit : ",

Transaction Update Relation A commit;


Transaction Update Helalion.B commit;
Transaction Update Relation commit;
Transaction Update Relation D commit;

ll
Transaction .,>
Update Relation A
Update Relation ..
Update Relation CJUi
Update Relation D^
Commit

Transaction...
Update Relation A >i|
Update Relation 1
Update Relation If
Update Relation
|
|
Commit .'

B)

. 23.16. : ) ;
)

904

V.

,
,
.
-: , .

. ,
, . .

,
. ,
,
. ,
Oracle staff ,
RENTALS. GLASGOW. NORTH. COM
(. 23.9.1), .
CREATE TRIGGER S t a f f A f t e r l n s R o w
BEFORE INSERT ON S t a f f
FOR EACH ROW
BEGIN
INSERT INTO StaffDuplicate@RENTALS.GLASGOW.NORTH.COM
VALUES (:new.stafNo, :new:fName, :new:IName, mew,position,
:new:sex, t n e w . D O B , :new:salary, :new:branchNo);
END;


Staff ,
,
, .
.
, ( , , ).
.
,
. , .
.
,
. . , , .
23.

905

,
. ,

.



, ,
. , ( ) , .
, . , ,
.
,
.
. , , .
. , .
, . . ,
,
salary = salary + .
. , .
. , . ,
.
.
.
,
.
.
. , .
. .
. -
, .

906

V.

,
, , ,
, ,
. . ,
UTC (Universal
Coordinated Time ) , , .

23.7.
20 , :
;
.
,
, .
20 .
.
22.5.3,
,
. , , , .
, ,
. -
,

,
, .

23.7.1.
20 , ,
, .
. , 20.3.2
,
. - .
, , . . one 23.

907

. ,
, . . .
:
;
;
.


: . , ,
, . , :
(R1 R2) IX R3 = (R1 X R3) U (R2 X R3)

, . >
. , , .
23.2.

23.2,
, ,
.

SQL:
SELECT *
FROM Branch b, PropertyForRent p
WHERE b.branchNo = p.branchNo AND p.type = ' F l a t 1 ;

, PropertyForRent Branch :
PI=

0- brail chNo,'Boo3-

BI:

ObHinchlfo.-' (Branch)

2=
2:

1.-- ='Flat'(PropertyForRent)
ObrwiehMoi.-' (Branch)

.;,-' {PropertyForRent)

..' (PropertyForRent)

. 23.17, .
, , 908

V.

, ,
. 23.17, . , (..
) :
af ( P i )

typ e = 'House' ( PrOpertyForRent ) )

, 2 , .
, , . 23.17, . , .
, . 23.17, .
. nchNo=p. branch N

. branehNo ' p. bnnch No

nc h No = . chN a

>

'"'b.brancllNo ^ p. branch No

p.typ--Flar

. 23.17. , 23.2: )
; ) , ; ) , ; )

23.

909



,
, .

23.3.
.
SQL:
SELECT fName, INarae
FROM S t a f f ;

Staff, 22.3:
^1: ' 'staff No, position, sex, DOB. salary I b C S t I
&2:

, fName, IKame, branchWo ' St af f }

. 23.18, .
, , fName IName . . 23.18, *.

""

Si

"""

?2

. 23.18. 23.3: ) ; )


, . , ,
.

23.4.

,
' ', .
SQL:
910

V.

SELECT *
FROM Branch b, Client
WHERE b.branchNo c.branchNo AND b.branchNo = ' B O Q 3 1 ;
, Branch
, 23.2, Client
Branch:
3 = .'' (Branch)
32 ! , '
R, = Client >branChNo Bi i = 1, 2

(Branch)

. 23.19, .

,
. ,
' '. , , . 23.19, . ! 2 .
. 23.19, .

'""b branch No=.bran chNo

. 23.19. 23.4: ) ; ) ; )

23.7.2.

. ,
,
(. 4.1.3).
: .
, ,
, .
, , S2
R! >< R 2 , RX Ra ,
S2, R! R2 =( , 3 , ... , aj =( 1 (
23.

911

2 , ... ) . . ,
:

.
1. R' - ( 2 ) S2 ( , S^2. R' S^
3. R" = RI > R' S^
4. R" S2.
5. R" xix R2 S2.
,
RJ R! R 2 .
R!, , .
[29]. ,
- .

23.8.
, ,
.
, , , , . , PDA (Personal Digital Assistant "" ) Internet. ,
,
, .
, , , ,

, .
.
. ,
,
;^ , ^
912

V.


, PDA
Internet, .
. 23.20.
:
, , ;
,
,
;
,
, PDA Internet;
.
,
,
, , , .

.
, .

. 23.20.
23.

913

:
. .

23.8.1.
.
.

, . ,
, .

Internet,
, .
,
.
, ,
Internet.
.
.
,
.
,
,
,
.
SQL; ,
.
,
, , .

23.9.
Oracle

, Oracle 8i [238], [239]. Oracle,
. Oracle
8.2.

914

V.

23.9.1.
Oracle
, Oracle , 22,
.
, ,
. ,
Oracle . ,
, .

Oracle, :
;
;
;
;
;
.
Oracle .


Oracle NetS ( Oracle
SQL*Net). NetS
, . , . NetS
,
, .
, . NetS , TNS
(Transparent Network Substrate ), , , (,
TCP/IP SPX/IPX).
, .
Oracle (Connection
MANager CMAN), Oracle 7
Multiprotocol Interchange.
Oracle Names , .
,
Oracle Names . Oracle Names
tnsnames.ora .

23.

915


,
, .
Oracle
, .
Internet,
,
. , . 23.21
DreamHome.
Rentals, ,
,
LONDON.SOUTH.COM. Rentals
:
RENTALS.LONDON.SOUTH.COM
RENTALS.GLASGOW.NORTH.COM


Oracle ,
Oracle (, Oracle). . , , .
,
, ,
. ,
, :
CREATE PUBLIC DATABASE LINK RENTALS.GLASGOW.NORTH.COM;


. -

. 23.21. DreamHome

916

V.

databaselink , SQL. SELECT.


Oracle INSERT, UPDATE DELETE. ,
Staff SQL:
SELECT * FROM StaffRENTALS.GLASGOW.NORTH.COM;
UPDATE StaffRENTALS.GLASGOW.NORTH.COM SET salary = salary*!.05;

,
. . , , viewing Supervisor, SQL:
SELECT * FROM Supervisor.ViewingRENTALS.GLASGOW.NORTH.COM;


, Viewing
Supervisor. ,
Viewing Supervisor ,
. , Viewing Viewing , Supervisor:
CREATE SYNONYM Viewing FOR
Supervisor-Viewing@RENTALS.GLASGOW.NORTH.COM;
SELECT * FROM Viewing;

, , .


Oracle ( ,
, ). , ,
.


Oracle ,
, , Oracle. Oracle
, , Oracle.
, Oracle, Oracle. , Oracle, SQL, , , Oracle.

23.

917


.
.
SQL , Oracle,
DB2/400, DB2 OS/390, Informix, Sybase, SQL Server, Rdb, RMS NonStop SQL. ,
Oracle, , Oracle. DRDA (. 22.5.2), SQL DRDA, DB2, SQL/DS SQL/400, Oracle .
.
(RFC Remote Procedure Call) ,
, Oracle. ,
RPC PL/SQL CICS, IMS/TM IDMS/DC, ,
ADABAS, CA-IDBS, IMS, VSAM DB2. Oracle .

.
. Oracle, , Oracle,
(. 23.4.3).
SQL. SQL, , SQL,
, Oracle.
. PL/SQL Oracle 8i , .
. , Oracle, Oracle,
SQL, Oracle, SQL, , Oracle.
SQL .
, Oracle,
SQL, .
, Oracle, SQL, ,
PL/SQL.
.

,
, Oracle, Oracle.


Oracle
,
. .
918

V.


.
, .
Oracle , 20.6.

23.9.2. Oracle
Oracle , ,
. Oracle , , , , , . Oracle ,
. Enterprise Edition ,
.
Oracle. , Oracle.


Oracle .
, . . . ; .
. ,
, , , , .
,
. .
.
,
.
, .
. .
.


Oracle , . ,
, . , .
.
23.

919


Oracle .
. , .

( ). ,
.
. , ,
,
.

,
,
.
.


, , , Oracle .
,
. ,
PL/SQL, DBMS_REFRESH. , , , LocalStaff, LocalClient
LocalOwner :
DECLARE

vSnapshotList DBMS_UTTLITY.UNCL_ARRAY;
BEGIN
vSnapshotList(1) = 'LocalStaff1;

vSnapshotList (2) = 'LocalClient!;


vSnapshotList (3) = ' LocalOwner' ,DBMS_REFRESH.MAKE (name => 'LOCAL_INFO', tab => vSnapshotList,
next_date => TRUNC(sysdate} + 1, interval => 'sysdate + I 1 );
END;


Oracle
.
COMPLETE. , ,
. ; .
Oracle
. , ,
,
, , .

920

V.

FAST. , , ,
, . , , , , .
,
. ,
() .
EORCE. , ,
. , Oracle
.


,
.
1. () (),
, ,
.
2. ()
().
3. ( )
, FAST.
4. CREATE SNAPSHOT. , , ,
:
CREATE SNAPSHOT Staff
REFRESH FAST
START WITH sysdate NEXT sysdate + 7
WITH PRIMARY KEY
AS SELECT * FROM StaffRENTALS.LONDON.SOUTH.COM
WHERE branchNo = ' B 0 0 3 ' ;

SELECT
( RENTALS.LONDON. SOUTH.COM), . START WITH , , .
Oracle SNAP$_Staff, Staff. Oracle
Staff, SNAP$_Staff.
.
5.
.


, , .
CREATE SNAPSHOT LOG. , Staff
:
23.

921

CREATE SNAPSHOT LOG ON Staff


WITH PRIMARY KEY
TABLESPACE DreamHome_Data STORAGE
(INITIAL 1 NEXT 1M PCTINCP.EASE 0) ;

DreamHome .mlog$_Staf f, Staff ( s t a f f N o ) , , /


. Oracle ,
S t a f f ,
, .

Oracle Replication Manager.


,
, , ,

. ,
,
, .
FOR UPDATE CREATE SNAPSHOT.
s t a f f Oracle , .
1. SNAP$_STAFF , .
2. USLOG$_STAFF , .
.
3. USTRG$_STAFF SNAP$_STAFF,
, USLOG$_STAPF.
4. STAFF$RT SNAP$_STAFF, ,
STAFF$TP.
5. STAFF$TP ,
RPC, STAFFSRP .
6. STAFFSRP, ,
7. STAFF$RR, .
8. s t a f f , SNAP$_STAFF.
9. , DBMS_REFRESH.



23.6.1. Oracle , , .
, .
,
, , , .

922

V.

DBMS_REPCAT, ,

staff
Staff (, salaryTimestamp)
:
EXECUTE DBMS J?EPCAT . MAKE_COLUMN_GROUPS

fgname => ' H R 1 , oname => 'STAFF', coluran_group => 'SALARY_GP',


list_of_column__narnes => 'staffNo, salary, salaryTimestamp 1 ) ,EXECUTE DBMS_REPCAT.ADD_UPDATE_RESQLUTION
(snarae => ' H R 1 , oname => 'STAFF', column_group => 'SALARY^GP',
sequence_no => 1, method => 'LATEST_TIMESTAMP',
1
parameter_column_name => ' s a l a r y T i m e s t a m p ,
comment = 'Method 1 added on' | | sysdate);

DBMS_REPCAT
. ,
Oracle Replication
Manager.


,
, . , . ,

. , , ,
.
RPC, . , .

, ,
. ,
, .
, ( KOS) , , . ,
.
: .
, . 23.

923

, . ,
. ,
.

. , , . : , .
, ,
. ,
.

.
. , .
, .
, , .
.

.
.
X/Open DTP , OSI-TP
.
, , ,
.
. ,
,
. , ( , ), , ,
.
,

. ', , .

924

V.


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

.

.
.
, ,
,
. ,
.
,
.
,
.
, PDA Internet,
.

23.1.

23.2.

23.3.
23.4.
23.5.
23.6.
23.7.
23.8.

.',,: " ,:: "'

, , , .
.

. .
,
.
" " ,
.
?
. .

.
.

' "

'""

- ; ;:;.-- - ; ;; <-

>'

-,' ~ ^"^"

" & <"=

- "'" !

"

"

' - "-

- '

-;-

- . -;;

- "-

"',">,'

23.9. DreamHome ,
,
.
23.

925


, . ,

. ,
.
23.10. . .
23.11.
.
.
23.12. , ,
X/Open DTP .
23.13. : \, 2 , 3, 4 .
TV Sj S 2 .
2 5^
3 S: S3.
4 S3.
5 S3.

,

T1

Xi

X;

^i

Si

3
XT

Si

^5

S2

ST.

Ts

XT

S3

) . , ?
) ,
. ?

926

V.

...
,
.
,
.
- :
, ;
;
;
;
, , ;
;
.
, .
.

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

(-) .
, , ,
.

.
25
, . 26
, ODMG (Object Data Management
Group
), , ObjectStore, 27 ,
. , SQL3, ANSI/ISO SQL; , - Oracle.
, .

24.1 , ,
. 24.2 ,
. 24.3
- , 24.4 ,
.
24.5 ,
- . ,
, DreamHome, 10.4
.

24.1.

1990- . , , , .
,
.
.
.
.
.
928

VI.

.
.
Web-.


(Computer-Aided
Design CAD) ,
, ,
. .
,
. . , DreamHome ,
, PropertyForRent, Client Viewing,
.
, , , .
.

. ,
.
-
, , ..
.
, , , .
.
,
.
. ,


(Computer-Aided
Manufacturing ) , CAD, a
, (, ) (, ). ,
, : , . , , ,
. , 24.

929

, .

.
.
,
, .
, .
, , .


(Computer-Aided Software Engineering CASE) , : , , , ,
, . CASE, CAD, , . , ,
, ,
. ,
,
.


. , , .
, ,
. , ,
, , , :
Node Link <=* Node <=> Link <=> Node <=^ Link <=> Node

Node ,
Link ,
. , , , .
,
, , .
930

VI.


(Office Information System
OIS) , , , , ..

, , ,
. , , , - . , , ,
. , , , , SGML
(Standardized Generalized Markup Language), HTML (HyperText Markup Language)
XML (Extensible Markup Language), 29.
, ,
1
Internet. , ,
. ,
.
ASCII
, . , ,
..
Dreamffome .
. . , . .
, (, ).
. ,
. ,
.
, (, ,
).
. , ' , World Wide Web (
" ")
,
. World
Wide Web 28.

24.

931

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


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


(Geographic Information
Systems GIS) , .
,
. , , ,
.
, NASA 1990- ,
EOS (Earth Observing System
), ,
,
. ,
. EOSDIS (EOS Data and
Information System). EOSDIS ,
, . ,
EOSDIS .
,
, ,
, .

932

VI.

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

. ,
,
. ,
,
-, [198].
28 29, Web , , XML, , .
Forrester Research Group ,
99%
2003 1,3 . , , 2003
3,2 5% . Internet Web
.
.
'rv 24.

933

,
, ,
.
,
, .
,
,

24.2.
3 ,
.
SQL,

. , (OLTP),
.
, , , . 24.1
, - . , .
24.1.








, ,


, " ". " " ,
, . 20, .



. ,
" " (*:*) 934

VI.

: ,
.
, . , " " (1:*)
: Has (), Owns (), Manages () ..
,
. - , .
, .. ,
, . [161] [248]. . ,
(. 3.2),
(. 13).


, , .
3.3 ,
3.2.1 ,
. ,
, .
, ,
, . , ,
.
5 6, SQL , (DDL ),


,
. , , , . , .
" " ,
, , , .
, .
,
, , , ,
, .. 24.

935

, . [17] [179]. .
1. (, ,
, ) .
2. a l f , ..., , 1? o 2t ...,
, [ : : , 2 : 2 , . . ., : _] .
3. o l f 2, ..,., , S={olf 2, ..., } -.
.
, John, Glasgow.
{SG37,

SG14f

SG5}.

[branchNo:BOQ3,

street:163 Main St, c i t y : G l a s g o w ] .


[branchNo: B 0 0 3 ,
city:Glasgow, StaffNo:(SG37, SG14, SG5}].

street:163

Main

St,



{[branchNo:B003,
street:163
Main
St,
city:Glasgow], [branchNo:B5, street:22 Deer Rd, city:London]}.

{ [branch.No:B003,
street:163
c i t y : G l a s g o w f S t a f f : { S G 3 7 , SG14, S G 5 } ] , [branchNo:B5,
Deer Rd, city:London, s t a f f N o : { S L 2 1 , S L 4 l } ] } .

Main
St,
street:22


BLOB (Binary Large Object BLOB).
BLOB , , , - ,
.
BLOB . .
, .
BLOB . , , , BLOB
BLOB, .
, BLOB . , BLOB. ,
.
,
. BLOB . 17.6.


,
, SQL, .
"
". , GIS , , , , .
936

VI.


,
.
, .. ,
( ) .
Staff, , (. 24.2).
24.2. Staff

, ' S 0 0 5 ' ?
:
SELECT managerStaffNo
FROM Staff
WHERE staffNo = 'S005'
UNION
SELECT managerStaffNo
F30M Staff
WHERE staffNo = (SELECT managerStaffNo
FROM Staff
WHERE staffNo = 'S005');


. , . , : " , ",
SQL.
SQL , ,
21. ,
. ,
, , .
(transitive closure)
(recursive closure) [218].
. R (&lt A 2 ), (
, ; R, , : (,) (,)
^ R, (, ) .
24.

937


. , ,
, .
S t a f f . 24.3.
24.3. Staff
staffNo

managerStaffNo

S005

S004
S003

SOQ4
S003

S002

S002

S001

S001

NULL

S005

S003

SOD5

S002

S005

SCI 01

S004

S002

S004

S001

S003

S001


5.1 , SQL-92 . (DML Data Manipulation Language)
. SQL
SQL, ,
21,
(impedance mismatch),
, .
SQL ,
,
, , ,
.
SQL . , SQL Date Interval, . ,
, ,
. ,
30% [10]. , -

.
-
938

VI.

, [93]. . .


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

, - ,
[300].
, .

, , .. .
, .
, . , .
SQL, .. SQL3, . ,

, , . SQL3 27.4.

24.3.


.
, .
24.

939

24.3.1. ,


.
,
, . , , ,
. .
, ,
, . , , . , - , ,
, . , . ,
,

. " ",
, . ,
Smalltalk, .
, Smalltalk
. ,
- , .
:
- ()
. -

(Abstract Data Types ADT).
. , ,
ADT , . .

, .
, : ADT , ,
ADT [12].

24.3.2.
-
Simula,
1960-
[85], -
940

VI.

Smalltalk [128]. Simula ,


, , . , :
, ( ). , Simula .
1

, , , > " " . ,

DreamHome
, .
: . , 11.1.1.
, .
, (instance variables). ,
1
, '163 Main Street , , . 24.4. .
(, ,
, ..) . , branchNo . 24.4
' ' . /
. , SalesStaff
S t a f f . .
( ), . , SalesStaff, ,
Staff.
. , , ( 24.3.9).
24.4. Branch

branchNo

' '

street

'163 Main St'

city

'Glasgow'

postcode

'Gil 9QX'

SalesStaff

| Beech'; 'David Ford 1

Manager

'Susan Brand'

"" , , street , .
branchObj ect.street

24.

941

24.3.3.
, - (Object IDentifier OID), :
;
;
, ,
; OID
,
;
(.. ;
,
OID);
( ).
, ,
,
(. 3.3.2). ,
, , ,
.
, , ,
.
OID ,
, .. . ,
DreamHome Staff Branch
Branch Has Staff.
,
,
13.2.
OID ,
- . , ,
(. 3.3.3). 25.7.2.
.
,
..
.
, - . -,
,
,, . -,
,
. ,
, branchNo. ,
942

VI.

. , 1
, ' B O Q l , ' B 0 0 2 ' ' ' , .
, , [186]. , C/C++ OID .
,
,
, , . , ,
, . , , , , , . ,
. . OID
25.2.

OID .
. OID
. ,
.
. OID
, . , ,
: .
. OID , , ,
, . , .
. OID
, , .
,
OID.
,
: ( ),
. OID .
' OID , ? , ,
.
,
, .
() , ; 24.

943

OID,
(=). ,
, (==).
, : ,
, ,
; , , .

24.3.4.

. ,
. 24.1
, .

. 24.1.

.

. , ,
, .
,
, . -
,
. ,
24.1 , .
updateSalary Increment, salary .

944

VI.

24.1.
method void updateSalary{float increment)

salary = salary + increment;

. , ()
() , -
. ,
. . ,
updateSalary Staff
1000 :
staffObject.updateSalary(1000)

:
u p d a t e S a l a r y ( s t a f f O b j e c t , 1000}

24.3.5.
Simula . , , , .
, . , Branch. (instance). ,
, . 24.2.
"" "" ,
. ""
[11]. .
, . ,
, .
, "" , .
- , .
, .
, Branch .
.
24.

945

branehNo
street

Branch

branchNo
street
city
postcode

printO
getPostCodef)
numbefOfStaff{ )

tf

branChNo=BOO?
street =16 Argyll St
city = Aberdeen spostcode

\
branchNo BOOS
street =163 Main St
city = Glasgow-.-:-;Jj
postcode

. 24.2. ,

. -
new.
. , . ,
, .

24.3.6. ,
, . ,

(
).

(inheritance) .
, .
(generalization), . . , ,
.

946

VI.

. ,
,
.
, , "-"
12, , - , .
(A Kind Of),
Manager Staff .
-,
Susan Brand Manager IS-A.
: (single),
(multiple), (repeated) (selective). . 24.3
, Manager SalesStaff S t a f f . ,
.
staff Person, ,
, .
. 24.4 ,
SalesManager Manager SalesStaff. , , , .
- .
, , . ,
, .
.
1.
. , bonus () Manager SalesStaff, SalesManager
bonus
SalesManager Manager. bonus SalesStaff .bonus.

. 24.3.
24.

947

2.
.
, . 24.4,
:
Sales_Manager -* Manager - SalesStaff

Sales_Manager - SalesStaff - Manager


,
SalesManager bonus, Manager, SalesStaff.
3.
.
4. , .

. 24.4.

,
.
, , Manager SalesStaff Staff, . 24.5. SalesManager S t a f f .
, .

.
, (. 6.4),
.

24.3.7.
, , , . . , , . , Staff
.
method void giveCommiselon(float branchProfit)

948

VI.

salary = salary + 0 . 0 2 * branchProfit;


Manager
. giveCommission Manager.
method void giveCommission(float branchProfit)
{

salary = salary + 0.05 * branchProfit;

. 24,5.





- .
, .

(overloading).
. , , , . , ,
, 24.2 24.3.
24.2. Branch
method void p r i n t ( ) {
printf("Branch number: % s \ n " , branchNo);
printf("Street: %s\n", street);
p r i n t f { " C i t y : %s\n", city);
p r i n t f ( " P o s t c o d e : %s\n", postcode);

24.

949

24.3. Staff
method void print( ) {
p r i n t f { " S t a f f number: %s\n", s t a f f N o ) ;
p r i n t f ( " F i r s t name: %s\n", fName);
printf ("Last name: %s\n", IName) ,p r i n t f ( " P o s i t i o n : %s\n", position);
printf ! "Sex: %c\n", sex) ,printf("Date of birth: %s\n", DOB);
printf("Salary: %f\n", salary);

,
, , . ,
.
(, printBranchDetails p r i n t s t a f f D e t a i l s ) ,
.

24.3.8.

(polymorphism " "). : , [46]. , ,
(operation polymorphism);
. , , (inclusion polymorphism).
(parametric polymorphism), (genericity),
, , .
template <type T>
(:, :) {
if(>)
return x;
else
return ;
}
max,
. .
.
:
int max(int, int)
real max(real, real)

// max
// max

VI.

, , (binding). ( ) ,
(dynamic), (]ate), .
, Staff Manager
SalesStaff, . 24.3. ,
print . , , (, )
.
CASE
IF:
FOR i=l TO n DO
S W I T C H ( l i s t [i] ,

type)

CASE s t a f f :
CASE manager:
CASE salesperson:
break;
}

p r i n t S t a f f D e t a i l s ( l i s t [ i ] . o b j e c t ) ; break;
printSanagerDetails(list [i] . o b j e c t ) ; break;
printSalesStaffDetails(list[i].object);

, CASE , .
,
print, print
CASE :
list [i] .print ()
, , , , - print - . , (.. ).

24.3.9.
, ,
. ,
" ",
A-Part-Of, ().

. -, . . -,
.
,
. (referential
sharing) [187]. , .
, . -

24.

951

, . , BLOB (. 24.2).

24.4.

( ) - , C++
Java, .
(.. ) ,
. , . , , , . 24.6,
Staff : Manager,
SalesPersonnel Secretary.
.
,
.
; ,
:
, ;
* ,
.
.

. 24.6. Staff

952

VI.

24.4.1.

,
. ,
, ,
, . .


. , . 24.6,
( ):
S t a f f (straffNo, fName, IName, position, sex, DOB, salary)
Manager (stafjNg, bonus, mgrStartDate)
SalesPersonnel (stajfNo, salesArea, carAllowance)
Secretary (sjtaffNo, typingSpeed)

, , . ,
.
, : , . , , ,
.


. , . 24.6,
:
Manager ( s t a f f N o , fName, IName, position, sex, DOB, salary, bonus,
mgrStartDate)
SalesPersonnel ( s t a f f N o , fName, IName, position, sex, DOB, salary,
salesArea, carAllowance)
Secretary ( s t a f f N o , fName, IName, position, sex, DOB, salary,
typingSpeed)
, ,
. ,
.



;
:
Staff ( s t a f f N o , fName, IName, position, sex, DOB, salary, bonus,
mgrStartDate, salesArea, carAllowance, typingSpeed, typeFlag)

24.

953

typePlag , ,
(, Manager 1,
SalesPersonnel 2, Secretary 3).
. ,
, , . ,
Manager NULL
salesArea, carAllowance typingSpeed.

24.4.2.
, , . ,
, (.. , ), :
Manager* pManager = new Manager;
// Manager
. . . ...
EXEC SQL INSERT INTO Staff VALUES( : pManager->staffNo, :pManager->fName,
:pManager->lName, :pManager->position, :pManager->sex, :pManager->DOB,
:pManager->salary) ,EXEC SQL INSERT INTO Manager VALUES (:pManager->bonus,
:pManager->mgrStartDate);
, Manager
( ),
-
() :
Manager* pManager = new Manager;
25.3 . (, , , bonus, 1000 ), :
Manager* pManager new Manager;
// Manager
EXEC SQL WHENEVER NOT FOUND GOTO done; //
EXEC SQL DECLARE managerCursor //
SELECT
CURSOR FOR
SELECT staffNo, fName, IName, salary, bonus
FROM Staff s, Kanager m // ,
// Staff Manager
WHERE s.staffNo = .staffNo AND bonus > 1000;
EXEC SQL OPEN managerCursor;
for ( ; ; ) {

EXEC SQL FETCH managerCursor

//
//
INTO :staffNo, :fName, rlName, :salary, :bonus,pManager->staff No = : staff Mo,- // Manager
954

VI.

pManager-> fName = :fName;


pManager->lName = ;IName;
pManager->salary = :salary;
pManager->bonus = : bonus,strcpy(pManager->position, "Manager");
EXEC SQL CLOSE managerCursor;

//
//

, :
os_Set<Manager*> khighBonus
11
= managerExtent->query! "Manager* , "bonus > 1 0 0 0 " , dbl) ;

Manager
(manage r Ex tent) ( dbl) (bonus > 1000). -
ObjectStore os_Set,
Manager, <Manager*>.

- ObjectStore 26.3.
, -
. , - , , .
, 30% ,
.

24.5.
1960- 1970-
. , IMS (Information
Management System) IBM.
, , Apollo.
, , , ,
. .
.
,
, ,
.
.
.
1970 . 24.

955

,
. ,
1970- 1980- . 100 , . .
* 24.2,
,
.
. 1976 "-", , 14 15 [55]. 1979

RM/T [70], RM/V2
[77].
" " . .
[153].
[274].
[297].

"" : - (Object-Oriented
Data Model OODM) - (Object-Relational
Data Model ORDM),
(Extended Relational Data Model ERDM). ,
, .
, . 24.7.
- ,
1970- . ,

, . ,
,
.
, ,
. ,
,
, .
, - , ,
, ,
, . , , SQL, - 25 26,
- 27.

956

VI.

,
'=

.-;,-.
:

'"-

ER-

- &1

-
;

. 4.7.

'
(Computer-Aided Design CAD), {Computer-Aided Manufacturing ), (Computer-Aided
Software Engineering CASE), (Office
Information System OSI) ,
(Geographic Information Systems GIS), Web-, .
, ,
, "
", , , . ,
,
.
,
, .
,
, .
24.

957

, ,
" ", ( ). .
.
-
( Object IDentifier), .
.


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

. , . ,
.

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

"" : - . , ,
. .

24.1.
.
24.2.

?

958

VI.

24.3. - :
) , ;
) ;
) ;
) ;
) , , ;
) ;
) .
,
DreamHome, . 3.3-3.9.
24.4.
, -
?
24.5. .

24.6. , 24.1, , . ,
,
, .
, - , 24.3.
24.7. , . - , . ?
24.8. Branch, Staff
PropertyForRent DreamHome,
.

24.

959




...

.
.
- .
,
, , .
.

- .

.
.
- ,
, ,
, .
- .
-
.
- .

, , . ,
- ,
. -
.

, ,
,

, , . ,

,
.


.

-
, - (). - .
( 3% 1997 ), , World Wide Web. ,
50% , .
26 , ODMG
(Object Data Management Group),
.
ObjectStore.

. , 27
-
,
.
- , .


25.1 -
, , ,
,
. , . 25.2
, . 25.3 . 25.4 , : ,
, ,
, 25.5 " - ", , .
25,6 ,
25.7
, 14 15, - .
, 24.
DreamHome,
10.4 .

962

VI.

25.1. -

, - . , [188] -
(), - () ().
. () , ,
~ .

. , () .,
.

. () .
,
- , .
. ,
[330] ,
.
1. .
2. .
3. .
4. .
, , ,
, . [186]
- .
1. "- " = " " +
"" + " ".
2. "- " = "- "
+ " ".
, [247].
1. , .
2. , .
3. , ,
.
4. "- " = "- "
+ " 1-3".
25. -

963

, GemStone
Gemstone Systems Inc. ( Servio Logic Corporation),
Itasca IBEX Knowledge Systems SA ( - Itasca
Systems Inc.). Objectivity/DB Objectivity Inc., ObjectStore
eXcelon Corporation ( Objectivity Inc.) Ontos
Ontoa Inc., Poet Poet Software Corporation, Jasmine
Computer Associates/Fujitsu Limited Versant Versant Corporation,
, -
, . 25.1.
26.2 , ODMG, -. ODMG
,

.

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

, .

',

":

'

.
;

^

. 25.1. -
964

VI.


[49].
.__

-:

- - ^

<

,> :

:-,

. , , , - ;[
.


, , ,
, , [16]. 21, ISO SQL , SQL ,
, Fortran, Pascal, COBOL, Ada, MUMPS PL/1. , SQL .
. API, . SQL , , SQL2 1
. ,
, (impedance mismatch)
(. 24.2). ,
30%

, [10]. .
, [221].

.
, .
.


. ,
. , PS-algol
NapierSS, . ,
, ,
, . ,
.
.
1
(SQL3) ,
SQL .

25. -

965

, , .
,
, 25.2.
(,
, ) , . ,
,
, , 25.2-25.4,

. (Persistent
Application System PAS) [13].

25.1.2.
, [186].
.
, Smalltalk, C++
Java (. . 25.1). GemStone,
.
- .

- .
, , , , , ,
.. Ontos, Versant
ObjectStore. ObjectStore 26.3.
-
. 21
SQL . . 2,
.

.
SQL -
- .
- . -

SQL (SQL3). ( SQL3 27.4.) , Object Database
966

VI.

Standard ODMG Object SQL, 26.2.4. Ontos Versant Object SQL, - ODMG.
. , , ,
, .
SIM (Semantic Information Manager),
[180].

25.2.

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

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

, 24.1. 1980
, . 25. - 967

,
.

.

, . .
, ().
(,
), . , , . , , 30%
. , .
, .

. , - Java
. , ,
, .
, .
,
(. 25.2). , (. 25.3).
,

.
24.3, (OID Object IDentifier), OID OID,
, OID,
.
. . OID , , . ,
OID
. (pointer
swizzling), (object faulting). :
[223]. .

968

VI.

. 25.2. ()

. 25,3.

25.2.1.
;

. .


. ,
(OID).
-
, , OID
. 25. -

969

, , . .
,
OID .
OID .
,
, .

, , .
,
, OID , , [324]. OID. ,
,
, .
, ,
. ,
,
.
, [223].
,
,
,
( Objectivity/DB), .


OID ,
.

(edge marking) (node marking) [158].
,
( ) ( ),

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

.
, , .
970

VI.


( ) [203].
,
( ) . , ,
, .
, ObjectStore Texas [280].
,
, , , ,
.
,
( ,
,
). , , ,
. , , .


,
.


, ,
- [324].
, OID , ,
. ,
.

[223] (eager swizzling), OID
. ,
[184], 25. -

971

, .
, (lazy swizzling)
.
,
,
.

, , . . ,
. ,
, ,

25.2.2.
, . ,
, ,
, . 25.4 .
,
,
, (. 20.4). .

. SQL .
.
SQL ,
.
,
, .
,

, . 25.5.
,
, OID , . ,
, .
:
() ;
972

VI.

4.

2.

. 25.4.

,
, ;
, .

.
,

, .

25.3.
(persistent)
,
, . (transient) ,
. ,
, .
, ,
. [11].
25. - 973


3.

2.
..

4.

..

5.

1.

. 25.5.

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

25.3.1.
: (checkpointing),
(serialization) (explicit paging).




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

VI.



, .
, ,
.
.
, (pickling) ( ) (marshaling).
. -, , ,
, ,
. -, , , .


,
. ,
.
/ : .
(reachabilitybased) , ,
. , ,
, . (reachability tree). , , ,
( , , Smalltalk Java).
(allocation-based) ,
. .
. ,
.
. Ontos Objectivity/DB.
.
() , ,
(). ObjectStore. .
25. -

975

, . .
, .
.
.

25.3.2.

(orthogonal
persistence) [10], [63].
.
.


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

. , .
,
. Pascal/R, Amber, Avalon/C++ . , PS-algol, Napier88, Galileo GemStone [81].


. ,
. (persistence identification), ODMG ,


, , .
.
976

VI.


.
,
.
.

.

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

, , , .
,
. , . : .
,

, .. , .
, . , . ?
,

, , ,
?
,
.

, .
,
ACID (Atomicity,
Consistency, Isolation, Durability , , , ) (.
19.1.1). ,
, .
,
.
: 25. - 977

? , , , , ?
, - , ,
.
, -
, ? ,
, . ,
-
, .

25.4.
24.2 , , :
;
;
.
. .

25.4.1.

19.1, ,
. , , , . ,
, , , , , .

,
.
. , .
, , , - , .
.

(. 19.2.6).
, , ,
(. 19.4).
978

VI.

25.4.2.
,
. ,
,
. , ,
, [14], [18], [183].
. ,
. ,
. . 25.6
: 0, . , V 1( V 2 V 3 , V1A
V;:, V 2 A V J B V 2 .
, : V 2 B
0; V 2 A V 1B .
Ontos, Versant, ObjectStore, Objectivity/DB Itasca. Itasca
[190].
.
.
,
.
. .
.
. , .
.
. . ,

.
-

. 25.6.

25. -

979

. 25.7.
Itasca ,
. (generic object), , .

25.4.3.
,
.
.
, , . . ,
, , . , [19].
1. :
2. ;
3. .
4. :
5. S ;
6. s ;
7. .
8. , , .
. Itasca GemStone
, ,
. ,
. 25.8.
. , Staff name DOB,
getAge .
.


|

|1|
-fjli

. 25.7. , Itasca

980

VI.

Person
name
fName
I Name
DOB
getAge

staff No (PK)
position
sex
salary

ownerNo {PK)
address

clientNo {PK]
telNo
prefType
maxRent

getMonthlySalary

SalesStaffClient
commission
telNo

addCommission
getMonthlySalary

staffNo {PK}
clientNo (AK)
position
sex
salary
telNo
prefType
maxHent
name
fName
IName
DOB
commission

getMonthlySalary
getMonthlySalarv
addCommission

. 25. ,

25. -

981

1. , ,
1.1 .
/ , / , .
1.2 ,
/
, , / . ,
SalesStaffClient . 25.8,
SalesStaff Client.
telNo, (
Person).
telNo SalesStaf fClient
, SalesStaff.
1.3 .
/
, /
. , . ,

.
,

SalesStaffclient name DOB SalesStaff, Client; Person,


SalesStaf fClient .
2. .
2.1 .
/ , , /
. , getAge
Person
. , getAge , Person.
,
Staff get Months alary, Manager,
SalesStaff, .
telNo SalesStaff, telNo SalesStaf fClient, telNo client (
1,2).
2.2 .
/ / ,
.
982

VI.

2.3 .
.
, .
3. .
3.1 .
cs,
C s . ,
. 1.1-1.3.
3.2 .
CR
, . , cs. , Staff, Manager SalesSCaff
, Person.
3.3 .
, OBJECT ( ).
3.4 .
3.2 .
OBJECT .
4. .

, .
, .
,
[19] [189].

25.4.4.

/
.

/
"/"
,
(. 2.6). "/".
,
, . 25.9 [209].

25. -

983

. 25.9. "/", : )
; ) ; )

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


: (. 25.10, )
(. 25.10, ).
(API) ,
, - . .
.

984

VI.

(
)

<

- -

i.

; - -

;.; "

|<|;

. 25.10. : ) ;
)

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

. , .
. ,

.
GemStone Itasca ,
.

25.4.5.

. , .
,
25. -

985

- ,
,
[138].


, , [33]. ,
, :
, ;
,
, ;
;
.

: Onektup 1000
, Tenktupl/Tenktup2, 10000 .
,
,
.

, 1988 (Transaction
Processing Council ), ,
. ANSI , .

- -
- - . - (OnLine Transaction Processing OLTP); , ,
. -
. :
Account (
Account 100000 );
Teller (
Teller 10 ):
Branch
( Branch 1 );
History,
( History 2592000 );
.
986

VI.

, .
(, ).

-
- -
-, .
-,
. - , , ,
, .


Transaction Processing Council , .
-. ,

, .
TPC-R.
, ; .
TPC-W. , Web,
,
Internet,
Web-,
.
Transaction Processing Council
Web- (www. tpc. org).

1
1 (Object Operations Version 1 ,
1) - [48]. , ,
24.1. , ,
, , , , .., 2. :
2

, (parts explosion).

25. -

987

1000 ( );
100 300 , ;


3280 .
1989 1990 01 GemStone, Ontos, ObjectStore, Object!vity/DB Versant, a
INGRES Sybase. ,
-
30 . ,
, ,
(
, ). , , , .

7
1993
7, . 07
- [47].
,
, ,
. ,
, ,
.
07 , ,
(, ) .
. :
(
, , 1);
( ,
, , , , ,
, );
,
.
, , , , , ,
988

VI.

, make, . , ftp.cs.wisc.edu, FTP


( Anonymous).

25.5. "
-
"
" -
" [12] ,
. :
- . .
1.
. SET, TUPLE LIST ( ARRAY).
, . , . , , , ..
!, . ,

SET (TUPLE ( ) ) , LIST (TUPLE () ), TUPLE (SET )
TUPLE (LIST ( ) ) .
2.
,
.
3.
,
, . , ,
. ( 24.3.1 , . , ,
?
,
, . , get,
.
.)
25. - 989

4.
34.3..5 . ,
. -
. ,
, ..
.
, .
5.
.
6.
(). , ().
( ).
7. DML
, (DML)
. , SQL (SQL2) (. 5.1). SQL (SQL3) ( 27.4).
8.

. Tqro, .
.
9.
, (.. ) , .

.
10.
, .
, , .
11.
, ,
.
990

VI.

12.

, ,
.

13.
(..
), (.. )
. , .
: , , , , . ,
, ,
,

25.6.

, .
, .

25.6.1 .
. 25.1.
25.1.


- . , ,
. ,
, " ",
, .
25. -

991


. ,
- .
,
. .
, , - . ,
. , ,
, , , , .. [93].
,
. 27.2.2.

(DML) .
,
, SQL, , .
, DML,
( SQL,
).

, , .
SQL ( , ). , ..
, , , , , .
ODMG ,
- SQL ( 26.2.4).
-


. ,
.