0% found this document useful (0 votes)
24 views18 pages

3.3x-Modeling Data Exercise

Uploaded by

talitakum.coffee
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views18 pages

3.3x-Modeling Data Exercise

Uploaded by

talitakum.coffee
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 18

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

Create the Movie and Person Entities 4

Create the MovieGenre and PersonRole Static Entities 13

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​.

1) Create the ​Movie E


​ ntity in the OSMDb_Core module, with the following attributes: T​ itle
(Text and mandatory),​ ​Year ​(Integer and mandatory),​ ​PlotSummary ​(Text, with max. length
of 500 characters),​ ​GrossTakingsAmount (​ Currency) and ​IsAvailableOnDVD ​(Boolean). The
Entity should be P
​ ublic ​and ​Exposed with write permissions​.

a) Click the Data tab in the upper right corner of the workspace, to switch to the
Data elements.

b) In the elements area, right-click the E


​ ntities ​folder and select ​Add Entity.

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.

h) Enter T​ itle ​for the ​Name o


​ f the attribute. Notice that the errors disappear.

i) Change the I​ s Mandatory​ property to ​Yes.

j) 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​.

l) Right-click the Movie Entity and select A


​ dd Entity Attribute​.

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

2) Create a new ​Person E


​ ntity to save all the people involved in the movies of our
application. The Entity has the following attributes: N
​ ame ​(Text and mandatory), S
​ urname
(Text and mandatory), D
​ ateOfBirth ​(Date and mandatory) and ​DateOfDeath ​(Date). Set the
Entity to ​Public a
​ nd​ exposed with write permissions​. Also, change the p
​ lural label​ of
the Entity to ​People​.

a) On the Data tab, create a new ​Entity ​and set its name to P
​ erson.

b) In the properties editor at the bottom right, change the P


​ ublic ​property to ​Yes
and the E
​ xpose Read Only​ to N
​ o.

c) Add the following attributes to the Entity: N


​ ame​, ​Surname​, ​DateOfBirth, a
​ nd
DateOfDeath.​ Did Service Studio guess the Data Types correctly from the attribute
name?​ Always double-check!

d) Make Name, Surname,​ ​and DateOfBirth ​mandatory​.

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.

a) Right-click the Movie Entity, select A


​ dvanced​, and then the option​ ​Create Action
to Bootstrap Data from Excel…

b) Browse to the Resources folder and select the M


​ ovies.xlsx​ Excel file.

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.

1) Create the ​MovieGenre S


​ tatic Entity to save the different genres of a movie. Add a new
attribute for the minimum age for that genre of movies: M
​ inimumAge ​(Integer). Add four
records to the Entity: ​Comedy​, ​Action​, ​Drama ​and ​Horror​. Set the appropriate minimum
age for each record (6, 12, 16 and 18) and make the Entity ​public​.

a) Switch to the Data tab in Service Studio.

b) In the elements area, right-click the E


​ ntities ​folder and select ​Add Static Entity​.

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​.

f) Right-click the MovieGenre Entity and select​ ​Add Entity Attribute​.

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​.

h) Right-click the MovieGenre Static Entity and select A


​ dd Record​.
i) Enter C
​ omedy ​for the identifier of the Record. In the properties editor, set the
value 6 in the ​MinimumAge a ​ ttribute this Record.

j) Add 3 more Records: ​Action​, ​Drama ​and H


​ orror​. Set these Records’ ​MinimumAge
to ​12​, ​16 ​and ​18​, respectively.

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

2) Create the ​PersonRole S


​ tatic Entity, to represent the different roles a person can have in
a movie. These roles can be: D​ irector​, ​Producer​, ​Actor a
​ nd ​Crew​. Make the Entity p
​ ublic​.
a) Create a new Static Entity and set its N
​ ame ​to P
​ ersonRole​.
b) In the properties at the bottom right, change the ​Public​ property to Y
​ es​.
c) Add four Records to the Static Entity: ​Director​, P
​ roducer​, ​Actor a
​ nd C
​ rew​.
d) The Static Entity should look like this

e) Click the ​1-Click Publish ​button to publish the module.

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.

g) After a few seconds, right-click on the ​Movie o


​ r ​Person E
​ ntity, select V
​ iew Data​,
and make sure that the data is previewed properly.

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

You might also like