How to present a hierarchy of classification of objects in a DBMS

My IF data will be represented by objects, it will look like this:

abstract class A{
   int a;
   int b;
   string c;
}

class B inherits A{
  string D;
}

class C inherits A{
  int e;
  int f;
}

My question is: do I create a separate table for objects B and C, Or do I create one main table, and for each type of entity I do different joins to extract the data.
In the real world, I will have about 15 similar fields for all objects and about 1-3 unique fields for each object.
I expect a maximum of 100 thousand records.

Any ideas?

+1
source share
2 answers

. , ( ) .

, . "" , , . , , , , . , - ...

tableA
(
    ID (primary),
    A,
    B,
    C
)

tableB
(
    ID (primary and foreign->table_A),
    D
)

tableC
(
    ID (primary and foreign->table_A),
    E,
    F
)
+4

table_a , table_B table_c

table_A
   PKa
   a int
   b int
   c string


table_B
  PKb
  FKa
  D string


table_C
  PKc
  FKa
  e int
  f int
+3

Source: https://habr.com/ru/post/1708520/


All Articles