salk31 / RedQueryBuilder

SQL Query Builder UI JavaScript component
http://redquerybuilder.appspot.com/
Eclipse Public License 1.0
96 stars 22 forks source link

Using the adjacency list model (recursive single table) results in error #34

Open Hoffmania opened 9 years ago

Hoffmania commented 9 years ago

The issue is a self referencing schema such as employee has a supervisor that is an employee. This is tracked with a FK of supervisor_id in the employees table. The FKS is described below:

"fks": [
{
  "referencedTableName": "employees",
  "name": "supervisor_id_fks",
  "label": "Supervisor",
  "foreignKeyNames": [
    "supervisor_id"
  ],
  "referencedKeyNames": [
    "id"
  ],
  "reverseLabel": "Subordinate"
}

Once deployed, the FKS association and the reverse are available in the select options, however, these items are not selectable.

The ideal case would be to limit this to one level as to get only the immediate supervisor or list of immediate subordinates.

salk31 commented 9 years ago

Ideas: 1) Allow self reference levels n=2 CON - what if via another table CON - seems very limited CON - not easy to implement

2) Support a config defined alias (that counts as a different table) PRO - fits the use case where want to give the other table a special name PRO - could be step towards user defined aliases

3) Allow the user to define and extra alias plus provide via config CON - confuse the user? PRO - want to support this in longer run. CON - lot of code?

4) Allow the user to define and API for pre-loaded alias PRO - want to support in longer run

Hoffmania commented 9 years ago

Option 2 or 3 seems the best for me.