Archives for posts tagged ‘database’

4GL Patterns - #11 Custom Data Types

Rapid application development usually require data types beyond the simple INT, FLOAT and VARCHAR found in databases.
Here are some examples gleaned from existing frameworks:

Compiere/ADempiere - Account, Amount, Assignment, Binary, Button, Color, Costs+Prices, Date, Date+Time, FileName, FilePath, ID, Image, List, Location (Address), Memo, Product Attribute, Quantity, Row ID, Table, TableDirect, Text, Text Long, Time, URL, Yes-No, [...]

4GL Patterns #10 - Auditability

I have seen this pattern occur several times in my career. Ken Downs has a comprehensive treatment on history tables.
There are several high level ways of describing how versioning/auditability is implemented:

Versioned rows - history is mixed with current data in a single table. Results in complicated joins, archiving problems, performance trouble
Naive history tables - a [...]

4GL Patterns #9 - Search

Specific fields are marked as being searchable. User interface and code is automatically generated.
Examples of Search in RAD

Adding Full Text Indexes to char columns - MySQL, SQLite, SQL Server
Query By Example (QBE) in MS Access - is a special case where all fields are made searchable
Autogenerated modal forms with search/filter capabilities. Used when look-up [...]

4GL Patterns #8 - Table Patterns

Ken Downs classified database tables into several patterns. These are grouped along the lines of number of columns, number of rows, transient vs. permanent:

Reference Table - small number of columns, small number of rows, permanent. e.g. U.S. States
Small Master Table - small number of columns (but more than a simple reference table), small number of [...]

4GL Patterns

Why study patterns from 4GL applications?
Writing 4GL applications yields a lot of productivity clues that may be applicable to programming at large.
User-Interface programming forces the hand of the programmer. When a database has validation and consistency rules, these rules have to be repeated in the user-interface code, lest the end-user be presented with cryptic error [...]

4GL Patterns #7 - Data Dictionaries

RAD thrives on autogenerated forms, autogenerated bindings, and autogenerated validation rules.
To support RAD, database dictionaries should contain hints that form libraries can use.
Here is a compilation of useful rules, gleaned from several forms libraries (XForms, MS Access):

field caption
tooltip
default value
full text search (KeywordIndex)
isMetadata (Archetypes Field Reference)
postback (Archetypes Field Reference) - False for password fields. If validation [...]

4GL Patterns #5 - Field Filters

I have encountered this pattern twice. Once in CodeIgniter, and another time in Django. 
The basic idea is to pipe values through a series of filters before it is displayed in the presentation layer, or before it is saved in the database. These filters, if stored in a schema definition, can be applied globally to an [...]

4GL Patterns #5 - In-Schema Validation

There are several ways a database application can enforce that valid data is entered. These can be categorized into: database level, application server level, and client-side.

(database level) field type: DateTime, Characters, Characters up to a Maximum Length, Nullable, Zero Length string
(database level) foreign key constraints
(database level) Databases like MSAccess and SQL Server supply additional field [...]

4GL Patterns #4 - Type Converter Pattern

Database types which have a text representation include Currency, Date/Time, Boolean fields. If these fields are presented in text boxes, then appropriate formatters and parsers are used to translate text into actual model values and vice versa.
There are two types of parsers:

strict where field masks are provided to ensure the user typed in data in [...]

4GL Patterns #3 - Database Update Patterns

There are three ways data on a form can be posted back to the server.

Auto-Commit, where changes are applied to the database once user navigates away from a record.
Batch, where changes to records are saved as a batch when the user explicitly actions the Save command
Autosave to pending, where changes are saved to a temporary [...]

4GL Patterns #2 - Save and Action Pattern

The “Save and Action Pattern” allows a user to perform Save, followed by another action in a single click.
This is used to facilitate rapid data entry, or when users need to save intermediate results to prevent data loss.
The example below is from Django’s administration screens. The user is presented with three possible choices:

“Save and Add [...]

4GL Patterns #1 - Select or Add

A common pattern found in database applications is the “Select or Add” pattern.
The pattern allows a user to either

select an existing item (usually a foreign key), or
to add a new item to the foreign key table, then refresh the combo box, and setting the item to the newly added one

Example
The following is a screenshot [...]

Rich Metadata Mediated UI development

What would you automate into your boilerplate code after having 10 years of writing database applications? Here are some links to promising projects/essays:

Andromeda
Django Admin
Dataphor
Promises: User interface “hints” integrated with the data model

Naked Objects
MS Access and Query By Form
I like how CodeIgniter makes it possible to compose declarative data validations e.g. “valid_email|matches[email_confirm]|min_length[6]“
We need standard ValueConverters [...]