Flux Database/Designing the database structure

From Wikibooks, open books for an open world
Jump to navigation Jump to search

Workspaces consist of custom data forms and views. You can freely design the structure of the data forms, such as their data fields and relationship with views, and assign fine-grained access rights to groups of users. The database structure is defined in a single XML file.

To define a data form, use the Form tag. Every form needs to have an identifier and you can optionally provide a title. If no title is given, the identifier is used as the title.

Forms consist of data fields. In the following example, the Title field is of type text, i.e., a simple text field. The Author field is of type reference, which means that it refers to records from the view specified by the refview attribute. The reffields attribute lists the fields that will be displayed in the corresponding select box.

<Form id="Book">
  <Field id="Author" type="reference" refview="Authors" reffields="LastName, FirstName"/>
  <Field id="Title"/>
  <ReadAccess groups="admin;member"/>
  <EditAccess groups="admin;member"/>
  <CreateAccess groups="admin;member"/>
</Form>

Every form is associated with a list of groups, whose members can use the form to read, create, author and edit records. Readers can merely read records. Creators can create records but they can't edit them. Authors can create records and edit or delete their own records (i.e., the records created by them). Finally, editors can edit and delete all records.

Views, defined using the View tag, consist of columns that refer to data fields of the form specified by the form attribute.

<View id="Books" form="Book" sortBy="Title" sortOrder="asc">
  <Column id="Author" prominent="1"/>
  <Column id="Title" prominent="1"/>
  <ViewAccess groups="admin;member"/>
</View>

The prominent attribute tells the application that the column should be displayed using a bigger font in the list of records. The ViewAccess tag specifies the groups, whose members can see the view's records.

The records in a view appear sorted if the sortBy attribute is specified and refers to a data field of the corresponding form.