BrainGrid Controller
Window creation
Foreign Key Relations

Foreign Key Relations

This documentation describes how users can view and manage windows with foreign key relations, including viewing related windows, switching between child tabs and sidebar views, and performing CRUD operations on foreign keys.

Viewing Windows with Foreign Key Relations

Viewing Related Windows

Users can view windows that have foreign key relations.

Example:

Given a user named "John Doe" with a window named "Student Window" and related windows "Student History" and "Student Attendance":

  • Action: John Doe views the "Student Window."
  • Result: John Doe sees "Student History" and "Student Attendance" as related windows.

Viewing Related Windows as Child Tabs

Users can choose to view related windows as child tabs within a parent window.

Example:

Given a user named "John Doe" with a window named "Student Window" and related windows "Student History" and "Student Attendance":

  • Action: John Doe chooses the option to view related windows as child tabs.
  • Result: "Student History" and "Student Attendance" appear as child tabs inside the "Student Window."

Viewing Related Windows as Regular Windows in the Sidebar

Users can choose to view related windows as regular windows in the sidebar.

Example:

Given a user named "John Doe" with a window named "Student Window" and related windows "Student History" and "Student Attendance":

  • Action: John Doe chooses the option to view related windows as regular windows in the sidebar.
  • Result: "Student History" and "Student Attendance" appear as regular windows in the sidebar.

Switching Between Child Tabs and Sidebar Views

Users can switch between viewing related windows as child tabs or regular windows in the sidebar.

Example:

Given a user named "John Doe" with a window named "Student Window" and related windows "Student History" and "Student Attendance":

  • Action: John Doe switches from viewing related windows as child tabs to regular windows in the sidebar.

  • Result: "Student History" and "Student Attendance" are moved to the sidebar as regular windows.

  • Action: John Doe switches from viewing related windows as regular windows in the sidebar to child tabs.

  • Result: "Student History" and "Student Attendance" appear as child tabs inside the "Student Window."

Viewing Foreign Keys and Related Windows

Viewing All Foreign Keys

Users can view all foreign keys used in the system.

Example:

Given a user named "John Doe" and the system has foreign keys "user_id" and "task_id":

  • Action: John Doe navigates to the foreign keys section.
  • Result: John Doe sees a list of all foreign keys including "user_id" and "task_id."

Viewing Windows Related to a Specific Foreign Key

Users can view windows related to a specific foreign key.

Example:

Given a user named "John Doe" and the system has windows "User Profile," "Task Assignment," and "Project Management":

  • Action: John Doe selects the foreign key "user_id."

  • Result: John Doe sees a list of windows using "user_id" including "User Profile" and "Task Assignment."

  • Action: John Doe selects the foreign key "task_id."

  • Result: John Doe sees a list of windows using "task_id" including "Task Assignment" and "Project Management."

Viewing Columns with Foreign Key Relations in a Window

Users can view columns with foreign key relations in a window.

Example:

Given a user named "John Doe" and the system has a window "Task Assignment" with columns "task_id," "user_id," and "task_description":

  • Action: John Doe views the "Task Assignment" window.
  • Result: John Doe sees that "task_id" and "user_id" columns have foreign key relations.

Searching for Windows by Foreign Key

Users can search for windows by foreign key.

Example:

Given a user named "John Doe" and the system has foreign keys "user_id" and "task_id" and windows "User Profile," "Task Assignment," and "Project Management":

  • Action: John Doe searches for windows using the foreign key "user_id."

  • Result: John Doe sees search results including "User Profile" and "Task Assignment."

  • Action: John Doe searches for windows using the foreign key "task_id."

  • Result: John Doe sees search results including "Task Assignment" and "Project Management."

Creating Foreign Key from Any Window and Field

Creating a Foreign Key from a Single Field

Users can create a foreign key from a single field in a window.

Example:

Given a user named "John Doe" with a window named "User Window" with fields "user_id," "name," and "dob":

  • Action: John Doe selects the field "user_id" to create a foreign key and names it "user_id_fk."
  • Result: "user_id_fk" is created as a foreign key and is available for use across the system.

Viewing Created Foreign Keys

Users can view the created foreign keys in the system.

Example:

Given a user named "John Doe" who has created foreign keys "user_id_fk" and "user_id_dob_fk":

  • Action: John Doe navigates to the foreign keys section.
  • Result: John Doe sees "user_id_fk" and "user_id_dob_fk" listed.

Using a Created Foreign Key in Another Window

Users can use a created foreign key in another window.

Example:

Given a user named "John Doe" with a window named "Task Assignment" with fields "task_id," "user_id_fk," and "task_description" and "user_id_fk" is a foreign key created from "User Window":

  • Action: John Doe assigns a task to a user by entering "user_id_fk" in the "Task Assignment" window.
  • Result: "user_id_fk" correctly references the "user_id" in the "User Window."

Managing Foreign Keys

Editing an Existing Foreign Key

Users can edit an existing foreign key.

Example:

Given a user named "John Doe" with a foreign key named "user_id_fk" created from the "User Window" field "user_id":

  • Action: John Doe edits the foreign key "user_id_fk" to rename it to "user_fk."
  • Result: "user_fk" is updated in the system and replaces "user_id_fk" in all associated windows and relations.

Deleting an Existing Foreign Key

Users can delete an existing foreign key.

Example:

Given a user named "John Doe" with a foreign key named "user_fk":

  • Action: John Doe deletes the foreign key "user_fk."
  • Result: "user_fk" is removed from the system and all references to "user_fk" are removed or updated in associated windows and relations.

Restoring a Deleted Foreign Key

Users can restore a deleted foreign key.

Example:

Given a user named "John Doe" who has deleted a foreign key named "user_fk":

  • Action: John Doe restores the foreign key "user_fk."
  • Result: "user_fk" is restored in the system and is available for use in associated windows and relations.