3.3x-Modeling Data Exercise
3.3x-Modeling Data Exercise
OutSystems Inc. 5
901 Peachtree Dunwoody Road, N.E. Building C, Suite 495, Atlanta, GA 30328 1
Table of Contents
Table of Contents 2
Introduction 3
End of Lab 18
OutSystems Inc. 5
901 Peachtree Dunwoody Road, N.E. Building C, Suite 495, Atlanta, GA 30328 2
Introduction
In this exercise lab, we already have the OSMDb application created, so we will start to
progressively build our app, by creating the data model.
The data model of this application will exclusively be created on the OSMDb_Core module, and
will consist at this stage on two Entities, Movie and Person, and on two Static Entities,
MovieGenre and PersonRole.
These Entities will represent the movies (Movie) in the database and their genres (MovieGenre),
as well as the cast and crew (People) and their role in the movies (PersonRole).
At the end of the Lab, we should have our data model looking like this
OutSystems Inc. 5
901 Peachtree Dunwoody Road, N.E. Building C, Suite 495, Atlanta, GA 30328 3
Create the Movie and Person Entities
In this section, we will create the initial Entities of the application: Movie a
nd Person. An Entity
in OutSystems requires a Name, an Id (identifier) attribute and at least one other attribute.
Entities can be initialized with data from an Excel spreadsheet. This process is called
Bootstrapping.
Since our application will have two modules, and the UI module will reference these Entities,
they will be defined as Public.
a) Click the Data tab in the upper right corner of the workspace, to switch to the
Data elements.
c) Type M
ovie f or the Name of the Entity.
OutSystems Inc. 5
901 Peachtree Dunwoody Road, N.E. Building C, Suite 495, Atlanta, GA 30328 4
d) Expand the Movie Entity. There is an auto-number I d attribute and six Entity
Actions to provide typical Create, Read, Update and Delete (CRUD) functionality.
NOTE: Notice that the Entity is underlined in red and that the TrueChange t ab
has a r ed X, meaning that the module has an error. Entities cannot be made up of
a single Auto-Numbered attribute.
e) Since we will be using this Entity on our UI module, in the properties editor at the
bottom right, change the Public p
roperty to Yes.
f) Still in the properties of the Entity, set the Expose Readonly to No, to make the
Entity exposed with write permissions.
OutSystems Inc. 5
901 Peachtree Dunwoody Road, N.E. Building C, Suite 495, Atlanta, GA 30328 5
g) Right-click the Movie Entity and select A
dd Entity Attribute.
k) Enter Y
ear for the Name of the attribute. Notice the default Data Type is I nteger.
Make this attribute Mandatory.
m) Enter P
lotSummary for the Name o
f the attribute. Notice the default D
ata Type is
Text w
ith a Length of 50 characters. Change it to 500.
OutSystems Inc. 5
901 Peachtree Dunwoody Road, N.E. Building C, Suite 495, Atlanta, GA 30328 6
n) Add 2 more attributes: G
rossTakingsAmount and IsAvailableOnDVD. Notice the
default Data Types are correctly set to Currency a
nd Boolean.
NOTE: OutSystems infers the data type of an attribute or variable from their
name. Since GrossTakinsAmount h
as Amount i n the name, OutSystems
automatically infers it to be a Currency a
ttribute. The same with IsAvailableOnDVD
being Boolean, since the attribute’s name starts with I s.
o) Select the GrossTakingsAmount attribute and change its Label property to Gross
Takings. This will shorten the default label used in OutSystems, when generating
UI, as we will see in a later Lab.
OutSystems Inc. 5
901 Peachtree Dunwoody Road, N.E. Building C, Suite 495, Atlanta, GA 30328 7
p) The Movie Entity should look like this
a) On the Data tab, create a new Entity and set its name to P
erson.
OutSystems Inc. 5
901 Peachtree Dunwoody Road, N.E. Building C, Suite 495, Atlanta, GA 30328 8
e) The Person Entity should look like this
f) Select the Person Entity and in the properties editor, double-click the M
ore…
property to launch the Entity Editor.
g) In the Entity Editor dialog, expand the More Options s ection and change the
Label (plural) property to People and click the Close b
utton.
OutSystems Inc. 5
901 Peachtree Dunwoody Road, N.E. Building C, Suite 495, Atlanta, GA 30328 9
NOTE: The Entity Editor allows us to configure more advanced settings relating to
your Entity, including the Labels which are used for the UI defaults while building
the Screens.
Here, we are simply setting the correct plural for the Entity name P
erson, which
unlike most English words, it is not simply a matter of adding an ‘s’ at the end.
This will be used whenever Service Studio needs to suggest the default name of
any module element, or operation, that involves multiple instances of Person. It
will also save manual adjustments later, if we want to keep grammar correctness.
3) Bootstrap s ome seed data for the two newly created Entities, from two Excel files. To do
that, we will use the M
ovies.xlsx and People.xlsx respectively, available in the
Resources folder.
OutSystems Inc. 5
901 Peachtree Dunwoody Road, N.E. Building C, Suite 495, Atlanta, GA 30328 10
c) In the “Create Action to Bootstrap Data from Excel” window, ensure that the
column headers names from the Movies.xlsx excel file (Excel Columns) match
the names of the Movie Entity attributes (‘Movie Attributes’). If so, click on the
Proceed button. Otherwise, click on the Cancel button and fix the names, or data
types, of the mismatched Movie Entity attributes. Then, redo the third step again.
Your Entity attributes m
ust match in name and type what is in the Excel file.
NOTE: Stars will appear in the interface when the previous step is completed. The
stars indicate the areas where elements are being created.
The logic for fetching the data from the Excel file and add it to the database is
created in the Action B
ootstrapMovies, under the Logic tab. It checks if any
Movies currently exist. If not, it imports the Movies from the Excel spreadsheet
and creates a Movie in the database, for each row in the spreadsheet. The Excel
file will be saved inside the module, in the Resources folder under the Data tab.
This Action runs when the module is published.
OutSystems Inc. 5
901 Peachtree Dunwoody Road, N.E. Building C, Suite 495, Atlanta, GA 30328 11
d) Follow the same process for the Person Entity, choosing the People.xlsx Excel
file. Don’t forget to verify that the values in E
xcel Columns match the values in
‘Person’ Attributes before you click Proceed.
OutSystems Inc. 5
901 Peachtree Dunwoody Road, N.E. Building C, Suite 495, Atlanta, GA 30328 12
Create the MovieGenre and PersonRole Static Entities
After creating the Entities, we will create two Static Entities: M
ovieGenre and PersonRole. A
Static Entity is initially created with a few attributes: Label, Order a
nd I s_Active, but other
attributes can be added.
Unlike regular Entities, the Static Entity data is defined and initialized at design time. Each of the
possible values of a Static Entity is called a Record.
c) Enter M
ovieGenre for the Name o
f the Static Entity.
OutSystems Inc. 5
901 Peachtree Dunwoody Road, N.E. Building C, Suite 495, Atlanta, GA 30328 13
d) Expand the MovieGenre E
ntity by clicking on the expand symbol.
NOTE: Notice that the Static Entity only has one Entity Action: Get<StaticEntity>.
Since it is not possible to dynamically create or update the Static Entity records in
runtime, the Create and Delete Actions are not available.
e) Since we will be using this Static Entity on our UI module, change its P
ublic
property to Yes.
OutSystems Inc. 5
901 Peachtree Dunwoody Road, N.E. Building C, Suite 495, Atlanta, GA 30328 14
g) Set its N
ame t o MinimumAge and change the Data Type to Integer.
OutSystems Inc. 5
901 Peachtree Dunwoody Road, N.E. Building C, Suite 495, Atlanta, GA 30328 15
k) The Static Entity should look like this
OutSystems Inc. 5
901 Peachtree Dunwoody Road, N.E. Building C, Suite 495, Atlanta, GA 30328 16
f) Make sure the module was published successfully, with a message indicating that
the OSMDb module is outdated. This will be addressed in the next Lab.
OutSystems Inc. 5
901 Peachtree Dunwoody Road, N.E. Building C, Suite 495, Atlanta, GA 30328 17
End of Lab
In this exercise, we created an initial data model for the movie database traditional web
application, in its Core module. The main application concepts are M
ovie and Person (member
of a movie’s cast and crew). These concepts were represented as Entities, which will correspond
to a table in the database.
In preparation for more advanced modeling of these Entities and their relationships, we also
created two Static Entities: M
ovieGenre and PersonRole. The Static Entities can only be
changed at design time.
The application module was then published to the server, thus creating the appropriate
database tables for these Entities. We will start visualizing these Entities, and their data, in the
next lab.
OutSystems Inc. 5
901 Peachtree Dunwoody Road, N.E. Building C, Suite 495, Atlanta, GA 30328 18