[ Pobierz całość w formacie PDF ]
.There is no database server toinstall, configure, or deploy (If you do not statically link in midaslib.dcu, the clientdataset does require midas.dll).There is no need for site licenses or databaseadministration.In addition, some versions of Delphi let you convert between arbitrary XMLdocuments and the data packets that are used by a client dataset.Thus, the file-basedapproach can be used to work with XML documents as well as dedicated datasets.For information about converting between XML documents and client dataset datapackets, see Chapter 26, Using XML in database applications.The file-based approach offers no support for multiple users.The dataset should bededicated entirely to the application.Data is saved to files on disk, and loaded at alater time, but there is no built-in protection to prevent multiple users fromoverwriting each other s data files.For more information about using a client dataset with data stored on disk, see Using a client dataset with file-based data on page 23-31.Connecting to another datasetThere are specialized client datasets that use the BDE or dbExpress to connect to adatabase server.These specialized client datasets are, in fact, composite componentsthat include another dataset internally to access the data and an internal providercomponent to package the data from the source dataset and to apply updates back tothe database server.These composite components require some additional overhead,but provide certain benefits:" Client datasets provide the most robust way to work with cached updates.Bydefault, other types of datasets post edits directly to the database server.You canreduce network traffic by using a dataset that caches updates locally and appliesthem all later in a single transaction.For information on the advantages of usingclient datasets to cache updates, see Using a client dataset to cache updates onpage 23-15." Client datasets can apply edits directly to a database server when the dataset isread-only.When using dbExpress, this is the only way to edit the data in the dataset(it is also the only way to navigate freely in the data when using dbExpress).Evenwhen not using dbExpress, the results of some queries and all stored proceduresare read-only.Using a client dataset provides a standard way to make such dataeditable." Because client datasets can work directly with dedicated files on disk, using aclient dataset can be combined with a file-based model to allow for a flexible briefcase application.For information on the briefcase model, see Combiningapproaches on page 14-14.14-10 Dev el oper s Gui deDa t a b a s e a r c h i t e c t u r eIn addition to these specialized client datasets, there is a generic client dataset(TClientDataSet), which does not include an internal dataset and dataset provider.Although TClientDataSet has no built-in database access mechanism, you can connectit to another, external, dataset from which it fetches data and to which it sendsupdates.Although this approach is a bit more complicated, there are times when it ispreferable:" Because the source dataset and dataset provider are external, you have morecontrol over how they fetch data and apply updates.For example, the providercomponent surfaces a number of events that are not available when using aspecialized client dataset to access data." When the source dataset is external, you can link it in a master/detail relationshipwith another dataset.An external provider automatically converts thisarrangement into a single dataset with nested details.When the source dataset isinternal, you can t create nested detail sets this way." Connecting a client dataset to an external dataset is an architecture that easilyscales up to multiple tiers.Because the development process can get moreinvolved and expensive as the number of tiers increases, you may want to startdeveloping your application as a single-tiered or two-tiered application.As theamount of data, the number of users, and the number of different applicationsaccessing the data grows, you may later need to scale up to a multi-tieredarchitecture.If you think you may eventually use a multi-tiered architecture, it canbe worthwhile to start by using a client dataset with an external source dataset.This way, when you move the data access and manipulation logic to a middle tier,you protect your development investment because the code can be reused as yourapplication grows." TClientDataSet can link to any source dataset.This means you can use customdatasets (third-party components) for which there is no corresponding specializedclient dataset.Some versions of Delphi even include special provider componentsthat connect a client dataset to an XML document rather than another dataset.(This works the same way as connecting a client dataset to another (source)dataset, except that the XML provider uses an XML document rather than adataset.For information about these XML providers, see Using an XMLdocument as the source for a provider on page 26-8.)There are two versions of the architecture that connects a client dataset to an externaldataset:" Connecting a client dataset to another dataset in the same application." Using a multi-tiered architecture.Connecting a client dataset to another dataset in the same applicationBy using a provider component, you can connect TClientDataSet to another (source)dataset [ Pobierz całość w formacie PDF ]