|
Creating A Table | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
It All Starts With A Mouse Click |
Before creating a table prepare yourself:
Once you have answered these questions you're ready to define your entity through the structuring of its attributes in table form. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Records & Data Fields |
When you create a new table, you first create it's structure. A table's structure is stored within it's ".msstr2" structure file. The structure file specifies the structure of the data table at the level of its records.
A record is defined within madsearch2 by breaking it down into its compositedata fields which store the attributes of an entity record. Fields are, in turn, further broken down and defined by the following elements:
Taken together, these defining elements of a data field are called a "field definition. Once you've entered the table structure utility, you'll see the following: Each row of this table contains all the elements necessary to create a field definition. Each column represents an element of a field definition. The first row corresponds to the field definition of the first row within our table. The second row corresponds to the field definition of the second row, and so on... |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Field Definitions |
Field Names The field name element of a field definition names the attribute to be stored within a column of a table. Field names may contain any combination of alphanumeric characters. Spaces are not permitted. Field names are used in constructing queries against data tables and to refer to data fields within reports. Field Type The field type element defines the type of attribute information to be stored within a data field. The field type determines how comparisons are made against values within this field in addition to what types of data are valid. Whenever a data field is assigned a value, madsearch2 validates the appropriateness of the value given a field's type. Validation of input includes validation of a data type's range, formatting, minimum length, and content. For example, if a field were declared to be of type "Integer", the following input values would be unacceptable:
There are two categories of field types: data types and security types. Data types store attribute values. Security types store information permitting/restricting who may view/modify records and their attributes. The following is a table describing the various data field types and the values that may be entered within them:
The next data types we will describe are security field types. Security data types are used in establishing record level security. Record level security is the ability to specify, record by record, who may view, modify, or delete a record. In implementing record-level security, madsearch2 takes its cue from unix file system permission levels. In madsearch2, just as in unix, there are three levels: user, group, and other. For each level, madsearch2 allows you to specify which group may have access and what types of access (i.e. what permissions they have with a given record).
The following table describes the five security data types:
There are a number of rules and restrictions imposed on the values of these fields. For example, unlike unix file system permissions, the user owner of a record cannot grant themselves a user permission (including the access control permission) unless the table administrator has previously granted them the access control permission for the record. A detailed explanation of madSearch2 record level security is contained within the section "Security". It is extremely important that you understand madSearch2's security features and policies prior to creating a table for an application. For now, it suffices to know that these fields exist and are used for the stated purposes. Field Length Many of madSearch2's field types store fixed-length values. For example, integers are always stored as a 4 byte (32 bit) value. However, the following fields require that you specify the maximum space to be reserved to accomodate the field's values:
These fields are sometimes referred to as variable width fields. Their size is specified as the number of characters necessary to accomodate their possible values. For example, a field storing social security numbers that are formatted to include dashes (###-##-####) would require a field size of 11. It is important that you not under allocate space for your data. You do, after all, want to be able to store all possible valid values. However, it is also in your interests not to over allocate. madSearch2 provides no means for compressing large alphanumeric fields. As a general rule: the smaller the table, the better the performance. Field Format A useful madSearch2 data validation feature is that of imposing a field format on field values. For example, one may wish that date values always be entered in the format "mm/dd/yyyy" or that social security numbers be entered as "###-##-####". The field format element of a field definition provides this functionality. There are two classes of field formatting options: those for alphanumeric-type fields and those for date/time type fields. The first class of field formats, allows you to specify a regular expression as the field format. All data field values must match the regular expression provided. The following table describes the characters that combine to form a regular expression in madSearch2:
For those of you who found the preceeding table to be rather dense, the following examples are provided to illustrate madSearch2 regular expressions:
The second class of field formatting expressions are those that deal with date, time, and datetime field value validation. The format strings for date, time, and datetime fields are made of formatting descriptors which specify which pieces of the field value are to be incorporated in the value presented. You can think of their format strings as a combination of surrounding text and descriptors where the surrounding text provides structure. You can also think of them as mini-templates. Fields of type date and time do not share descriptors within one another. Therefore, we present them in separate tables. Fields to type datetime can mix and match the descriptors of both date and time fields within their format strings. Date Field Format Descriptors
Time Field Format Descriptors
Key madSearch2 supports primary keys on its tables. A primary key is used to uniquely identify records within a table. A madSearch2 primary key can consist of one or more fields. A primary key made up of multiple fields is referred to as a composite key. The primary key is used to build an index on the table. This index orders records within the table and speeds various query operations that reference key fields. The field(s) of a primary key must appear as the first fields within the table. In a composite primary key, just as in a one field primary key, the key fields taken together must uniquely identify a record. In specifying that a field is part of the primary key, you may select "ascending" or "descending" from the "Key" element of the field definition. The "ascending" option instructs madSearch2 to sort values in the field in ascending order: a -> z, 1 -> 9. The "descending" option instructs madSearch2 to sort values in the field in descending order: z -> a, 9 -> 1. In ordering the records of a table with a composite primary key, madSearch2 begins with the first field and continues to sort according to the following fields of the primary key. madSearch2 enforces primary key constraints on tables for which a primary key has been defined. Any attempt to insert a record whose primary key field(s) duplicate those of another record within the table yields a "key violation" and a rejection of the record. Records violating key constraints are removed from the data table and written to an associated non-keyed table. The non-keyed table's name is that of the core data table with the phrase "-keyviol" concatenated. For example, if your table was named "people" and located within the directory "/wwws/data/cu/myData", it's associated key violation table would be "people-keyviol" located in "/wwws/data/cu/myData". If a field is not a member of the primary key, leave the "Key" element set to blank (no selected option). Required A required field is one for which a value must be specified at all times. MadSearch2 checks that the required field constraint has been met when the query is executed. The keyword "blank" (to be described later) is not acceptable for a required field as "blank" specifies the absence of a value. Default Value This field definition element specifies the default value to be given to the associated field of a newly inserted record should no value be specified. Any default value provided must conform to the field type, field length, field format, and field content restrictions specified or implied. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Creating A Table |
To create a new madSearch2 table, simply follow the instructions below. The instructions assume that you have prepared a directory in which to store your new table as per the directions in the previous section, "Preparing A Directory For MadSearch2 Data Tables"
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
A Few Final Thoughts & A Promise |
When you create a madSearch2 table, you are the administrator of the table. The administrator of the table is the person responsible for granting users access to the table and its data. The administrator is a privileged role which allows you to use various madSearch2 utilities to import, export, encrypt, modify, and empty the table. By default at the table level of security, all other users will have "read" permissions on the table. We will delve into madSearch2 security further in a later section entitled, "Security". For now, this may not mean very much to you. It is very important to remember these default assignments when you later consider further access control/security arrangements. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||