# Set a table as loosely coupled table

Check if there are loosely coupled tables in the app by using the [GetLooselyCoupledVector method](https://help.qlik.com/en-US/sense-developer/November2024/Subsystems/EngineJSONAPI/Content/service-doc-getlooselycoupledvector.htm).

Set a table as loose using the [SetLooselyCoupledVector method](https://help.qlik.com/en-US/sense-developer/November2024/Subsystems/EngineJSONAPI/Content/service-doc-setlooselycoupledvector.htm).

Information noteIf the vector contains values set to 1 or 2, it means that there are loosely coupled tables in the app.

Information noteThe last three values in the vector are extra values. These values are for internal use.

Information noteIn case of circular references, the engine automatically creates loosely coupled tables so that the circular references do not create a loop.

## Examples

Example 1:

[](https://help.qlik.com/en-US/sense-developer/Subsystems/EngineAPI/Content/Sense_EngineAPI/CreatingAppLoadingData/ViewDataToLoad/set-table-as-loosely-coupled-table.htm)

#### The goal is to check if there are any loosely coupled tables in the app.

The data model in the app is the following:

![Example map of multiple linked tables, all of which share at least one value with another.](https://help.qlik.com/en-US/sense-developer/November2024/Subsystems/EngineAPI/Content/Resources/Images/ui_gen_ExampleQVCPLooselyCoupledVector.png)

The client sends:

```
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "GetLooselyCoupledVector",
  "handle": 1,
  "params": []
}
```

The engine returns:

```
{
  "jsonrpc": "2.0",
  "id": 1,
  "result": {
    "qv": [
      0,
      0,
      0,
      0,
      0,
      0,
      0,
      0,
      0,
      0
    ]
  }
}
```

There is no loosely-coupled tables.

Example 2:

[](https://help.qlik.com/en-US/sense-developer/Subsystems/EngineAPI/Content/Sense_EngineAPI/CreatingAppLoadingData/ViewDataToLoad/set-table-as-loosely-coupled-table.htm)

#### .

1. Create a folder connection using the [CreateConnection method](https://help.qlik.com/en-US/sense-developer/November2024/Subsystems/EngineJSONAPI/Content/service-doc-createconnection.htm).

The client sends:

```
{
  "jsonrpc": "2.0",
  "id": 5,
  "method": "CreateConnection",
  "handle": 1,
  "params": [
    {
      "qName": "CONNECTION_NAME",
      "qConnectionString": "E:\\\\GIT\\\\engine-sense-fork\\\\prod\\\\data\\\\Engine\\\\test\\\\qlikviewTests\\\\ProtocolTester4Net\\\\TestData\\\\",
      "qType": "folder"
    }
  ]
}
```

The engine returns:

```
{
  "jsonrpc": "2.0",
  "id": 5,
  "result": {
    "qConnectionId": "F2718B64-181760BF-AC07B9FE-32216200-0870C51A"
  }
}
```

The folder connection is created. The identifier of the connection (in qConnectionId) is produced by the engine and is unique.

2. Load the tables CitizenCity, CitizenSchool and SchoolCity into the app using the [SetScript method](https://help.qlik.com/en-US/sense-developer/November2024/Subsystems/EngineJSONAPI/Content/service-doc-setscript.htm).

The client sends:

```
{
  "jsonrpc": "2.0",
  "id": 6,
  "method": "SetScript",
  "handle": 1,
  "params": [
    "LOAD Name, Age, City FROM [lib://CONNECTION_NAME/CircularLoop.xlsx] (ooxml, embedded labels, table is CitizenCity); LOAD Name, School FROM [lib://CONNECTION_NAME/CircularLoop.xlsx] (ooxml, embedded labels, table is CitizenSchool); LOAD School, City FROM [lib://CONNECTION_NAME/CircularLoop.xlsx] (ooxml, embedded labels, table is SchoolCity);"
  ]
}
```

The engine returns:

{ "jsonrpc": "2.0", "id": 6, "result": {}, "change": [ 1 ] }

The script has been updated with the new values. The three tables are created.

3. Reload the app.

The client sends:

{ "jsonrpc": "2.0", "id": 7, "method": "DoReload", "handle": 1, "params": [] }

The engine returns:

{ "jsonrpc": "2.0", "id": 7, "result": { "qReturn": true }, "change": [ 1 ] }

The app is reloaded.

The data model is as follows:

![Example map of three linked tables: CitizenSchool, CitizenCity, and SchoolCity. CitizenSchool and SchoolCity are linked by sharing the School value.](https://help.qlik.com/en-US/sense-developer/November2024/Subsystems/EngineAPI/Content/Resources/Images/ui-gen-circular-loop.png)

4. Check if some tables are loose using the [GetLooselyCoupledVector method](https://help.qlik.com/en-US/sense-developer/November2024/Subsystems/EngineJSONAPI/Content/service-doc-getlooselycoupledvector.htm).

The client sends:

{ "jsonrpc": "2.0", "id": 8, "method": "GetLooselyCoupledVector", "handle": 1, "params": [] }

The engine returns:

{ "jsonrpc": "2.0", "id": 8, "result": { "qv": [ 2, 0, 0, 0, 0, 0 ] } }

The first loaded table (the table CitizenCity) is loose. The associated flag is set to 2.

5. Set loose the table SchoolCity using the script statement Loosen table.

The client sends:

{ "jsonrpc": "2.0", "id": 9, "method": "SetScript", "handle": 1, "params": [ "LOAD Name, Age, City FROM [lib://CONNECTION\_NAME/CircularLoop.xlsx] (ooxml, embedded labels, table is CitizenCity); LOAD Name, School FROM [lib://CONNECTION\_NAME/CircularLoop.xlsx] (ooxml, embedded labels, table is CitizenSchool); LOAD School, City FROM [lib://CONNECTION\_NAME/CircularLoop.xlsx] (ooxml, embedded labels, table is SchoolCity); Loosen table SchoolCity;" ] }

The engine returns:

{ "jsonrpc": "2.0", "id": 9, "result": {}, "change": [ 1 ] }

The table SchoolCity is loose.

6. Reload the app.

The client sends:

{ "jsonrpc": "2.0", "id": 10, "method": "DoReload", "handle": 1, "params": [] }

The engine returns:

{ "jsonrpc": "2.0", "id": 10, "result": { "qReturn": true }, "change": [ 1 ] }

The app is reloaded.

The data model is as follows:

![Example map of three linked tables: CitizenSchool, CitizenCity, and SchoolCity. CitizenSchool and CitizenCity are linked by sharing the Name value.](https://help.qlik.com/en-US/sense-developer/November2024/Subsystems/EngineAPI/Content/Resources/Images/ui-gen-circular-loop2.png)

7. Check that the third table is loose using the [GetLooselyCoupledVector method](https://help.qlik.com/en-US/sense-developer/November2024/Subsystems/EngineJSONAPI/Content/service-doc-getlooselycoupledvector.htm).

The client sends:

{ "jsonrpc": "2.0", "id": 11, "method": "GetLooselyCoupledVector", "handle": 1, "params": [] }

The engine returns:

{ "jsonrpc": "2.0", "id": 11, "result": { "qv": [ 0, 0, 2, 0, 0, 0 ] } }

The third loaded table (the table SchoolCity) is loose. The associated flag is set to 2. The table CitizenCity is no longer loose.

8. Set loose the table CitizenSchool (with flag 1) using the [SetLooselyCoupledVector method](https://help.qlik.com/en-US/sense-developer/November2024/Subsystems/EngineJSONAPI/Content/service-doc-setlooselycoupledvector.htm). CitizenSchool is the second loaded table.

The client sends:

{ "jsonrpc": "2.0", "id": 12, "method": "SetLooselyCoupledVector", "handle": 1, "params": [ [ 0, 1, 2, 0, 0, 0 ] ] }

The engine returns:

{ "jsonrpc": "2.0", "id": 12, "result": { "qReturn": true }, "change": [ 1 ] }

The tables CitizenSchool and SchoolCity are loose.

9. Check that the tables CitizenSchool and SchoolCity are loose, using the [GetLooselyCoupledVector method](https://help.qlik.com/en-US/sense-developer/November2024/Subsystems/EngineJSONAPI/Content/service-doc-getlooselycoupledvector.htm).

The client sends:

{ "jsonrpc": "2.0", "id": 13, "method": "GetLooselyCoupledVector", "handle": 1, "params": [] }

The engine returns:

{ "jsonrpc": "2.0", "id": 13, "result": { "qv": [ 0, 1, 2, 0, 0, 0 ] } }

The table CitizenSchool is loose (flag set to 1) and the table SchoolCity is always loose (flag set 2).

10. Set loose the table CitizenCity (with flag 1) using the [SetLooselyCoupledVector method](https://help.qlik.com/en-US/sense-developer/November2024/Subsystems/EngineJSONAPI/Content/service-doc-setlooselycoupledvector.htm). CitizenCity is the first loaded table. The table CitizenSchool should not be loose any longer (flag set to 0).

The client sends:

{ "jsonrpc": "2.0", "id": 14, "method": "SetLooselyCoupledVector", "handle": 1, "params": [ [ 1, 0, 2, 0, 0, 0 ] ] }

The engine returns:

{ "jsonrpc": "2.0", "id": 14, "result": { "qReturn": true }, "change": [ 1 ] }

The tables CitizenCity and SchoolCity are loose.

11. Check that the tables CitizenCity and SchoolCity are loose, using the [GetLooselyCoupledVector method](https://help.qlik.com/en-US/sense-developer/November2024/Subsystems/EngineJSONAPI/Content/service-doc-getlooselycoupledvector.htm).

The client sends:

{ "jsonrpc": "2.0", "id": 15, "method": "GetLooselyCoupledVector", "handle": 1, "params": [] }

The engine returns:

{ "jsonrpc": "2.0", "id": 15, "result": { "qv": [ 1, 0, 2, 0, 0, 0 ] } }

The table CitizenCity is loose (flag set to 1) and the table SchoolCity is always loose (flag set 2). The table CitizenSchool is no longer loose.

12. Check that the table SchoolCity cannot be unloose.

The client sends:

{ "jsonrpc": "2.0", "id": 16, "method": "SetLooselyCoupledVector", "handle": 1, "params": [ [ 0, 0, 0, 0, 0, 0 ] ] }

The engine returns:

{ "jsonrpc": "2.0", "id": 16, "result": { "qReturn": false }, "change": [ 1 ] }

The table SchoolCity could not be unloose because it has 2 as flag.