package org.melati.example.contacts;

table Contact
  (displayorder = 10)
  (category = "Data")
  (description = "A Contact") {

  (primary) Integer id
    (displaylevel = record) 
    (searchability = no);

  String name 
    (size = unlimited) 
    (displaylevel = primary) 
    (searchability = primary)
    (description = "Contact Name")
    (displayorderpriority = 0)
    (width = 20);

  Contact owner
    (nullable)
    (displaylevel = summary) 
    (searchability = yes)
    (displayorderpriority = 1)
    (description = "Contact who owns this contact")
    ;

  String address
    (size = unlimited) 
    (displaylevel = record) 
    (searchability = no)
    (description = "Contact Address")
    (height = 5)
    (width = 40);

  Integer updates
    (displaylevel = record) 
    (searchability = no)
    (description = "How many times has this record been updated?")
    (uneditable)
    (uncreateable)
    (width = 5);

  Date lastupdated
    (displaylevel = record) 
    (searchability = no)
    (renderinfo = "org.melati.poem.DatePoemType-dropdown")
    (uneditable)
    (uncreateable)
    (description = "When was this last updated?");

  User lastupdateuser
    (displaylevel = record) 
    (searchability = yes)
    (uneditable)
    (uncreateable)
    (description = "Who last updated this?");

}

table Category
  (displayorder = 100)
  (category = "Codes")
  (description = "A Category for Contacts") {

  (primary) Integer id
    (displaylevel = record) 
    (searchability = no);

  String name 
    (size = unlimited) 
    (displaylevel = primary) 
    (searchability = primary)
    (description = "Category Name")
    (displayorderpriority = 0)
    (width = 20);
}

table ContactCategory

  (displayorder = 10)
  (category = "Data")
  (description = "Contacts Categories") {

  (primary) Integer id
    (displaylevel = record) 
    (searchability = no);

  Category category
    (displaylevel = primary) 
    (searchability = primary)
    (description = "Category")
    (displayorderpriority = 0)
    (integrityfix=delete);

  Contact contact
    (displaylevel = summary) 
    (searchability = yes)
    (description = "Contact")
    (displayorderpriority = 1)
    (integrityfix=delete);

}



