[[TOC]]
= Generating MOLGENIS from scratch, step-by-step =
== 1. Create the data model XML[[BR]] ==
Create a new xml file ‘addressbook_db.xml’ in the root of you application. This file will contain the MOLGENIS model. Use the following template:
{{{
#!xml
}}}
== Create a “Contact” data type ==
{{{
#!xml
}}}
== Add properties to “Contact” ==
* A unique, automatic numeric identifier field that MOLGENIS will use to refer contacts.
{{{
#!xml
}}}
* A required and unique string field ‘displayname’ to have a unique label to find Contacts by. Note that if you provide no ‘type’ then type=”string” is implied.
{{{
#!xml
}}}
* Optional (‘nillable’) string fields for firstname, lastname and midinitials:
{{{
#!xml
}}}
* An optional field of type date for birthday:
{{{
#!xml
}}}
== Create a “Address” data type ==
* Create the entity again
{{{
!xml
}}}
* A unique, automatic numeric identifier field that MOLGENIS will use to refer addresses.
{{{
!xml
}}}
* Add the phone number field:
{{{
#!xml
}}}
* Add a field where the user can choose from an enumeration of options whether the address is ‘home’,’work’,or ‘mobile’:
{{{
#!xml
}}}
== Link Addresses to Contact. ==
* In the Address entity create a [http://en.wikipedia.org/wiki/Foreign_key ForeignKey] reference to Contact
{{{
#!xml
}}}
Note that the xref_field refers to unique field ‘contact_id’ in entity ‘Contact’. The xref_label attribute indicates that we want to view references to Contact by ‘displayname’ name instead of the numeric id.
Use of a meaningless numeric ‘id’ next to a meaningful ‘label’ enables us to change the ‘displayname’ name on Contact without the problem of also having to change this on each Address that refers to this contact.
== Result ==
[[Image(address-book-screenshot.JPG)]]