Multiple tables in Orchid resource #2269
-
I have a main products table:
And an additional table for each product type. For example, belts:
The reason for this approach is that I want to make sure each product has a unique code. I'm aware that I could achieve this with a single table but then I would have to make mandatory columns (such as the dimensions column) nullable. Plus I would have to amend the table schema each time a new product type is added. I have set up the Product model as follows:
And the Belt model as follows:
I have created an Orchid belt resource as follows:
This gives me the following new belt form: When I try to create a belt I get the following error:
I can see why this error is occurring but I'm not sure how best to address it. I'd be grateful for any pointers. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Answering (kind of) this myself in case others have the same question. What I was trying to achieve is Multi-Table Inheritance (MTI). After researching the topic I realised I would be better off using Single-Table Inheritance (STI) instead. That was much easier to achieve and resulted in a simpler database schema. |
Beta Was this translation helpful? Give feedback.
Answering (kind of) this myself in case others have the same question.
What I was trying to achieve is Multi-Table Inheritance (MTI). After researching the topic I realised I would be better off using Single-Table Inheritance (STI) instead. That was much easier to achieve and resulted in a simpler database schema.