Tags:
create new tag
, view all tags
-- 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.

Book Category General Properties

Figure ME.1 - Book Category Object Model

Book Category Attribute Name

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.

Adding a 1:1 Relation attribute

We'll begin with the 1:1 relation with publishers. Open the LIB_Book Object Model and add another attribute of type "Object". For the attribute name use "publisher", for the label type "Publisher" and in the description "Book Publisher". You'll notice that Object attributes have a different set of properties from previous attributes created, one of them being the "Type" (highlighted in red in figure ME.2). The type property defines which type of instances (i.e. instances of which Object Model) can relate to instances of the current Object Model; in this situation we want that LIB_Book instances have a relation with LIB_Publisher instances so we'll have to select the LIB_Publisher object model.

The default value for the Type property of an Object attribute is object.boObject. boObject is the super class for all Object Model instances (similar to Object in Java) and you can use it as representation of "any Object Model". The object.ObjectModelName is the syntax used internally but by pressing the "Brower" button (see figure ME.2) you only need to choose from the list of Object Models in your project (Typing Object Model names will narrow the list progressively). Choose "LIB_Publisher" as the type for the publisher attribute.

Book Object Attribute Properties

Figure ME.2 - Editing an attribute of type Object (for the LIB_Book Object Model)

Note: Object attributes can have several more properties which will be discussed later in the documentation (for example, it's possible to declare the following: instances "LIB_Book" have a 1:1 relation, through attribute X, with an instance of Model A, Model B or Model C)

To finalize the LIB_Book Object Model we'll need the 1:N relations (to Categories and Authors) which will be done in the following section.

Adding a 1:N Relation (Collection) attribute

Collection attributes in Object Models represent 1:N relations, which are among the most common in Object Modeling.

a

s

a

Topic attachments
I Attachment Action Size Date Who Comment
PNGpng BookCategoryAttribute.png manage 14.6 K 2010-12-17 - 16:36 PedroRio BookCategory Attribute Name
PNGpng BookCategoryGeneral.png manage 17.4 K 2010-12-17 - 16:36 PedroRio BookCategory General Properties
PNGpng BookObjectAttribute.png manage 29.5 K 2010-12-20 - 09:08 PedroRio Book Object Attribute
PNGpng BookObjectAttributeCollection.png manage 28.2 K 2010-12-20 - 13:54 PedroRio Attribute Object Collection
Edit | Attach | Print version | History: r16 | r6 < r5 < r4 < r3 | Backlinks | Raw View | Raw edit | More topic actions...
Topic revision: r4 - 2010-12-20 - PedroRio
 

No permission to view TWiki.WebTopBar

This site is powered by the TWiki collaboration platform Powered by Perl

No permission to view TWiki.WebBottomBar