wCMF  3.6
 All Classes Namespaces Files Functions Variables Groups Pages
dbschema.doxy
Go to the documentation of this file.
1 /** @page dbschema
2  *
3  * @section dbschema Database scheme
4  *
5  * @note The following section applies only, if a database and the
6  * appropriate classes (UserRDB, RoleRDB, NMUserRole, LockManagerRDB, UserManagerRDB) are used
7  * in the application. At the moment locking is not supported when using XML files as
8  * data storage. For storing users and roles there is a DTD given in the class
9  * UserManagerXML.
10  *
11  * For its infrastructure (user, locking, ...) the framework needs some
12  * base tables, which are defined in the file tables.sql (directory
13  * @em blank/install in the framework) of the application template (see @ref howtostart).
14  * The definition of the data model's tables is completely free (see
15  * @ref howtotype).
16  *
17  * The tables have the following definitions:
18  *
19  * @subsection seqtable ID Sequence
20  *
21  * When rows are inserted in the data tables, ADOdb creates an unique ID.
22  * In the table @em adodbseq this ID is counted up. Please note, that when inserting
23  * data manually into the data tables the id attribute of the adodbseq table
24  * has to be set to a value higher than the highest ID to assure that ADOdb
25  * doesn't generate already existing IDs.
26  *
27  * @verbatim
28  DROP TABLE IF EXISTS `adodbseq`;
29  CREATE TABLE `adodbseq` (
30  `id` int(11) NOT NULL default '0'
31  ) TYPE=MyISAM;
32 
33  INSERT INTO `adodbseq` (`id`) VALUES (100); @endverbatim
34  *
35  * @subsection usertables User Tables
36  *
37  * There are three tables for the user management, which are used by UserManagerRDB and UserRDB upon login:
38  * @em user, @em role and @em nm_user_role. %User data is stored in the table user, the definition of groups in
39  * the table roles.@n
40  * The rights management is based on roles (see @ref secauthorization). As a result it's crucial for authorization
41  * to which group the user belongs, who is logged in.
42  * This assignment is made in the table nm_user_role, where the two foreign keys fk_user_id and fk_role_id
43  * point to the corresponding tables. This means that a user can be in several groups and one group can
44  * contain several users.@n
45  * Upon installation the group @em administrators and the user @em admin (password admin)is created.
46  * admin is assigned to group administrators. Furthermore
47  * the user admin obtains the configuration file include/admin.ini.
48  * @note Passwords are stored encrypted in the database. For the creation of passwords the tool
49  * /wcmf/tools/password/password.php can be used. The encryption is carried out in the method
50  * UserManager::encryptPassword.
51  *
52  * @verbatim
53  DROP TABLE IF EXISTS `user`;
54  CREATE TABLE `user` (
55  `id` int(11) NOT NULL default '0',
56  `name` varchar(50) default NULL,
57  `firstname` varchar(50) default NULL,
58  `login` varchar(50) default NULL,
59  `password` varchar(50) default NULL,
60  `config` varchar(255) NOT NULL default '',
61  PRIMARY KEY (`id`)
62  ) TYPE=MyISAM;
63 
64  INSERT INTO `user` (`id`, `name`, `firstname`, `login`, `password`, `config`)
65  VALUES (0, 'Administrator', '', 'admin', '21232f297a57a5a743894a0e4a801fc3',
66  'include/admin.ini');
67 
68  DROP TABLE IF EXISTS `role`;
69  CREATE TABLE `role` (
70  `id` int(11) NOT NULL default '0',
71  `name` varchar(50) default NULL,
72  PRIMARY KEY (`id`)
73  ) TYPE=MyISAM ;
74 
75  INSERT INTO `role` (`id`, `name`) VALUES (0, 'administrators');
76 
77  DROP TABLE IF EXISTS `nm_user_role`;
78  CREATE TABLE `nm_user_role` (
79  `fk_user_id` int(11) NOT NULL default '0',
80  `fk_role_id` int(11) NOT NULL default '0',
81  KEY `fk_user_id` (`fk_user_id`,`fk_role_id`)
82  ) TYPE=MyISAM;
83 
84  INSERT INTO `nm_user_role` (`fk_user_id`, `fk_role_id`) VALUES (0, 0); @endverbatim
85  *
86  * @subsection locktable Lock Table
87  *
88  * When the application is used concurrently, the LockManager can be activated in order to protect
89  * the user's work (see @ref howtoconcurrency). For the storage of locks on data records the
90  * %LockManager's database implementation (LockManagerRDB) uses the following table:
91  *
92  * @verbatim
93  DROP TABLE IF EXISTS `locktable`;
94  CREATE TABLE `locktable` (
95  `oid` varchar(255) NOT NULL default '',
96  `sid` varchar(255) NOT NULL default '',
97  `fk_user_id` int(11) NOT NULL default '0',
98  `since` datetime NOT NULL default '0000-00-00',
99  PRIMARY KEY (`oid`)
100  ) TYPE=MyISAM; @endverbatim
101  *
102  * Back to the @ref intro | Previous section @ref configuration | Next section @ref howto
103  *
104  */