0

in 'many' table: what's difference 'required' vs 'composition'?

In my fairly long experience, every RDBMS's implementation of relationality has been a little different, so it's not a big deal to me that Ninox's approach is a bit different. But as a new Ninox-er, I am not sure I understand these terms: 'Required' and 'Composition'.

For example, I have a two-table database. Tables are Firms and Employees. Of course, an employee must be linked to a firm. A firm record, on the other hand, may be created (at least initially) without any linked employees.

So, over in the table reference definition for the link from the employee record to the firm record: It's my understanding that the 'Composition' setting (with its options Yes or No) basically answers the question, "If the parent of this record is deleted, should this child record be deleted too?" Please correct me if I'm wrong about that. And it was explained to me that this is to prevent the creation of orphans.

So what's the point in this case of the 'Required' setting? Or rather, if I select "Yes" for 'Composition', shouldn't Required automatically be set to "Yes" as well? Are there any circumstances in which it should be possible to create an employee record that is NOT linked to a firm record?

Now, I can think of one possible answer to my question, and that's when records are created by import. In that situation — especially if the records are coming from another database and you intend to link them in a moment to their parents but of course haven't done that yet — I can see that it might make sense to allow the Firm reference to remain empty. Is that it? Or is there some other reason?

 

4replies Oldest first
  • Oldest first
  • Newest first
  • Active threads
  • Popular
    • Fred
    • Fred
    • 1 mth ago
    • Reported - view

    I would view them as separate things.

    Composition just tells Ninox that a table is a child of another. That is all. You can create a record in the child table and not have it linked to anything.

    That is where the Required comes in. If you do create a child record in the child table then it will force you to pick a record in the Parent table.

    Like 1
    • WILLIAM PORTER
    • Independent Developer
    • WILLIAM_PORTER
    • 1 mth ago
    • Reported - view

    Thanks, Fred. But the composition option does ensure that children are deleted when the parent record is deleted, is that not correct? I picked that idea up from somewhere. I can't remember where. If it's wrong I'd like to know.

    Like
    • Fred
    • Fred
    • 1 mth ago
    • Reported - view

    You are correct. Once a table is made a child (composition = yes), if the parent record is deleted all child records will be as well.

    Like
    • WILLIAM PORTER
    • Independent Developer
    • WILLIAM_PORTER
    • 1 mth ago
    • Reported - view

    Thanks for confirming. I think that's an excellent feature. Thanks again for your earlier answer.

    Like
Like Follow
  • 1 mth agoLast active
  • 4Replies
  • 27Views
  • 2 Following