Database Engine Enhancements
Database Engine Enhancements
Database Engine Enhancements
Topics to be Covered
Here, in brief, is how the development from these design goals has manifested as features in the new database engine. For a more thorough look, youll have to attend the session!
7/9/13
Integrity checks
Ensuring the physical and logical integrity of data is a vital job for any database system. In addition, proposed changes to data need to be validated for compliance with any applicable business rules. In the past, the bulk of this work has been performed in code embedded in the application (or applications) which use the data. Now, the DBC allows you to store data validation and referential integrity (i.e., deleting detail records when the master record is deleted) code in the data repository itself, where its automatically used by any application that tries to make changes to data. Visual FoxPros Referential Integrity Builder can even generate the stored code for you! Field rules serve as built-in VALID clauses, while row rules play a similar role in checking the record as a whole before any changes are committed. Triggers are procedures which are executed any time a record is inserted, deleted, or updated. Among other uses, triggers are tremendously useful in implementing referential integrity. By allowing developers to store rules, triggers, and stored procedures in the DBC, Visual FoxPro stores the data-specific code where it makes the most sense architecturallywith the data. This makes maintaining the code easier and ensures that its consistently used by all applications which access the data. By integrating the hooks for this code into the engine, we should realize performance benefits. For client-server applications, the ability to define rules in the local DBC relieves the server CPU from needing to perform the rule-enforcement work, speeding processing even more.
7/9/13
a block, or rolled back if some portion of the changes fails an integrity check or collides with someone elses changes. Transactions are particularly useful in cases where changes to multiple tables must all be made in synch to preserve the logical relationship among the records. The combination of buffering and transactions, with appropriate error handling, provides the basis for a fundamentally different approach to coding multiuser applications than was possible in FoxPro 2.x. In the session, well walk through some source code that illustrates some of the new options.
7/9/13
View window, where tables visible at one level (DataSession) are hidden when you move to the next level. With 32,767 work areas in each DataSession and an unlimited number of DataSessions possible, the problem of running out of work areas is history. Forms participate in DataSession #1 (the one the Command Window uses at startup) by default, but enabling them to have separate DataSessions is as easy as changing the form.DataSession property. DataSessions can be very useful for applications which use multiple instances of forms, protecting them from interfering with one anothers data. Forms can be set up to make automatic use of buffering. One of the properties of a form is BufferMode. By setting this property, any controls which are contained in the form can benefit from optimistic or pessimistic buffering. (Table buffering for grids, record buffering for other bound controls). In some cases, it may be desirable to force a specific flavor of buffering on a specific cursor. For example, if pessimistic locking is important for one but not all of the cursors referenced by a form, you can adjust the cursor.BufferModeOverride property in the DataEnvironment for the form.
Looking Ahead
The generational change from FoxPro 2.x to Visual FoxPro is a substantial one, and its likely to change the way we spend our time while developing business applications. The new event and object models place a heavy emphasis on design, both up front and iteratively throughout the development cycle. Database engine enhancements make it much easier to let FoxPro do it rather than writing procedural code to handle things like buffering and transactions. Heres a scenario that may be playing on a desktop near you quite soon. A user specifies a need for a new master-detail data entry form in an existing application. The developer takes these steps: opens the applications Project Container and DBC creates a new form (which automatically inherits characteristics from the corporate standard template form) and opens its DataEnvironment drags the two relevant tables from the Project Container to the forms DataEnvironment. Their relationship is automatically carried along adds several textboxes (for the fields from the master table) and a grid (for information from the detail table) to the form and sets their ControlSource/RowSource properties appropriately changes the forms BufferMode property to Optimistic and its DataSession property to .T. adds a general-purpose navigation toolbar (VCR buttons) from the applications visual class library gives the user a working data entry form with built-in support for multiple instancing and multiuser access Elapsed time: 10 minutes! This is the leverage that proper use of the new tools can provide. Whats conspicuous in this process is the absence of any code to handle setting up indexes, relationships, locking, SCATTER/ GATHER, and all the other drudgework weve been used to. The database engine enhancements make these complexities of data access transparent from the application builders point of view as well as the users. When assembling components is this easy, the burden of development shifts to making sure the components are well thought out and well debugged, and to writing code to handle the inevitable exceptions. Error handling, including dealing with violations of DBC-stored rules and triggers, will occupy proportionately more development time than before. Designing applications in the new world means building classes that are smart enough to let FoxPro handle what its best at, and robust enough to deal with all the exceptions gracefully, in a way that preserves the integrity of the data and meets the needs of the user. Visual FoxPro provides an exceptional set of enhancements to the database engine in order to support these goals.
www.dfpug.de/loseblattsammlung/migration/whitepapers/DBEngine.htm 4/5
7/9/13
www.dfpug.de/loseblattsammlung/migration/whitepapers/DBEngine.htm
5/5