" "



#10 2007




:
CALS-



English Library
-







About project
N 7730569
# . 0420800025
ISSN 19940408
. English Koi-8 Win

!
^^

. #10 2007
.., ..
. , , . - . - - , [1], [4,7].
, (Persistence) - . , , . , .
, -. , [5,6] , () .
- ( ) [8,9,10] , [11]. , , , . , - (persistence storage) .
SQL [2] : (), ( ), ( ), , . . . - - () (Object Relational Mapper - ORM) - , . (patterns), ORM, [12]; , [13, 17].
ORM , () , . (, web-).
- , , . : is-a part-of. :
- ( -, is-a), / ( ). / () ().
- ( part-of).
. [14]:
1. , .
2. .
3. .
: - (embedded object [12]), .
. . 1 .
. 1. - ^- (. 2 ) part-of (. 3).
. 2 - ^-
^- 1- , .
. 3 - part-of
, , , [14]. .
2, , , . : Document - Invoice, Organization - Dealer, Person - Customer; Address. . 4.
Invoice
PK InvoiceID
FK2 FK1 FK3 Do eu nient ID DealerlD Customer! D Total
\
Customer
PK CustomerlD

FK2 FK1 PersonlD Address ID
Dealer
PK DealerlD
FK1 Organization^ DealerN umber
Table Person
PK P eis on ID
First Name MiddleName Last Name

Table Organization
PK Organization ID

FK1 varchar Title Ad dress ID
I
Table Address
PK AddressID
varchar Country varchar City varchar Zi|>C ode varchar Street int House int Flat
. 4
(is-a part-of) (foreign keys). , .. , part-of .
, , Invoice, . , Invoice ( ). SQL- :
SELECT * FROM Invoice WHERE InvoiceID=@InvoiceID
SELECT * FROM Document WHERE Document ID=@DocumentID
SELECT * FROM Dealer WHERE DealerID=@DealerD
SELECT * FROM Organization WHERE Organization ID=@OrganizationID
SELECT * FROM Address WHERE AddressID=@OrganizationAddressID
SELECT * FROM Customer WHERE CustomerID=@CustomerD
SELECT * FROM Person WHERE PersonID=@PersonID
SELECT * FROM Address WHERE AddressID=@PersonAddressID
: , Invoice Address . , , .
. , Invoice Recalculate(percent), Total . (, 10%) Invoice InvoiceCollection (, , ) SQL- :
UPDATE Invoice SET Total=Total*1.1 WHERE InvoiceID=@InvoiceID1 UPDATE Invoice SET Total=Total*1.1 WHERE InvoiceID=@InvoiceID2
UPDATE Invoice SET Total=Total*1.1 WHERE InvoiceID=@InvoiceIDn
InvoiceID1,InvoiceID2...InvoiceIDn - Invoice InvoiceCollection.
, SQL- :
UPDATE Invoice SET Total=Total*1.1 WHERE InvoiceID IN (InvoiceIDl,
InvoiceID2, ... , InvoiceIDn)
, ORM.
, SQL- . , , .. , , ( - postponed load). , , - . (load-on-demand). . SQL- :
SELECT * FROM Invoice WHERE InvoiceID=@InvoiceID
SELECT * FROM Document WHERE Document ID=@DocumentID
:
SELECT * FROM Invoice INNER JOIN Dealer Invoice.DealerID = Dealer.DealerID WHERE InvoiceID=@InvoiceID
.. , SQL- ( , (execution plan) ..).
(load-on-demand) SQL- , ( ), .
() . , .. (lazy load) (load-on-demand). , ,
. -, , . -, , , , ( ). , :
SELECT * FROM Organization WHERE Organization ID=@OrganizationID
SELECT * FROM Address WHERE AddressID=@OrganizationAddressID -- low priority
SELECT * FROM Customer WHERE CustomerID=@CustomerD
SELECT * FROM Address WHERE AddressID=@PersonAddressID -- low priority
:
SELECT * FROM Organization WHERE Organization ID=@OrganizationID SELECT * FROM Customer WHERE CustomerID=@CustomerD SELECT * FROM Address WHERE AddressID=@OrganizationAddressID -- low priority SELECT * FROM Address WHERE AddressID=@PersonAddressID -- low priority
:
SELECT * FROM Organization WHERE Organization ID=@OrganizationID SELECT * FROM Customer WHERE CustomerID=@CustomerD
SELECT * FROM Address WHERE AddressID IN (OrganizationAddressID, PersonAddressID) -- low priority
(). SQL- [15].
(lazy load) [18, 19]. (fetching strategies) , ; , .
SQL- . , . , .
, , . . , :
class ObjectStatistic {
Type LoadingType;
Type[] ReferencedTypes;
Type[] LoadedTypes;
int[] ReferenceRequested;
int[] ReferenceOmitted;
}
LoadingType - ,
ReferencedTypes - , is-a part-of,
LoadedTypes - ,
ReferenceRequested - ( ) ReferencedTypes,
ReferenceOmitted - , .
ObjectStatistic LoadingType . ( ReferencedTypes) ReferenceRequested ReferenceOmitted.
ReferenceRequested ReferenceOmitted (, ) :
SELECT * FROM Invoice INNER JOIN Dealer Invoice.DealerID = Dealer.DealerID WHERE InvoiceID=@InvoiceID
ReferenceRequested ReferenceOmitted ( lazy load)
SELECT * FROM Invoice WHERE InvoiceID=@InvoiceID SELECT * FROM Dealer WHERE DealerID=@DealerD - low priority
ReferenceOmitted ReferenceRequested (load-on-demand), . . , , .
. , (, Invoice, Invoice, ..), ( , ) . ORM.
ReferenceRequested , ReferenceOmitted - , .
, , . , . . , ,
. ORM .
ORM , .. , . , . , (load-on-demand) (lazy load) (C#) . , C#:
class FooObject {
public PropertyType PropertyName get {...} set {...}
}
PropertyType get_PropertyName () void set_PropertyName (PropertyType), get_ :
get {
if(!propertyData.IsLoaded)
propertyData.LoadImmediately(); // load on demand // propertyData.WaitForPendingLoad(); // lazy load
return propertyData;
}
FooObject, FooObject . ORM, , , .. [16]. (wrappers) (proxy), [18]. . , (user UI) ORM.
, , -. (postponed load) ORM ( 2) , , ( ) - , . ORM - , .
( ), . :
Add(Object) - . ;
bool Contains(Object) - . . (lazy load) , ;
Remove(Object) - . ; int Count() - . SQL- SELECT Count(*) FROM... ;
GetEnumerator() - . SQL- , .
GetEnumerator() . :
foreach(invoice in InvoiceCollection)
{
Invoice.Recaulculate(10);
}
Recaulculate(percent):
class Invoice {
void Recalculate(int percent) {
Total = Total*(100+percent)/100;
}
}
SQL- .
(custom) Enumerator, :
class InvoiceEnumerator {
static Invoice[] InvoiceCollection; static int[] PercentParameterCollection;
}
class Invoice {
void Recalculate(int percent) {
InvoiceEnumerator.InvoiceCollection.Add(this);
InvoiceEnumerator.PercentParameterCollection.Add(percent);
}
}
foreach InvoiceEnumerator SQL- Invoice percent PercentParameterCollection.
. . , , .
ORM , . , , web- -, () . , .

1. Booch, G. Object-Oriented Analysis and Design with Applications. 2-nd ed. Addison-Wesley, Rational, Santa Clara, California. (1994). ( . - C++, 2- ./. . - .: , .: , 1999. - 560 ., .)
2. Gruber, M. SQL Instant Reference. Sybex, Alameda, CA. (1993). ( . SQL. . . - .: "", 1998. - 291 .)
3. Date, C.J. An Introduction to Database Systems. Addison-Wesley, Reading, Massachusetts. (1995). ( . . . - : "", 1998. - 784 .)
4. Stroustrup B., The C++ programming language. 3-d ed. Addison-Wesley, AT&T Labs Murray Hill, New Jersey. (1997) ( . ++, 3- . . . - .; .: - , 1999 . - 991 ., .)
5. Codd E.F. "A Relational Model for Large Shared Data Banks". Communications of the ACM, 13, 6, June 1970, p.p. 377387.
6. Maier D. The Theory of Relational Databases. Computer Science Press, Rockville, Maryland (1983). (. . . .: , 1987. 608.)
7. Archer, Tom. Inside C#. 2-nd ed. Microsoft Press A Division of Microsoft Corporation One Microsoft Way Redmond, Washington. (2002)
8. Malcolm Atkinson, Francois Bancilhon, David DeWitt, Klaus Dittrich, David Maier, and Stanley Zdonik: "The Object-Oriented Database System Manifesto", Proc. 1st International Conference on Deductive and Object-Oriented Databases, Kyoto, Japan (1989). New York, N.Y.: Elsevier Science (1990). (. . " - ", , No. 4, 1995, http:// www. osp. ru/ dbms/1995/04/23.htm )
9. M. Stonebraker, L. Rowe, B. Lindsay, J. Gray, M. Carey, M. Brodie, Ph. Bernstein, D. Beech. "Third-Generation Data Base System Manifesto" Proc. IFIP WG 2.6 Conf. on Object-Oriented Databases, July 1990, ACMSIGMOD Record 19, No. 3 (September 1990). ( . . " : ", , No. 2, 1996, http://www. osp. ru/ dbms/1995/02/23. htm )
10. Hugh Darwen and C. J. Date: The Third Manifesto. ACM SIGMOD Record 24, No. 1 (March 1995). (: . , . . " ", , No. 1, 1996, http:// www. osp. ru/ dbms/1996/01/23. htm )
11. ODBMS.ORG. Object Database Vendors. http://www.odbms.org/vendors.html
12. Martin Fowler, David Rice, Matthew Foemmel, Edward Hieatt, Robert Mee, Randy Stafford. Patterns of Enterprise Application Architecture. Addison Wesley. (2002)
13. Object Architects. O/R Mapping Products. http://www.objectarchitects.de/ObjectArchitects/orpatterns/Appendices/products.htm
14. Scott W. Ambler. Mapping Objects to Relational Databases: O/R Mapping In Detail. Ambysoft Inc. (2006) http://www.agiledata.org/essays/mappingObjects.html
15. Dan Tow. SQL Tuning. O'Reilly & Associates, Sebastopol , CA. (2003)
16. Thuan L. Thai, Hoang Lam. .NET Framework Essentials, 2nd Edition. O'Reilly (2002)
17. hibernate.org - Hibernate http://www.hibernate.org/
18. hibernate.org - A Short Primer On Fetching Strategies. http://www.hibernate.org/315.html
19. hibernate.org - Some explanations on lazy loading. http://www.hibernate.org/162.html
: - - : - - . :
maiL.ru


IBM Siemens Business Services -


,
>>
>>
| | Copyright 2003 . E-mail: magazine@xware.ru | .: +7 (495) 263-68-67