Is it possible/advisable to emulate subclasses (like in C# or python) using partitioned tables in Base?
One table would have the common fields for the parent class and main key and other tables would have the specific fields for each subclass.
For example with items for sale:
Parent table Items has unique ID, Name, Price, Author
Subtable Book has unique ID, Pages, Type
Subtable Sculpture has ID, Weight, Style, Material
Subtable DVD has ID, Length, Content
The IDs in the subtables would be linked to the parent table.
Certainly!
Most likely solution (I guess):
- An “item class” field in the main table governs which subtable you will link to.
- The primary key is also the “Parent” field in each subtable, linking to the parent item.
- This makes it a 1-1 relationship. Each main entry can only have 1 entry in each subtable. However, additional mechanisms are required to limit the connection to use only the relevant subtable.
There are ways to enforce the constraint using helper tables and relationships with defined conditions. For personal use I guess it is just as well to trust manual procedures or enforce by automated enabling of subforms.
Note the advice in @Ratslinger’s answer!
It is important to focus on the database basics. Tools available in Base do not solve much if you don’t have a sound database structure in place.
If you want to make something for other people to use and develop further, normalization is important. In your case, transactions may also be important. Both subjects are reachable from the Ralational database link in that answer.