[ Pobierz całość w formacie PDF ]
.In addition, the BDE drivers provide limited transaction support forsome local databases.Database transaction support is provided by the componentthat represents the database connection.For details on managing transactions using adatabase connection component, see  Managing transactions on page 17-5.In multi-tiered applications, you can create transactions that include actions otherthan database operations or that span multiple databases.For details on usingtransactions in multi-tiered applications, see  Managing transactions in multi-tieredapplications on page 25-18.Referential integrity, stored procedures, and triggersAll relational databases have certain features in common that allow applications tostore and manipulate data.In addition, databases often provide other, database-specific, features that can prove useful for ensuring consistent relationships betweenthe tables in a database.These include" Referential integrity.Referential integrity provides a mechanism to preventmaster/detail relationships between tables from being broken.When the userattempts to delete a field in a master table which would result in orphaned detailrecords, referential integrity rules prevent the deletion or automatically delete theorphaned detail records." Stored procedures.Stored procedures are sets of SQL statements that are namedand stored on an SQL server.Stored procedures usually perform commondatabase-related tasks on the server, and sometimes return sets of records(datasets)." Triggers.Triggers are sets of SQL statements that are automatically executed inresponse to a particular command.Database architectureDatabase applications are built from user interface elements, components thatrepresent database information (datasets), and components that connect these to eachother and to the source of the database information.How you organize these pieces isthe architecture of your database application.Des i gni ng dat abas e appl i c at i ons 14-5 Da t a b a s e a r c h i t e c t u r eGeneral structureWhile there are many distinct ways to organize the components in a databaseapplication, most follow the general scheme illustrated in Figure 14.1:Figure 14.1 Generic Database ArchitectureData moduleUIData source ConnectionDatasetto dataThe user interface formIt is a good idea to isolate the user interface on a form that is completely separatefrom the rest of the application.This has several advantages.By isolating the userinterface from the components that represent the database information itself, youintroduce a greater flexibility into your design: Changes to the way you manage thedatabase information do not require you to rewrite your user interface, and changesto the user interface do not require you to change the portion of your application thatworks with the database.In addition, this type of isolation lets you develop commonforms that you can share between multiple applications, thereby providing aconsistent user interface.By storing links to well-designed forms in the ObjectRepository, you and other developers can build on existing foundations rather thanstarting over from scratch for each new project.Sharing forms also makes it possiblefor you to develop corporate standards for application interfaces.For moreinformation about creating the user interface for a database application, see Designing the user interface on page 14-15.The data moduleIf you have isolated your user interface into its own form, you can use a data moduleto house the components that represent database information (datasets), and thecomponents that connect these datasets to the other parts of your application.Likethe user interface forms, you can share data modules in the Object Repository so thatthey can be reused or shared between applications.The data sourceThe first item in the data module is a data source.The data source acts as a conduitbetween the user interface and a dataset that represents information from a database.Several data-aware controls on a form can share a single data source, in which casethe display in each control is synchronized so that as the user scrolls through records,the corresponding value in the fields for the current record is displayed in eachcontrol.14-6 Devel oper  s Gui de Da t a b a s e a r c h i t e c t u r eThe datasetThe heart of your database application is the dataset.This component represents a setof records from the underlying database.These records can be the data from a singledatabase table, a subset of the fields or records in a table, or information from morethan one table joined into a single view.By using datasets, your application logic isbuffered from restructuring of the physical tables in your databases.When theunderlying database changes, you might need to alter the way the datasetcomponent specifies the data it contains, but the rest of your application can continueto work without alteration.For more information on the common properties andmethods of datasets, see Chapter 18,  Understanding datasets.The data connectionDifferent types of datasets use different mechanisms for connecting to the underlyingdatabase information.These different mechanisms, in turn, make up the majordifferences in the architecture of the database applications you can build.There arefour basic mechanisms for connecting to the data:" Connecting directly to a database server.Most datasets use a descendant ofTCustomConnection to represent the connection to a database server." Using a dedicated file on disk.Client datasets support the ability to work with adedicated file on disk [ Pobierz całość w formacie PDF ]

  • zanotowane.pl
  • doc.pisz.pl
  • pdf.pisz.pl
  • swpc.opx.pl
  •