Parent Directory
|
Revision Log
Revision 771 - (view) (download)
| 1 : | sh002i | 771 | (nudge-to-right centering) |
| 2 : | |||
| 3 : | -------------------------------------------------------------------------------- | ||
| 4 : | Architecture | ||
| 5 : | -------------------------------------------------------------------------------- | ||
| 6 : | |||
| 7 : | The new database system uses a three-tier architecture to insulate each layer from the adjacent layers. | ||
| 8 : | |||
| 9 : | TOP LAYER: DB | ||
| 10 : | ------------- | ||
| 11 : | |||
| 12 : | The top layer of the architecture is the DB module. It provides the methods | ||
| 13 : | listed in doc/new-DB-API, and uses schema modules (via tables) to implement those methods. | ||
| 14 : | |||
| 15 : | / list* new* get* put* delete* \ <- api | ||
| 16 : | +------------------------------------------------------------------+ | ||
| 17 : | | DB | | ||
| 18 : | +------------------------------------------------------------------+ | ||
| 19 : | \ password permission key user set set_user problem problem_user / <- tables | ||
| 20 : | |||
| 21 : | MIDDLE LAYER: SCHEMAS | ||
| 22 : | --------------------- | ||
| 23 : | |||
| 24 : | The middle layer of the architecture is provided by one or more schema modules. They are called "schema" modules because they control the structure of the data for a table. This includes odd things like the way multiple tables are encoded in a single hash in the WW1Hash schema, and the encoding scheme used. | ||
| 25 : | |||
| 26 : | The schema modules provide an API that matches the requirements of the DB layer, on a per-table basis. Each schema module has a style that determines which drivers it can interface with. For example, WW1Hash is a "hash" style schema. SQL is a "dbi" style schema. | ||
| 27 : | |||
| 28 : | The null schema, "0", can handle all tables, but merely returns a false value for any method call. The null schema has no style. | ||
| 29 : | |||
| 30 : | Both WeBWorK 1.x and 2.x courses use: | ||
| 31 : | |||
| 32 : | / password \ / permission \ / key \ <- tables | ||
| 33 : | +--------------+ +----------------+ +---------+ | ||
| 34 : | | PasswordHash | | PermissionHash | | KeyHash | | ||
| 35 : | +--------------+ +----------------+ +---------+ | ||
| 36 : | \ hash / \ hash / \ hash / <- style | ||
| 37 : | |||
| 38 : | WeBWorK 1.x courses also use: | ||
| 39 : | |||
| 40 : | / set_user problem_user \ / * \ | ||
| 41 : | +-------------------------+ +-----+ | ||
| 42 : | | WW1Hash | | 0 | | ||
| 43 : | +-------------------------+ +-----+ | ||
| 44 : | \ hash / | ||
| 45 : | |||
| 46 : | The null schema "0" provides the set and problem tables. | ||
| 47 : | |||
| 48 : | WeBWorK 2.x courses also use: | ||
| 49 : | |||
| 50 : | / set set_user problem problem_user \ | ||
| 51 : | +-------------------------------------+ | ||
| 52 : | | WW2Hash | | ||
| 53 : | +-------------------------------------+ | ||
| 54 : | \ hash / | ||
| 55 : | |||
| 56 : | Other drop-in schema modules could be: | ||
| 57 : | |||
| 58 : | / * \ / password \ | ||
| 59 : | +-------+ +--------------+ | ||
| 60 : | | SQL | | PasswordLDAP | | ||
| 61 : | +-------+ +--------------+ | ||
| 62 : | \ dbi / \ ldap / | ||
| 63 : | |||
| 64 : | BOTTOM LAYER: DRIVERS | ||
| 65 : | --------------------- | ||
| 66 : | |||
| 67 : | Driver modules implement a style for a schema. They provide physical access to a data source containing the data for a table. Some driver modules are as follows: | ||
| 68 : | |||
| 69 : | / hash \ / hash \ / hash \ <- style | ||
| 70 : | +--------+ +--------+ +--------+ | ||
| 71 : | | DB | | GDBM | | DB3 | | ||
| 72 : | +--------+ +--------+ +--------+ | ||
| 73 : | |||
| 74 : | / dbi \ / ldap \ | ||
| 75 : | +-------+ +--------+ | ||
| 76 : | | DBI | | LDAP | | ||
| 77 : | +-------+ +--------+ | ||
| 78 : | |||
| 79 : | -------------------------------------------------------------------------------- | ||
| 80 : | Schema API | ||
| 81 : | -------------------------------------------------------------------------------- | ||
| 82 : | |||
| 83 : | $record - an object representing a record in the table | ||
| 84 : | @keyparts - values for fields that make up the table's key | ||
| 85 : | |||
| 86 : | @tables = tables() | ||
| 87 : | returns list of tables supported. static. | ||
| 88 : | |||
| 89 : | $handle = new($driver, $table) | ||
| 90 : | creates a schema interface for $table, using the driver interface | ||
| 91 : | provided by $driver. returns a false value if the $driver does not | ||
| 92 : | support the driver style needed by the schema. | ||
| 93 : | |||
| 94 : | @keys = $handle->list() | ||
| 95 : | returns a list containing the key of each record in the table. the | ||
| 96 : | elements of @keys are \@keyparts. | ||
| 97 : | |||
| 98 : | $result = $handle->new($record) | ||
| 99 : | attempts to add $record to the table. returns a false value if a record | ||
| 100 : | with the same key exists. | ||
| 101 : | |||
| 102 : | $record = $handle->get(@keyparts) | ||
| 103 : | attempts to retrieve the record matching @keyparts from the table. | ||
| 104 : | returns a false value if no record matches. | ||
| 105 : | |||
| 106 : | $result = $handle->put($record) | ||
| 107 : | attempts to replace the record in the table that matches the key of | ||
| 108 : | $record. returns a false value if no such record exists. | ||
| 109 : | |||
| 110 : | $result = $handle->delete(@keyparts) | ||
| 111 : | attempts to delete the record matching @keyparts from the table. | ||
| 112 : | returns a false value if no such record exists. | ||
| 113 : | |||
| 114 : | -------------------------------------------------------------------------------- | ||
| 115 : | Driver API | ||
| 116 : | -------------------------------------------------------------------------------- | ||
| 117 : | |||
| 118 : | @styles = styles() | ||
| 119 : | returns the styles supported by the driver | ||
| 120 : | |||
| 121 : | $handle = new |
| aubreyja at gmail dot com | ViewVC Help |
| Powered by ViewVC 1.0.9 |