AnyLogic
Expand
Font size

Database view

Database view is the result set of a query on the data stored in database table(s). Unlike ordinary base tables in a relational database, a view is a virtual table computed or collated dynamically from data in the database when access to that view is requested. Changes applied to the data in a relevant underlying table are reflected in the data shown in subsequent invocations of the view.

Views can provide advantages over tables:

  • Views can represent a subset of the data contained in a table.
  • Views can join and simplify multiple tables into a single virtual table.

Views take very little space to store; the database contains only the definition of a view, not a copy of all the data that it presents.

You can manipulate nested views, since one view can aggregate data from other views.

The rows of a view are not ordered. View is a relational table, and therefore represents just a set of rows. ORDER BY condition in the view definition is meaningless. However, you can obtain sorted data from a view, just as you do with any other table — as part of a query statement on that view.

AnyLogic database views

AnyLogic provides users with a set of predefined database views, logs collected during the model execution.

You can also create your own database view based on your own database tables, or raw data tables.

To create a new database view

  1. In the Projects view, right-click the  Database item, and choose New > Database view from the popup menu.
  2. You will see the New Database View dialog box.
  3. Specify the name of the view in the View name field.
  4. Select the tables you want to include in this database view.
  5. Click OK when finished.

  6. You will see the database view editor in the center of the workspace showing the view contents.

  7. In the Projects tree, the new view will be put in the model’s Database branch.
  8. In the Properties, you will see the view properties (see the description below). You can modify the view by editing the SQL query of this view in the View definition field.

Properties

General

Name — The name of the database view.

I do not need this type of log — [Visible if this view is an AnyLogic log] If selected, the data for this log is not collected.

Create an editable copy of this view — [Visible if this view is an AnyLogic log] Click this label to create a copy of this non-editable view and modify it according to your needs (by editing the SQL query in the View definition field).

View definition — [Visible if the DB view is user-created] SQL query that produces this view. You can edit this query to modify the view.

Columns — [Visible if the DB view is user-created] The non-editable list of view columns (it is formed by the view’s SQL query). You can see the Column name and Type for each column of this view.

How can we improve this article?