【发布时间】:2014-03-06 17:09:56
【问题描述】:
我正在尝试创建组件的层次结构,fx。:
CREATE TABLE COMPONENTS(id, name, price, component_type)
CREATE TABLE SUB_COMPONENTS_1(...)
CREATE TABLE SUB_COMPONENTS_2(...)
SUB_COMPONENTS 表在哪里使用超类型的 id 列作为外键,它们会根据它的 component_type 得到“填充”。 (即 component_type 列)
我一直在努力关注: http://bytes.com/topic/sql-server/answers/808389-design-question-type-heirarchy-supertype-queries 但是我无法理解他如何使“vehicle_type”唯一,并能够在车辆表中创建具有相同“vehicle_type”的多个条目?
任何帮助理解这一点,将不胜感激!
更新:
就我而言,没有关系的关系模式是这样的:
组件(component_id:序列号,名称:字符串,类型:字符串,价格:double)
Wheels(wheel_id=component_id, kind: string, price=component_price)
电机(motor_id=component_id, kind: string, price=component_price)
汽车(名称:字符串,total_price,wheels=component_id,motor=component_id....)
【问题讨论】:
-
SUB_COMPONENTS_1 和 SUB_COMPONENTS_2 的架构是什么?
标签: sql sql-server hierarchy