-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Multiple Many-to-Many relationships between two tables #14802
Comments
Hey @IvanDrag0, Can you provide all the information from the bug template? This information is important whenever we try to replicate what's happening on your end. The bug template is attached below. I haven't been able to replicate this on latest but I've only tried with a MySQL database. Checklist
Hosting
Describe the bug To Reproduce
Expected behavior Screenshots App Export Desktop (please complete the following information):
Additional context |
Hi @ConorWebb96, Sure thing! Hosting
Describe the bug To Reproduce Steps to reproduce the behavior:
Theoretically, after selecting the "Tasks" table again, the schema should look like this: The only issue is that a join/through table should have the two values as primary keys instead of having a separate ID key. However, Budibase does not allow the user to specify two columns as primary keys. App Export MTMDemo-export-1729614491668.tar.gz Desktop (please complete the following information):
Hope this helps! |
@ConorWebb96 I just realized that I've submitted another issue that has to do with Many-to-Many relationships (#14800) and these reproduction steps apply to the other one. To make them apply to this issue as well, do the following (each task can have multiple assignees and approvers, and the same in reverse where a person can be assigned and the approver for multiple tasks):
When trying to do the same for "Assignees", you get the following error: |
Oh, I think I understand what's happening now. Thank you for all the additional information. This is currently a limitation within Budibase. The screenshots you have shown tell you exactly what is happening here. You can probably avoid this by restructuring your database. For example, you could use a single join table and just add an ENUM (select) for choosing the user's role. CREATE TYPE role_type AS ENUM ('Assignee', 'Approver');
CREATE TABLE Tasks (
TaskId SERIAL PRIMARY KEY,
TaskName VARCHAR(255) NOT NULL,
Description TEXT,
CreatedAt TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
CREATE TABLE People (
PersonId SERIAL PRIMARY KEY,
FirstName VARCHAR(100) NOT NULL,
LastName VARCHAR(100) NOT NULL,
Role role_type NOT NULL
);
CREATE TABLE TaskPeople (
TaskId INT REFERENCES Tasks(TaskId) ON DELETE CASCADE,
PersonId INT REFERENCES People(PersonId) ON DELETE CASCADE,
PRIMARY KEY (TaskId, PersonId)
); I'm going to change this from bug to enhancement. Thanks for writing this up. I hope the above table is helpful for you. |
@ConorWebb96 Thank you for the suggestion! How would Budibase handle that setup? Can it work with custom times/enums?
Is this true for this issue as well as #14800?( |
Fixed in version 3.0.4 |
I'm not sure if this is a bug or this has not been implemented. When trying to setup a second many-to-many relationship between two tables (with different join tables), I get an error that a relationship between the two tables already exists. As long as I'm using different join tables, I should be able to create more than one many-to-many relationship between two tables.
The text was updated successfully, but these errors were encountered: