280 likes | 439 Views
A Conceptual Approach to Database Applications Evolution. Anthony Cleve , Anne-France Brogneaux and Jean-Luc Hainaut PReCISE research center University of Namur, Belgium. SATToSE 2011, Koblenz , Germany. Introduction. Database applications set of programs manipulating a database
E N D
A Conceptual Approach to Database Applications Evolution Anthony Cleve, Anne-France Brogneaux and Jean-Luc Hainaut PReCISE research center University of Namur, Belgium SATToSE 2011, Koblenz, Germany
Introduction • Database applications • set of programs manipulating a database • subject to continuous evolution to fit ever changing business needs and technical requirements • Database applications evolution • complex, time-consuming, risky and costly process • co-evolution of several interdepedent artefacts: • conceptual schema, logical schema, physical schema, DDL code, data, mappings, programs • inter-artefact consistency must be preserved over time
Schema-programs co-evolution scenarios • CS: conceptual schema; LS: logical schema; PS: physical schema; XS: external schema; and P a program using XS • Scenario 1: Change in CS without impact on P • derivation of new LS and CS/LS mapping, but XS/LS mapping unchanged • Scenario 2: Change in CS, with impact on P • requires manual adaptation of P. impact analysis may be difficult in case of dynamically generated queries • Scenario 3: Change in LS, with CS unchanged • frequent scenario, tool-supported program adaptation is possible but very difficult in case of dynamically generated queries • Scenario 4: change in PS, with CS and LS unchanged • No impact on P
In this paper… • Focus • co-evolution of conceptual schema, logical schema and programs • Goals • mitigate the impact of database schema changes on programs • provide automated support for schemas-programs co-evolution, to reduce cost, effort and risks • Approach • transformation-based derivation of relational logical schema (LS) from conceptual schema (CS) • automatic derivation of the mapping between CS and LS • automatic generation of a data access API that provides the programs with a conceptual view to the relational database
Transformation-based logical schema derivation • Logical design = deriving LS from CS • can be modelled as a chain of semantics-preserving schema transformations • Transformation plan to obtain a relational LS from a CS • is-a relationships into one-to-one rel-types • complex rel-types into entity types and one-to-many rel-types • complex attributes into entity types • one-to-many and one-to-one rel-types into foreign keys + renaming some tables and columns, if needed + adding some technical identifiers, if needed
Schema mapping derivation • Idea: • propagate mapping « stamps » through successive schema transformations applied to CS to obtain LS • derive mapping M(CS,LS) between CS and LS
Conceptual API generation • Idea: generate a conceptual data manipulation API from M(CS,LS) • providing programs with a conceptual view of the relational database • isolating programs from logical schema changes • facilitating impact analysis of conceptual schema changes • Conceptual API • CS-based class hierarchy • CS-based data navigation • CS-based data modification
CS-based class hierarchy PERSON BOOK Pid Book-id Name Title First-Name publicclass Book public class Copy public class Person public class Author extends Person public class Borrower extends Person working hypothesis: each is-a relationship represents a partition AUTHOR Publisher 0-N written 0-N id: Pid Origin[0-1] Date-Published Abstract[0-1] COPY P id: Book-id Copy-No Date-Acquired 0-N Location BORROWER of Nbr-of-Volumes 1-1 0-1 borrowing 0-N Address State Phone Comment[0-1] id: of.BOOK Copy-No
CS-based data navigation (by entity type) PERSON BOOK Pid Book-id Name Title First-Name public Vector<Book> getAllBook() {…} public Vector<Copy> getAllPerson() {…} // returns all authors and borrowers … public Book getBookById(String BookId) {…} // standard id public Person getPersonById(Integer Pid) {…} // standard id public Copy getCopyById(Book book, Integer copyNo) {…} // hybrid id public Author getAuthorById(Integer Pid) {…} // inherited id public Borrower getBorrowerById(Integer Pid) {…} // inherited id AUTHOR Publisher 0-N written 0-N id: Pid Origin[0-1] Date-Published Abstract[0-1] COPY P id: Book-id Copy-No Date-Acquired 0-N Location BORROWER of Nbr-of-Volumes 1-1 0-1 borrowing 0-N Address State Phone Comment[0-1] id: of.BOOK Copy-No
CS-based data navigation (by rel. type) PERSON BOOK Pid Book-id Name Title First-Name // in class Copy: public Book getBookViaOf() {…} public Borrower getBorrowerViaBorrowing() {…} // in class Book: public Vector<Copy> getAllCopyViaOf() {…} public Vector<Author> getAllAuthorViaWritten() {…} // in class Author: public Vector<Book> getAllBookViaWritten() {…} // in class Borrower: public Vector<Copy> getAllCopyViaBorrowing() {…} AUTHOR Publisher 0-N written 0-N id: Pid Origin[0-1] Date-Published Abstract[0-1] COPY P id: Book-id Copy-No Date-Acquired 0-N Location BORROWER of Nbr-of-Volumes 1-1 0-1 borrowing 0-N Address State Phone Comment[0-1] id: of.BOOK Copy-No
CS-based data modification (create) PERSON BOOK Pid Book-id Name Title First-Name • creation arguments: all (inherited) conceptual attributes and roles Copy c = db.insertCopy(copyNo,…, comment, book); • creation available for leaf entity types only (recursive call to super class) Author a = db.insertAuthor(pid, name, firstName, origin); Borrower b = db.insertBorrower(pid, name, firstName, address, phone); AUTHOR Publisher 0-N written 0-N id: Pid Origin[0-1] Date-Published Abstract[0-1] COPY P id: Book-id Copy-No Date-Acquired 0-N Location BORROWER of Nbr-of-Volumes 1-1 0-1 borrowing 0-N Address State Phone Comment[0-1] id: of.BOOK Copy-No
CS-based data modification (delete) PERSON BOOK Pid Book-id Name Title First-Name • visibledelete()method • deletes or disconnects all the entity type instances that reference the entity type instance to be deleted (similar to delete cascade mode) • starting from the root type • internaldeleteFromDB()method • actually removes the entity type instance from the database • starting from the leaf type AUTHOR Publisher 0-N written 0-N id: Pid Origin[0-1] Date-Published Abstract[0-1] COPY P id: Book-id Copy-No Date-Acquired 0-N Location BORROWER of Nbr-of-Volumes 1-1 0-1 borrowing 0-N Address State Phone Comment[0-1] id: of.BOOK Copy-No
CS-based data modification (update) PERSON BOOK Pid Book-id Name Title First-Name • Update value of (inherited) conceptual attributes and roles borrower.updateAddress(address); • Connect/disconnect entity type instances author.connectToBookViaWritten(book); copy.disconnectFromBorrowerViaBorrowing(borrower); AUTHOR Publisher 0-N written 0-N id: Pid Origin[0-1] Date-Published Abstract[0-1] COPY P id: Book-id Copy-No Date-Acquired 0-N Location BORROWER of Nbr-of-Volumes 1-1 0-1 borrowing 0-N Address State Phone Comment[0-1] id: of.BOOK Copy-No
Schema-programs co-evolution scenarios revisited • CS: conceptualschema; LS: logicalschema; PS: physicalschema; XS: externalschema; and P a program using XS • Scenario 1: Change in CS without impact on P • automatedderivation on new LS and CS/LS mapping (the API), but XS/LS mappingunchanged +easier to startmanipulating instances of new CS concepts • Scenario 2: Change in CS, with impact on P • stillrequiresmanual adaptation of P, but impact analysiscanbedonestatically (by the Java compiler) • Scenario 3: Change in LS, with CS unchanged • frequent scenario, tool-supported program adaptation is not necessary, justregenerate the API from the new CS/LS mapping and you’redone
Tool support • DB-MAIN, version 9 (http://www.db-main.be) • database schemas design and manipulation (GER model) • manual conceptual schema design • automatic logical (and physical) schema derivation • automatic DDL code generation (MySQL, PostGreSQL, DB2, Oracle, etc) • automatic schema mapping propagation and derivation • DB-MAIN Java plugins • schema mapping manipulation and visualization • customized DDL code generation • conceptual API generation (java+jdbc/odbc, tested with MySQL, SQLLite Interbase, DB2, Oracle) • client programs generation (for systematic testing purposes)
Application • Gisele project • eHealth domain, IT support for clinical pathway management • ex. treatment of specific kinds of cancer • Clinical pathways represented as process models • to be stored in a database and accessed by dedicated programs • Ex: creation, evolution, deletion, analysis of clinical pathways • Conceptual schema of process models • inspired by several process modelling languages like BPMN, Yawl, etc. • Continuous schema evolution • stable kernel, but frequent changes for adding various dimensions special attention paid to reduce the impact of evolutions on already developed programs
Application: some figures • Representative schema size and mapping complexity • Generated API • 50 java classes • > 20.000 lines of code • extended kernel systematically tested using generated client programs allowing to create, delete, and update clinical pathways in the database
Conclusions and perspectives • Conceptual approach to database applications design and evolution • Combining generative and transformational techniques • Co-evolution between database schemas and programs better mastered • Future work • Relaxing some working hypotheses • Better integration of the supporting tools • Application to other data-intensive applications in other domains • Precisely measure the gain od our approach in terms of co-evolution effort, based on realistic scenarios • Extension of the approach to other evolution scenarios (e.g., migration, integration) • Possible integration with an ORM technology? (no, I’m joking)
ORM technologies are getting very popular(just a few examples) C++: LiteSQL, Debea, dtemplatelib, hiberlite, romic, SOCI, etc. Delphi: Bold for Delphi, Macrobject DObject, InstantObjects, tiOPF, etc. Java: Carbonado, Cayenne, CocoBase, Ebean, EJB 3.0, Enterprise Objects Framework, Hibernate, iBATIS, JPM2Java, JPOX, Kodo, Object Relational Bridge OpenJPA, SimpleORM, Spring, TopLink, Torque, GenORMous, etc. .NET: ADO.NET Entity Framework, Atlas, Base One Foundation Component Library, BCSEi ORM Code Generator, Business Logic Toolkit for .NET, Castle ActiveRecord, DataObjects.Net, CocoBase, Devart LINQ to SQL, DevForce, Developer Express, ECO, EntityORM, EntitySpaces, Euss, Habanero, iBATIS, Invist, LLBLGen Pro, LightSpeed, Altova Mapforce, Neo, .netTiers, NConstruct, NHibernate, Opf3, ObjectMapper .NET, Picasso, OpenAccess, TierDeveloper, Persistor.NET, Quick Objects, Sooda, Subsonic, Wilson ORMapper, etc. PHP: CakePHP, Coughphp, DABL, Data Shuffler, dbphp, Doctrine, dORM, EZPDO, Hormon, LightOrm, Outle, pdoMap, PersistentObject, PHPSimpleDB, Propel, Rocks, Qcodo, Redbean, Xyster, etc. Python: Django, SQLAlchemy, SQLObject, Storm, etc. Ruby: Active Record, Ruby on Rails, Datamapper, iBATIS, Sequel, etc. Pearl: DBIx::Class, Rose::DB::Object, Fey::ORM, Jifty::DBI, DBIx::DataModel, Data::ObjectDriver, Class::DBI, etc.
ORM-based program development … and evolution Application programs Application programs O/R Mapping Class schema Relational DB schema Relational DB schema RDB data RDB data standard architecture ORM architecture Looks like our architecture … but the mapping is not automatically maintained
ORM-based program evolution… "Object/relational mapping is the Vietnam of Computer Science" Ted Neward "It represents a quagmire which starts well, gets more complicated as time passes, and before long entraps its users in a commitment that has no clear demarcation point, no clear win conditions, and no clear exit strategy.“ Ted Neward's Technical Blog - June 2006 http://blogs.tedneward.com/2006/06/26/The+Vietnam+Of+Computer+Science.aspx
Questions, comments, suggestions, complaints? anthony.cleve@fundp.ac.be
Generic schema representation • Generic Entity-Relationship Model (GER) • encompasses the three main abstraction levels • conceptual • logical • physical • serves as a pivot model for most data modelling paradigms • ER • relational • object-oriented • object-relational • file structures • network • hierarchical • XML • …