Rev 18 | Rev 26 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed
<html>
<body>
<p>
CAMP is designed to be run with a relational database which is supported by the PHP PDO class. It has been developed and tested using MariaDB.
</p>
<p>
Version 2 is a complete rewrite, with emphasis on getting the basic system right, then adding functionality through modules. Thus, the decision was made to only include the minimum functionality required to track an asset (called a device in the app) through sites and clients. Since modules are not allowed to modify the structure of any tables, this basic database structure will be static, requiring a major revision to modify.
</p>
<p>
This document describes the structure of the basic database, without modules.
</p>
<p>
CAMP has two types of tables; system and data. System tables are preceded by an underscore, and are used for program flow.
</p>
<p>
System tables can have rows edited, updated, added and deleted as necessary. For example, adding a new module often requires adding rows to _system and _menu, and removing a module will remove those entries.
</p>
<table border='1'>
<tr>
<td valign='top'>_system</td>
<td valign='top'>
configuration of system, similar to an INI file structure. Contains columns group_name, key_name and theValue, corresponding to<br />
[group_name]<br />
key_name=theValue<br />
This is modified programmatically any time a module is added or removed, or if system wide configurations need to be made.
</td>
</tr>
<tr>
<td valign='top'>_menu</td>
<td valign='top'>describes the menuing system used in the program. This is based on the library DBHierarchialHash (DBMenu extends it). Each entry is a menu, with a (possibly null) parent, a caption, and a URL to go to if the menu item is selected.<br />This is modified by modules, with menu items added when a module is activated</td>
</tr>
<tr>
<td valign='top'>_user</td>
<td valign='top'>defines access to the program. However, _user entries should never be removed as the can be linked to various modules. Thus, it has two date fields; added_date and removed_date to allow removal from access while maintaining structual integrity.</td>
</tr>
</table>
<p>
The remaining tables should never have rows deleted under normal circumstances, in or to track history and/or maintain data integrity. They have two additional date fields, added_date and removed_date. An edit of any of these tables proceeds as follows:
mark "deleted" row with removed_date = a non-null value
copy the newly removed row's data to new row, modifying the fields necessary (added_date always)
</p>
<p>
The basis of the whole system is the device (aka asset). An asset has an owner (client) and a location (site). Since we don't want to lose historical data, the linkage between devices, clients and sites is done through join tables, named by the tables they join, thus, client_device links the client and device tables. Additionally, a site is owned by a client, so there is a client_site table.
</p>
<p>
A device can also be a part of another device in the table. An example is a virtual machine which is hosted by a physical machine. In this case, we use a separate table to mark the "part of" relationship.
</p>
<table border='1'>
<tr>
<th>Linkage Table</th>
<th>Connection 1</th>
<th>Connection 2</th>
<th>Notes</th>
</tr>
<tr>
<td valign='top'>client_device</td>
<td valign='top'>client</td>
<td valign='top'>device</td>
<td valign='top'>A client "owns" a device, but this can change.</td>
</tr>
<tr>
<td valign='top'>client_site</td>
<td valign='top'>client</td>
<td valign='top'>site</td>
<td valign='top'>A client "owns" a site. This client is not necessarily the same as the owner of a device on that site</td>
</tr>
<tr>
<td valign='top'>site_device</td>
<td valign='top'>site</td>
<td valign='top'>device</td>
<td valign='top'>A device is at a particular site (which may not be the owners site)</td>
</tr>
<tr>
<td valign='top'>device_device</td>
<td valign='top'>device</td>
<td valign='top'>device (parent)</td>
<td valign='top'>A device can be part of another device. For example, a USB printer can be part of a computer, or a Xen DOMU may be on a physical DOM0</td>
</tr>
</table>
<p>
The current (2017) plan is that linkage tables will only be one-to-one.
</p>
<p>
A device also has one child table, device_type. device_type allows us to categorize devices by function; router, server, workstation, virtual. This relationship does not involve link tables; one of the columns in device is device_type_id, so a device can only have one type.
</p>
<p>
Finally, there is one weird table, alias. I found computer names change over a period of time, and there can actually be multiple names for a device at the same time, especially when automated reporting is done.
</p>
<p>
alias is not a true relational table. Instead, it tracks aliases for devices, sites or clients, depending on the source column; a 64 varchar which is designed to store the table name it is aliasing. This is a kludge to solve a problem that exists in real life, but has no elegant solution in a DBMS.
</p>
<p>
See database.png for a diagram of the basic database.
</p>
<p>
IMPORTANT: This document describes the actual database layout. However, CAMP does not read the layout from the database. Instead, it uses a hash to describe the database and some PHP classes that automate a lot of the screens. After the database is defined, the hash must be created. See DatabaseDefinition.php in the include directory.
</p>
<table border='1'>
<tr>
<th>
Table
</th>
<th>
Description
</th>
</tr>
<tr>
<td valign='top'>
device
</td>
<td valign='top'>
Holds some basic information about a device; name, device_type and any notes you may want
</td>
</tr>
<tr>
<td valign='top'>
client
</td>
<td valign='top'>
Holds information about a particular client, such as name, notes, and private notes which are available to limited visitors
</td>
</tr>
<tr>
<td valign='top'>
site
</td>
<td valign='top'>
Physical sites which may house devices. Table holds information such as name and any special notes.
</td>
</tr>
<tr>
<td valign='top'>
alias
</td>
<td valign='top'>
things get renamed occasionally. Sites may go by one or two names, clients can change names, and devices especially can change names when pulled and redeployed. However, they are still the same item. This is especially important when automated processes (backups, sysinfo) can update the database and use a different name than is stored her, or when a device has a name change.
<br />while aliases mainly concern devices, the table is set up to also handle site and client, by the field <b>source</b> which holds the name of the table for which this alias refers.
</td>
</tr>
</table>
</body>
</html>