Forum Academy Marketplace Showcase Pricing Features

How to create a table column that can allow values from 2 different tables

Scenario:
table name: Competetion

  1. The competetion can happen between 2 players or 2 teams.
    so if I have to define the competition table with “Self” and “oponent” columns that will allow values from “players table” or “teams table”, how could I implement that ?

New to bubble and also databases, so bit stuggling with this db design or logic… Please advise

There are 2 ways u can go about it from my experience.

Easiest being to create a new Thing in your database that links to both tables.

For example u can call the new Thing “Match” with fields from both Player and Team tables. Then create a new workflow to create a new Match. You can trigger that workflow however matches the user experience (press of a button or scheduled in the backend if u are familiar with it). You can add other fields related to a “Match” if u want to.

The second, but a bit more complicated, will be a workflow to generate a new state with a list of texts (this will be ur Data Source in your repeating group) that will each contain the UIDs of both Player and Team tables involved in a match that u can use ‘:split by’ and use ‘Search for’ matches to display the right Thing in your repeating group cells.

Though I’d recommend the first. Creating a new Thing for matches. U can do alot more with it.

Hope i helped abit!