A C++ DAL / ORM code generation framework
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

55 lines
3.5 KiB

12 years ago
  1. Design Architecture for WORM
  2. This document describes the basic architecture for a DAL and ORM layer.
  3. This is a general treatment and unfinished.
  4. The database abstaction layer consists of four functional components that share one point of
  5. entry to the database (via. the driver).
  6. 1. Classes which offer and API for basic CRUD interaction with the database.
  7. These include:
  8. * WSqlDatabase - the sole point of access recommended; all raw/direct interaction with
  9. the database should use an instance of this class - the API is intended to provide any
  10. direct query actions, insertions, selection of datasets, etc.
  11. * WSqlDriver - this is a base class to be implemented by adapters for specific datastore
  12. engines (currently MySql5, Sqlite3 and PosrgreSQL adapters are implemented). This class
  13. does all the heavy lifting behind the scenes for the WSqlDatabase API. It should not be
  14. used directly.
  15. * WSqlRecord - datasets (or result sets) are encapsulated by WSqlRecord; this class is
  16. returned by the API for queries that return results (may be empty ..) - it is initialized and
  17. managed by the driver which hands it to WSqlDatabase. Random access to sets of the
  18. records is supported (if cached). This is also the prefered method of insertion or update
  19. - an initialized WSqlRecord sent to the driver is the cleanest interaction.
  20. WSqlRecord is basically a vector of WSqlFields with some convenience methods for seeking
  21. in the columns.
  22. * WSqlField - represents a single data column in a record consisting of a column name
  23. and a value (ie. simple key/value data structure). It does _not_ contain metadata about
  24. the value. The value is stored as a string of characters as received from the database.
  25. The value can therefor be easily converted to native C++ data types using the convenience
  26. methods provided.
  27. This class is intended to provide a simple and efficient data transfer - not metadata; if
  28. metadata about the database column, data type etc. is needed WSqlColumn is to be used.
  29. * WSqlResult - this class represents a set of returned records (or records to be inserted/updated)
  30. it is an internal managed cache object for the driver.
  31. 2. Classes which offer and API for obtaining metadata about the database schemata. These may
  32. instantiated for access to metadata at runtime but are primarily for use by the ORM generator.
  33. These include:
  34. * WSqlCatalog - access to all schemata in the DBMS (unimplemented)
  35. * WSqlSchema - access to a metadata for a single database
  36. * WSqlTable - metadata for a single table
  37. * WSqlColumn - metadata for a single column
  38. * WSqlIndex - metadata for an index in a table
  39. * WSqlForiegnKey - metadata for a foriegn key relationship
  40. 3. Classes which deal with generating ORM class object source code representing the metadata
  41. for existing database schemata.
  42. These include:
  43. * TBD
  44. 4. Generated ORM classes and scaffolding providing an alternate CRUD vector. These class
  45. object may be used directly for CRUD functions with no interaction with the DAL classes.
  46. Eg.:
  47. user = new User(); user->setName("joe"); user->save();
  48. or
  49. int id = 33; user = User::load(id); cout << user->name();