Generation of query and update views for object relational mapping

Information

  • Patent Application
  • 20070226203
  • Publication Number
    20070226203
  • Date Filed
    March 16, 2007
    17 years ago
  • Date Published
    September 27, 2007
    17 years ago
Abstract
A data access architecture may includes a mapping architecture for mapping data as may be used by an application to data as persisted in a database. Such a mapping architecture uses two types of “mapping views”—one for translating queries and the other for translating updates. A mechanism is provided that automatically generates query and update views from high-level mapping specifications. A validation may be performed to ensure that a mapping specification, when used in conjunction with a mapping architecture, allows data to “roundtrip” from the application to the database, without loss of data.
Description

BRIEF DESCRIPTION OF THE DRAWINGS

The systems and methods for mapping architecture with incremental view maintenance in accordance with the present invention are further described with reference to the accompanying drawings in which:



FIG. 1 illustrates an architecture of an exemplary Entity Framework as contemplated herein.



FIG. 2 illustrates an exemplary relational schema.



FIG. 3 illustrates an exemplary Entity Data Model (EDM) schema.



FIG. 4 illustrates a mapping between and entity schema (left) and a database schema (right).



FIG. 5 illustrates mapping is represented in terms of queries on the entity schema and the relational schema.



FIG. 6 illustrates bidirectional views—the query and update views—generated by the mapping compiler for the mapping in FIG. 5.



FIG. 7 illustrates a process for leveraging materialized view maintenance algorithms to propagate updates through bidirectional views.



FIG. 8 illustrates a mapping designer user interface.



FIG. 9 illustrates depicts an entity schema with entity types Person and Customer whose instances are accessed via the extent Persons.



FIG. 10 illustrates query and update views generated by the mapping compiler for the mapping in FIG. 9.



FIG. 11 illustrates a merge view that combines an updated store state computed by a client and an old store state into the new store state.



FIG. 12 illustrates a mapping expressed as a composition mapping f, ◯ g−1 where the view f: C→V is given by queries QC1, . . . , QCn, the view g: S→V is given by queries QS1, . . . , QSn, and V corresponds to the view schema V1, . . . , Vn induced by these queries.



FIG. 13 illustrates a scenario in which a combination of horizontal and vertical partitioning is used to store the inheritance hierarchy shown on the left. Table HR holds portions of instances of Person and Employee, but no Customer instances. The mapping fragment for HR can be specified using OR.



FIG. 14 illustrates an exemplary partitioning of a relational table.



FIG. 15 illustrates a query g that partitions S into P Pexp×Punexp such that pexp: S→Pexp and punexp.



FIG. 16 illustrates exemplary steps of a mapping compilation process.



FIG. 17 illustrates exemplary partitions and views for use as an example in the corresponding written specification.



FIG. 18 illustrates an exemplary embodiment including a method that combines a variety of aspects of the disclosure provided herein.


Claims
  • 1. A method for providing data services to an application by a data access system, comprising: receiving a mapping that associates valid application states corresponding to an application executed by a client computer system with valid database states corresponding to a database in which data for use by said application is stored;generating a set of query view definitions and a set of update view definitions from said mapping, such that the query views determine the application state from a database state, and the update views determine the database state from the application state;utilizing said set of query view definitions and said set of update view definitions to persist in said database a data modification produced by said client computer system.
  • 2. The method of claim 1, wherein said mapping comprises at least one pair of fragment queries comprising a first fragment query stated in terms of an application schema and a second fragment query stated in terms of a database schema.
  • 3. The method of claim 1, wherein the said query view definitions are logically implied by the said mapping, which is in turn logically implied by the said update view definitions.
  • 4. The method of claim 2, further comprising: applying an algorithm to reconstruct disjoint partitions from said set of fragment queries, wherein fragment queries can be rewritten using the said partitions.
  • 5. The method of claim 1, further comprising verifying, by said data access system, that: an update initiated by said application according to said application schema can be: received by said data access system;modified by said data access system utilizing said mapping; andperformed by said database without loss of update data; anda query subsequently initiated by said application to retrieve said update data can be: received by said data access system;modified by said data access system utilizing said mapping;performed by said database; andupdate data returned to said application without loss of said update data.
  • 6. The method of claim 1, further comprising determining whether said set of query view definitions and said set of update view definitions can be generated from said mapping, such that: said set of query view definitions expresses at least a portion of said set of valid application schemas in terms of at least a portion of said set of valid database schemas;said set of update view definitions expresses at least a portion of said set of valid database schemas in terms of at least a portion of said set of valid application schemas;a composition of said set of query view definitions and said set of update view definitions produces an identity mapping on an application schema.
  • 7. The method of claim 1, further comprising optimizing at least one view within said set of query view definitions or said set of update view definitions by minimizing the number of relational operations required by said at least one view.
  • 8. The method of claim 1, further comprising optimizing at least one view within said set of query view definitions or said set of update view definitions by replacing an outer join with a union, inner join, or left outer join.
  • 9. The method of claim 1, further comprising removing redundant self operations from at least one view within said set of query view definitions or said set of update view definitions.
  • 10. The method of claim 1, wherein generating said set of query view definitions and said set of update view definitions comprises applying a symmetric algorithm to obtain an exact rewriting of an identity query for an extent.
  • 11. The method of claim 1, further comprising producing a merge view to preserve data in the said database that is not exposed through a mapping to an application.
  • 12. A data access system for providing data services to an application, said data access system comprising: a subsystem that receives a mapping that associates valid application states corresponding to an application executed by a client computer system with valid database states corresponding to a database in which data for use by said application is stored;a subsystem that generates a set of query view definitions and a set of update view definitions from said mapping, such that the query views determine the application state from a database state, and the update views determine the database state from the application state;a subsystem that utilizes said set of query view definitions and said set of update view definitions to persist in said database a data modification produced by said client computer system.
  • 13. A method for providing data services to an application by a data access system, comprising: receiving, by said data access system, a mapping specification, said mapping specification correlating an application schema associated with said application with a database schema associated with a database:verifying, by said data access system, that an update initiated by said application according to said application schema can be: received by said data access system;modified by said data access system utilizing said mapping; andperformed by said database without loss of update data; andverifying, by said data access system, that a query subsequently initiated by said application according to said application schema can be: received by said data access system;modified by said data access system utilizing said mapping;performed by said database; andupdate data returned to said application without loss of said update data;approving subsequent use of said mapping specification by said data access system in providing data services to said application.
  • 14. The method of claim 13, wherein said mapping specification comprises an expression that relates a query on said application schema to a query on said database schema.
  • 15. The method of claim 13, wherein said mapping specification comprises an Extensible Markup Language (XML) document.
  • 16. The method of claim 13, wherein said mapping specification comprises a query on said application schema and a query on said database schema that is equal to said query on said application schema.
  • 17. The method of claim 13, further comprising determining a set of constraints comprising one or more of a key constraint, an inclusion constraint, a domain constraint, and a disjointness constraint.
  • 18. The method of claim 17, further comprising utilizing said set of constraints when verifying, by said data access system, that a query initiated by said application according to said application schema can be: received by said data access system;modified by said data access system utilizing said mapping specification;performed by said database; andrequested data returned to said application without loss of said requested data.
  • 19. The method of claim 13, further comprising translating, by said data access system, a portion of said database schema into a third schema that is equivalent to said portion of a said database schema, and translating a query initiated by said application into a query over said third schema.
  • 20. The method of claim 13, further comprising determining whether a query view and an update view can be produced from said mapping specification, such that: said query view expresses at least a portion of said application schema in terms of at least a portion of said database schema;said update view expresses at least a portion of said database schema in terms of at least a portion of said application schema;a composition of said query view and said update view produces an identity mapping on said application schema.
Provisional Applications (1)
Number Date Country
60785457 Mar 2006 US