AppSheet and Relational Databases... Hi, I w...

AppSheet and Relational Databasesโ€ฆ

Hi, I was searching AppSheet documentation to try to understand how exactly AppSheet translates some terms from relational databasesโ€ฆ

I meanโ€ฆ AppSheet documentation is about references, parent and child tablesโ€ฆ

While in Relational Databases lingo usually we talk about Keys and Foreign Keys, and One-to-One, One-to-Many, Many-to-Many relationships between tables.

I gather for example that the โ€œRef - Is Part ofโ€ creates a One-To-Many relationship?

And the โ€œRefโ€ without being โ€œA Part ofโ€ creates a One-to-One relationship?

0 10 2,793
10 REPLIES 10

Ref column is equivalent to โ€œForeign Keyโ€, regardless of the type of relationship being one-to-one or one-to-many, and โ€œAs part ofโ€ adds ability to add rows in โ€œmanyโ€ table in the same form that you are adding row to โ€œoneโ€ table, so you can save them at once; otherwise without that option, you need to first add a record on the โ€œoneโ€ side and save, prior to adding rows to โ€œmanyโ€ side. In addition, โ€œAs part ofโ€ will enforce โ€œcascade deleteโ€ too.

@RezaRaoofi thanks. What about MANY-TO-MANY relationships?

On a well designed relational database you should not have many-to-many relationship; each many-to-many relationship should be broken into 2 one-to-many relationships; this is totally a design matter and independent from platform whether it is AppSheet, or not.

Yes, I suppose so. But I thought any many-to-many relationship was always done with a intermediary A-B B-A table.

It would be interesting if you added more info on how to do that (inside appsheet) on your help docs, as well as maybe a App Example with such Many-To-Many relational database, using of course, the intermediary

table.

Yes, you are right, that was what I meant by breaking it into 2 one-to-many. Assuming entity A and entity B have many-to-many relationship, you will add a third intermediary table which has one-to-many relationship with each A and B tables, then on the AppSheet side you will add 2 Ref columns in that table, one refers to table A, and one refers to table B.

AppSheet has actually provided a pretty decent article about data modeling; check it out: https://help.appsheet.com/data/data-the-essentials

Thanks, but that leaves some gaps between how Many-to-Many work and AppSheet inner workings.

For exampleโ€ฆ a junction table has 2 many-to-one relationships.

However, AppSheet only allow ONE Ref-IsAPartOf column per table.

Also, in AppSheet, from where do you set each of the โ€œone-to-manyโ€ relationships?

I have a Risks table. Each Risk has a one-to-many relationship to the Analysis table.

Now, I want each analysis to be able to have different Action Plans. Again a one-to-many relationship.

However, there is also the Year Objectives table. This table can have several Action Plans. (One-to-Many).

Some of these Action Plans will also be used by the Analysys table. Some wonยดt.

Suppose I am at Risk Analysis table, and I create a new Action Plan.

I am taken to the Action Plan form. Where do I link this Action Plan to the Year Objectives table?

Well, I do not exactly know all relationships you mentioned above; your last message kind of sounded like you were thinking out loud and each paragraph was a new thought coming to your mind

As I told you before, in the intermediary table you will have Ref columns referring to one side of the relationship, so the table containing the Ref column is the โ€œmanyโ€ side.

Regarding Is part of you are right, there is a limit, and only one table can have it.

Yeah, I guess it was somewhat like thinking out loud lol.

Let me try to rephrase.

I create table A, which has a 1-Many relationship with table B, which has a Many-to-1 relationship to C.

From TableA form, I can create a new item at B.

It will open Table B Form view, where the Ref column will be already

โ€œfilledโ€ by the link to Table A.

Is that correct?

Ok. But how do I connect table B to table C?

Does it creates a dropdown list at TableB Form, where I can choose between ALL records from Table C?

What if Table C has a thousand records, and worse, some are equal, since Table C itself is a Many-to-One table to Table D?

(The Label canยดt be the Key, so you use the Foreign Key as Label. But Foreign Keys repeat in a One-To-Many)

Anyway, seems like ideal situation would be to enter TableA Form, create new item at TableB but leave empty the relation to Table C.

Then at Table C Form, we should somehow choose that same Table B record already linked to Table A, thus linking C to B, which was already connected to A.

But that seems impossible, as from Table C, the inline table to B will look empty and your only option is to create a NEW record at B, linking B to C, but not being able to connect it to A!!!

Errrโ€ฆ I guess this answer was still too long and complicated

Just so you know, I am just a community moderator and I donโ€™t work in AppSheet support. I will read your above message, and get back to you later.

Just one thing I missed out in my last answer was that whatever you check as Label in column structure of referrenced table, that column will be displayed in the Ref columnโ€™s drop-down list.

Top Labels in this Space