Sign Up

Table Relationships

In Twidget, you can connect database table data using the _id field that is automatically generated for every row in a table. This _id field is essential for creating and maintaining relationships across different tables.

Types of Relationships

One-to-One (1:1)

A one-to-one relationship occurs when a single row in Table A is linked to a single row in Table B. Each record in Table A has a direct and unique relationship with a single record in Table B.

For example, consider a Users table and a Profiles table:

  • Each user in the Users table corresponds to a unique profile in the Profiles table.

  • The Profiles table will have a foreign key _user_id that references the _id field in the Users table.

One-to-Many (1:Many)

A one-to-many relationship occurs when a single row in Table A is linked to multiple rows in Table B. Each record in Table A can have multiple related records in Table B, but each record in Table B has only one corresponding record in Table A.

-

For example, consider a Categories table and a Products table:

  • Each category in the Categories table can include multiple products from the Products table.

  • The Products table will have a foreign key _category_id that references the _id field in the Categories table.

Many-to-Many (Many:Many)

A many-to-many relationship occurs when multiple rows in Table A are linked to multiple rows in Table B. Each record in Table A can have many corresponding records in Table B and vice versa.

-

For example, consider a Students table and a Courses table:

  • Each student can enroll in multiple courses.

  • Each course can have multiple students enrolled.

  • This relationship is typically implemented using a junction table, such as an Enrollments table, which contains foreign keys _student_id and _course_id that reference the _id field in the Students and Courses tables, respectively.

Populating Data

When working with functions in Twidget, you can use the _id fields to query related data and populate the complete data set into the main object.

Related Topics

Adding Database Table Rows

In Twidget, you can easily add new entries (rows) to your database tables. This feature allows you to expand your data dynamically without the need for complex coding. This document provides a step-by-step guide on how to add rows to your database tables. Adding a New Entry to a Table. To add a new ...

CSV Import

Twidget enables seamless import of data from a CSV file into your database. Follow the steps below to successfully import a CSV file. Step-by-Step Guide. 1. Initiate the Import: - Click on the Import button within the table toolbar. - Select Import from CSV from the dropdown. 2. Open Import Dialog: ...

Filter Data

In Twidget, you can easily filter and sort data within the database tables view. This allows you to refine and manipulate the data as needed. Below are the steps and options available for filtering and sorting data. Filtering Data. To filter data: 1. Click on the Filter Button: In the table toolbar,...

Table Field Types

Each table column in Twidget has a data type. The available data types are: - Text - Number - Boolean - Date - Object Field Type Adherence. Data added to the table should adhere to the column's field type. When you manually enter data via the web application, the value editor will use the input type...

Database Basics

Twidget offers a comprehensive database solution for all workspaces. Here's an overview of how databases are structured and managed within Twidget: Database Structure. 1. Tables: A database may contain multiple tables. Each table stores data in a structured format. 2. Fields: Tables consist of field...