Register to post in forums, or Log in to your existing account
 

 Related 
Contents
Database Module
  Creating a Database
  Database Views
  Adding Data to a Database
  Quick Filters
  Programming the Database
  Advanced Database usage
Related Links:
  Database Module
  Creating a Database
  Adding Data to a Database
Database Views [[CMUD_Database_Views]] 
Database Views

A Database View is a subset of the database sorted and displayed in a particular way. For example, in an equipment database, perhaps you only wish to display the Weapons stored in the database. To do that you would create a Weapons view. The equipment database templates has a view for each equipment type, sorted by the name of the equipment.

For each view, you can control which columns are displayed, what order they are displayed in, how wide each column is, how the data is sorted, and what types of records to display.

A view called "All" is always defined and cannot be deleted. While you can change the sort order of this view, you cannot change which records are displayed. As the name of the view suggests, All records in the database are always displayed by the All view. However, feel free to change the column order or column widths as you'd like.

Changing a View's Appearance

You can change the width of a column in a view by clicking on the line between the column names where the mouse cursor changes to a resize image, and then dragging the edge of the column where you want it. To rearrange the order of the columns, click on the name of the column you want to move and drag it to its new location. The display will automatically update to show your changes.

To change how a view is sorted, click on the column header that you want to sort on. As you click on the column header, it will toggle between a normal sort, a reverse-order sort, and no-sorting. You can sort on multiple columns by holding down the Shift key when you click on a column to add that column to the sort list. So, to sort in Reverse order on the Hit field and then sort on the Name field, you would click the Hit column twice (to set it to reverse sort), then Shift-Left-click on the Name column to add it to the sort order.

Creating a New View

You can only change the appearance of the All view. To change other view properties you need to create a new view. Select New from the View menu or right-click on the empty space in the view tabs to the right of the All view tab. The View window will then be displayed.



The View window has a toolbar along the top, and a list of all fields in the database on the left. Just beneath the toolbar is a selection box for selecting the View you wish to edit, and the Name of the View. To the right of the Name is an option box labeled Auto Append. This option selects whether new fields added to the database are automatically appended to the columns in this view.

To the right of the list of database fields are three sections labeled "Columns", "Sort Order", and "Records (Filters)". These sections control which columns to display in the view, how the view is sorted, and which records are displayed in the View.

Columns in a View

The Columns area indicates the columns displayed in the view and the order that they are displayed in. The top value is the name of the column to be displayed at the left side of the database display. To add columns to the view, drag the name of the field from the list on the left and drop it into the Columns box. It will be added wherever you drop it. To remove a column from the list, drag the name of the column from the Columns box and drop it anywhere on the Field list.

You can also add a field by clicking on the item in the Columns list just below the point you want the new column, then click on the Field you want in the Field list, then click the Add button. The Add All button will add all of the fields to the Column list. The Remove All button will remove all columns from the column list.

To change the order of columns in the column list, simple drag the column you want to move to its new location in the list.

Sort Order

To change the way the view is sorted, drag the field you want to sort by from the Fields list on the left and drop it into the Sort Order box. You can sort on as many fields as you like. The field at the top of the list is sorted first. Items that have the same value for this field are then sorted by the second field in the Sort Order list. If you check the checkbox to the left of the field name in the Sort Order list, the order of the sort is reversed. For example, adding the Name field to the Sort Order list will normally display names in normal alphabetical order, starting at A and going to Z. If you check the box next to the Name field, the order is reversed, with Z shown first, and A last.

The Formula box beneath the Sort Order allows you to sort based upon a numeric "score" for each record in the database. This is explained in more detail in the Advanced Database section.

Record Filters

To select what records to display in the View you must create some record Filters. Filters are rules that describe the type of records to display. To create a new filter, drag the field you wish to filter on from the Field list on the left and drop it on the Record Filter box. A default filter for that field will then be displayed. You modify a filter using the different fields shown beneath the filter list. To delete a filter, drag it from the Filter box and drop it onto the Field list. To change the order of filters, simply drag the filter to the position in the list you want it.

Filters are combined using the boolean AND and OR operators. For example, you might want to display records that have the Kind field set to the value of Weapons AND records whose Level field is greater than 20. Or, you might want to display records that have the Kind field set to the value of Scrolls OR records whose Kind field is set to Potions to display both scrolls and potions in the same view. The AND and OR operation is selected with the first selection box on the left beneath the filter list. The AND operation has precedence over the OR operation. So, if you have three filters and set them up in the order F1 AND F2 OR F3, this is really the same as (F1 AND F2) OR F3. If you want to do F1 AND (F2 OR F3), you need to enter the filters like F1 AND F2 OR F1 AND F3 by repeating the F1 filter. Think of the AND as multiplication, and the OR as addition and you'll see how this works: F1 * (F2 + F3) = F1*F2 + F1*F3.

The selection box to the right of the AND/OR box is simply the Field selection box and should already be filled in properly if you dragged the field you wanted to filter from the list on the left of the window. However, you can change it here if you want. The first value in this selection box is called -formula- and is explained in more detail in the Advanced Database section.

To the right of the Field selection is the Operation selection. This important selection box tells the database what you want to test for. Several operations are given depending upon what Type the field is you are filtering on. For example, for Text fields, you can filter if the field Contains a certain string, Begins with a certain string, Ends with a certain string, etc. For Number fields, you can test if the number is Equal to a value, Greater then a value, Between two values, etc. Here is a complete list of the operations available for each field type.



Text, Memo
Contains, Equals, Begins with, Ends with, is not Empty, Greater than, Less than, Greater than or equal, Less than or equal



Number
Equals, is not Empty, Greater than, Less than, Greater than or equal, Less than or equal, Between



Single Option, Option List
Contains, Equals, Begins with, Ends with, is not Empty, Greater than, Less than, Greater than or equal, Less than or equal, Between, Has some items, Has All items



In the case of text fields, an alphabetic comparison is made, where as with Number fields a numeric comparison is made. The Between operations tests if it is between one value or another, or equal to one of those values (inclusive test). The Has some items tests an option field to see if it contains any of the items in a list. The Has All items tests an option field to see if it contains all of the items in a list. All of the text operations are case insensitive, so HELLO is equal to hello. To reverse or negate a filter, click the NOT option box.

Let's look at the example mentioned above for displaying level 20 or greater weapons. First, drag the Kind field to the filter list and change the Operation to Equals, then select Weapons from the list the appears below the operation selection box. Then, drag the Level field from the list on the left and drop it into the filter box. Change the operation to Greater than and enter 20 into the number box that is displayed below the operation list.

The line beneath the field selection and operation selector changes depending upon the operation that you select. If the operation requires a text value, a text box will be displayed. If it requires a number, a numeric entry box is displayed. If it requires you to select a value from a list, a selection box is displayed. To the left of the input box is a button labeled @ that is used to enter scripting formulas. This option is described in more detail in the Advanced Database section.

Saving your View

To save your new view, click the Save button. To discard any changes, click the Cancel button. You will be returned to the main database display and your new view will be shown.

To edit you new view, select the Customize option from the View menu or right-click on the name of the view in the view tabs and you will be returned to the View window.

While in the View window, you can select another view to edit by selecting the name of the view in the selection box just beneath the toolbar. If you change views, any changed made to the current view are automatically saved.

You can Delete a view by selecting Delete from the View menu in the main window, or by clicking the Delete button in the View window.

You can add a New view by selecting New from the View menu in the main window, or by clicking the New button in the View window.

Once you have some views defined you can start Entering Data into the database.
Viewer Comments [0 - Post your comments]

Jump to:  

© 2009 Zugg Software. Hosted by Wolfpaw.net