<< Click to Display Table of Contents >> Create Script Data Set |
![]() ![]() ![]() |
1) Click the quick start shortcut of Yonghong Z-Suite.
2) Open the browser and enter http://hostname:8080/bi/Viewer in the address bar to log in to the client. The hostname here refers to the IP address of your PC. For local visit, you can use localhost. 8080 is the default port number. If the default port number is changed during installation, type in the correct port number.
3) Enter username and password and then log in the homepage.
4) Click "Create Data Set" to enter the page for creating a data set.Click on the "Script Data Set" option on the page to open the Script Data Set interface.
5) On the data set page, click "New" on the menu bar and select "Script Data Set" to open Script Data Set page.
❖Example of Script Data Set
The tables in database can be related to each other by primary keys. The primary key is a column in which the value of each line is unique. The value of each primary key is unique in the table. The goal is to cross bind the data across tables without repeating all the data in each table.
There are two SQL data sets on the data set list: Persons and Orders.
The following table lists the data in the data set named Persons.
Id_P |
LastName |
FirstName |
Adress |
City |
---|---|---|---|---|
1 |
Adams |
John |
Oxford Street |
London |
2 |
Bush |
George |
Fifth Avenue |
New York |
3 |
Carter |
Thomas |
Changan Street |
Beijing |
Note that the "Id_P" column is the primary key in the data set named Persons. This means that no two lines can have the same Id_P. Even though two persons have the same name, they can be distinguished through Id_P.
The following table lists the data in data set named Orders .
Id_O |
OrderNo |
Id_P |
---|---|---|
1 |
77895 |
3 |
2 |
44678 |
3 |
3 |
22456 |
1 |
4 |
24562 |
1 |
5 |
34764 |
65 |
Note that the "Id_O" column is the primary key in the data set named Orders. The "Id_P" column in the Orders table is used to reference the persons in the data set named Persons without using their names. The "Id_P" column connect the two data sets.
Write the script query statements to realize the join relationship of over two data sets.
var lt = execute(this, SQL, "Persons");
var rt = execute(this, SQL, "Orders");
var lkeys = [0];
var rkeys = [2];
var lcols = [0, 1,2];
var rcols = [1];
join(this, FINAL_JOIN | LEFT_MAIN, LEFT_JOIN, lt, rt, lkeys, rkeys, lcols, rcols);
The previous statements join the data set named Persons and data set named Orders together over Id_P. The Persons data set is the primary, and the 0, 1st, and 2nd columns of the data set named Persons as well as the 1st column of the data set named Orders are reserved.
The join results are as follows.
Id_P |
LastName |
FirstName |
OrderNo |
---|---|---|---|
1 |
Adams |
John |
22456 |
1 |
Adams |
John |
24562 |
3 |
Carter |
Thomas |
77895 |
3 |
Carter |
Thomas |
44678 |
2 |
Bush |
George |
33656 |