--
PedroRio - 17 Dec 2010
XEO Library - Modeling the Entities
In the
last section, you've seen how to use XEO Studio to create the XEO Model for the Author entity (named LIB_Author). Now we'll start by progressively create the XEO Object Models for the other entities. To make things easier to explain and also to show XEO's ability to deal with change over time we'll first create some Object Models that do not contain all of their attributes and, as the explanation progresses, add the remaining attributes later on.
We've already learned how to add a textual attribute, define the label, set its length and make it a required attribute (from the previous section), so we'll now make use of that knowledge to define the next entity: the "Book Category". We'll first define a small convention to use in this section of the documentation regarding XEO Object Models, which is:
Object_Model_Name ( Object Model Label)
- attribute name (type, label, description [,length] [, required ])
- attribute2 name (type, label, description [, length] [, required ])
- etc...
We first start with the Object Model Name and it label within curly brackets. For each attribute of the Object Model we have an unordered list item with the name of the attribute and properties about it inside curly brackets (such as its type (text, number, date), a label, a description, its lenght (1 - 5000+). An example maybe more clear, for the Book Category entity (
recall the book category entity from previous sections):
LIB_BookCategory ( Book Category)
- name (Text, 'Name', 'Name of the Category' ,30, required)
To create the LIB_Category Object Model, go to the "File" menu, select "New" and then "XEO Object Model". In the XEO Package field, browse to the "LIB$1.0" package and in the name fill "LIB_BookCategory", in the description you can write "Represents a book category". Press finish and add a "Text" attribute and fill the name with "name", label with "Name" , description with "Name of the category", length with 30 and in the "Required" section, choose "BOL" from the dropdown menu and type "true" in the field that appears. Your Object Model should look like the one depicted in figure ME.1 and ME.1a.
Figure ME.1 - Book Category Object Model
Figure ME.1a - Book Category Name Attribute
Next, let's create a few more Object Models for entities (Publisher and Book). Create the Publisher entity as the following (use the new Object Model wizard as before and choose the LIB$1.0 Package):
LIB_Publisher ( Publisher )
- name (Text, "Name", "Publisher Name", 40, required)
- address (Text, "Address", "Publisher Address", 100, required)
- website (Text, "Website", "Publisher WebSite", 40)
Then, create the Book entity with the following definition (also in the LIB$1.0 package):
LIB_Book (Book)
- title (Text, 'Title', 'Book title', 100, required)
- isbn (Text, 'ISBN', 'The Book's ISBN', 13, required)
- edition (Text, 'Edition', 'Book Edition', 30, required)
- summary (LongText, 'Summary', 'Summary of the Book') - LongText attributes do not have the length property
- frontCover (BinaryData, 'Front Cover', 'The Book's Front Cover') - Binary Data attributes (files) also don't have length property
- backCover (BinaryData, 'BackCover', 'The Book's Back Cover')
Save both Object Models and by now you'll have four XEO Object Models (LIB_Author, LIB_BookCategory, LIB_Publisher and LIB_Book). If you recall from the
introduction, the Book entity had a 1:N relation with authors and categories and a 1:1 relation with publishers. We'll now add those relations to the LIB_Book Object Model. We'll begin with the 1:1 relation with publishers. Open the LIB_Book Object Model and add another attribute of type "Object"