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

Generate CRUD Endpoints

With Twidget, you can efficiently generate CRUD (Create, Read, Update, Delete) endpoints for your database tables upon their creation. This functionality is designed to streamline the development process and ensure that essential API operations are readily available. Enabling CRUD Endpoints. 1. Crea...

Database Storage

Managing your database storage effectively is crucial for ensuring optimal performance and cost-efficiency when using Twidget. Each entry within your database table utilizes a certain amount of storage space. Twidget provides intuitive tools to help you monitor and manage this storage. Viewing Datab...

Export Data from Tables

Twidget allows you to export data from your database tables to a CSV file. This feature supports the export of both complete and filtered datasets. Here’s how you can utilize this functionality: Features. - Format: Export data in CSV format. - Data Handling: Object and list data types within your ta...

Authentication Table

An authentication table is a crucial component in Twidget that is used to store all necessary authentication information, essential for authenticating requests. Overview. - Purpose: To store authentication details such as email, password, token signature, and reset key. - Recommendation: It's recomm...

Database Tables

Database tables are essential components of your Twidget workspace, serving as the primary storage locations for your data. In Twidget, each table consists of rows and fields, meticulously designed for efficient data management and retrieval. Structure of Database Tables. - Rows: Each row in a datab...