我通过这种方式实现了SQL表继承:
Table Shape:
Column | Type
------------+---------
shape_id | integer
square | foat
name | character varying(64)
Table Triangle
Column | Type
------------+---------
shape_id | integer
a | float
b | float
c | float
Foreign-key constraints:
"fkey1" FOREIGN KEY (shape_id) REFERENCES Shape(shape_id)
Table Circle
Column | Type
------------+---------
shape_id | integer
r | float
Foreign-key constraints:
"fkey2" FOREIGN KEY (shape_id) REFERENCES Shape(shape_id)
Run Code Online (Sandbox Code Playgroud)
用光滑的方法可以创建三角扩展形状而圆扩展形状的类模型吗?
我看到了这个问题,但我不喜欢将所有派生表列都放在一个表中为可为空的方法。
谢谢!