Data Definition Language
(the Makumba abstract level)
Types, objects, databasesData definitions describe data types (or classes). They are placed in files contained in directory hierarchies, and the directory name is part of the type name (similar to Java packages). For example the file best/Student.mdd describes the type best.Student. Type names can contain letters, digits, underscores and dashes and cannot contain slashes and dots. Usually, the directories are used to separate organisations and projects. Current Java implementation finds the data definition files as follows:
Data objects (records) are stored in databases. The actual implementation of the database is not part of this specification but implementation suggestions will be made. Data can be copied and/or replicated between different databases, even between different DB engine types. Replication is not yet implemented, but the design is prepared for it. Copying
works.
FieldsEvery data definition file contains field definitions, separated by newline. A field definition looks like: fieldname= [attributes] fieldtype [parameters] [; description]
default values are supported internally, but not by the mdd parser
As an implementation guideline, field names tend to stay approximately the same
in:
(Automatic labeling: The field description might be used at interface levels to present that field. It is typically shown at the left of, or somewhere near to, the input control (text box, radio button, chooser, etc) that allows for data input in that field. If a field description is not present, its field name stands for its description by default.) Comment lines can be inserted in the data definition files as follows: # your comment... Default fieldsEvery datatype has some additional fields by default, as follows:
Simple field typesintA 32-bit integer. For example shoeSize= int; Shoe size If the int can have a limited number of values, it can be described as follows gender= int{ "male"=0, "female"=1 }; Sex
This will help the presentation layer to present a suitable input control (e.g. ) "deprecated" can be used in this way to denote a deprecated option:
userType = int{"type1"=10, "type2"=10,"old"=0 deprecated} In the present implementation, this type is called "intEnum" internally.
Negative numbers are supported (e.g. int { "aa"=5, "bb"=2, "cc"=-10}). realA real number with double precision with (2-2-52)·21023 as max value and 2-1074 as min value. For example: high= real; high of a person charA char field contains a number of characters. Maximal width must be specified and is limited to 255. (Optionally a minimal number of characters (lesser than max) can be indicated). Both must be positive integers. For example: #fieldName= char[maxWidth] " Pay close attention to the character set (charset) for encoding the characters. In Java the
charset is Unicode, but the JSP/HTML pages have their own encoding settings, as well as the database, etc.
DEPRECATED (use int{...} instead): If the char can have a limited number of value, it can be described as follows gender= char{ "male", "female" }; Sex
This will help the presentation layer to present a suitable input control (e.g. a HTML SELECT) in the present implementation, this type is called "charEnum" internally
booleanA boolean, that can take as values true or false. For example: hasChildren= true; whether this person has children textAn unlimited-length string of characters. This type is designed to accommodate large text content. It is implemented with LONGTEXT or its counterparts, depending on the underlying DB engine. The text data-type is ready for accepting data in UTF-8 encoding. application= text ; Application letter binaryAn unlimited-length field designed for binary content. In contrast to the singature= binary ; a binary digital signature dateA date and/or time. birthdate= date; Date of birth Structural (relational) typesPointers (ptr)Pointers define a reference to an object of a certain type. For example citizenship= ptr general.Country; Citizenship the
ptr keyword might be ommitted in future parsersThe type can be defined on-the-spot for a single usage. For example addres= ptr ; Address The main difference between sets of external types and internal sets is that when the host
object (e.g. Person.mdd that has the above field "address") is deleted from the database (DB), also all elements of
the set (addresses) are deleted automatically, so there is no orphans (addresses) in the DB. Elements (addresses) of
an internal set of some host object (Person X) also can't be used in a set of some other host object (Company Y).
future parsers might read this:
address= ptr{
this type is known internally as ptrOne
Sets (set, bag, list)Sets define a number of references to multiple objects of a certain type. For example: language= set general.Language; Spoken languages This type accomodates sets, bags and lists. The set and list constraints (sets have to contain only one element of a certain value and lists have to be ordered) have to be cared for by the programmer. Lists are easy to represent, just having an integer field, for the order. The type which the set is made of can be defined on the spot: addresses= set; Addresses the future parser might recognize this form:
addresses: set{
this type is known internally as setComplex
The set can contain enumerated int values : place= set int {"home"=1, "away"=0} ; Home or away
this is currently known internally as setintEnum
DEPRECATED: The set can contain enumerated char values : place= set char {"home", "away"} ; Home or away
It means that place is a set that can take only the "home" and "away" values.
This is currently known internally as setcharEnum
FileA file data-type is a kind-of record containing several fields needed when wanting to store files. These fields are:
image= file ; Picture attachment All fields are automatically set by Makumba, all needed to do is to make a <mak:input> on the field name. This type should be used in favour of the binary data type when you don't want to store only the raw binary data, but also meta-data as in the fields above. Macro typesA name can be defined for a more complex type and it can be reused in the file. This can be done with a !type directive !type.yesno= int{"yes"=1, "no"=0}
Field attributes
Object titleThe object title is used for set and ptr choosers
One of the fields is always the object title, and is normally presented differently from other fields in user interface. For example, when you have a field that is a set and you use a mak:input on that field, Makumba will automatically create a list with all the items in the set and it will use the object title to know what field to display. The default is the field called "name" if that exists, otherwise it is the first non-pointer field in the record description. If another field needs to be title, it can be specified like !title=gender for the on-the spot types in the current implementation, the following notation works:
address->!title= street Include mechanismA record description can include text from one or more files. This is declared as !include=name_of_included_type The included file has the idd extension and is found in a similar way like the data definitions. The included file is inserted instead of the !include line. There can be more include lines in a record description file. If a field is defined that exists also in the included metadata, the defined field takes precedence. If fieldname= it means that it does not actually exist. this can be used to cancel an included field. include might be replaced by more advanced concepts such as inheritance and type
inclusion (rather than reference in foreign table)
Validation RulesValidation rules are defined inside a data definition, and allow Makumba to automatically validated form data input. The general syntax of a validation rule definition is as follows: [validation rule name] : [validation rule] : [error message] Validation rule nameThe validation rule name is an identifier which should be unique. The exact usage is not yet specified, but it could be used in the future to centralise error messages or provide translations into other languages, etc. Validation ruleThe validation rule specifies what should be validated, and can be one of the following [range validation | string length | regular expression | comparison] Number range ruleThe range definition rule applies for [fieldName]%range = [1..10] Using To require that the age needs to be between 12 and 99: age%range = [12..99] : Age must be between 12 and 99! To define that we need to be at least 5 year old, but without any upper limit: age%range = [5..?] : Age must be at least 5! String length ruleThe length definition rule is very similar to the range definition, but applies for [fieldName]%length = [1..10] Using To define that the CV needs to be at least 100 characters, define: cv%length = [100..?] : CV must be of decent length! Regular expression ruleThe string regular expression rule applies for [fieldName]%matches = regular expression Regular expressions must be valid regular expressions in Java, for more details please refer to the specification and tutorial. To compare if a field contains a valid e-mail address, define: email%matches = .+@.+\.[a-z]+ : Email address is not valid! Comparison ruleThis rule allows to compare a field to a constant value or simple function calls. The following constants are currently available:
The following functions are currently available:
Valid comparison operators are the ones defined in Java:
To compare if someone is at least 15 years old, define the following validation rule: minimumAge%compare = birthdate >= date($now,$now,$now - 15) : You have to be at least 15 years old! To ensure that a field doesn't contain only lower-case values, define this rule: nameNotAllLower%compare = lower(name) != name : Your name must not contain only lower-case letters! Two fields can be compared in a similar way graduationCheck%compare = birthdate < graduationDate : You cannot finish school before your birthdate! Multi-field uniqueness definitionSimilar to the unique field attribute, you can also define multi-field uniqueness contraints. These constraints can even span over several data definitions, if they are related via pointers. Multi-field uniqueness can be defined as follows uniqueAgeEmail%unique = age, email : the combination of age and email must be unique! If the fields are in the same data definition, the uniqueness definition will
translate into a database level multi-field key and uniqueness will be enforced there.
Otherwise, Makumba will issue a query checking the uniqueness before new or edit operations. Error messageThe error message that will be displayed if the validation fails. |