简体   繁体   English

在 SQL Server 上继承 MS SQL

[英]Inheritance MS SQL on SQL Server

I have this diagram:我有这个图:

图表[1]

Where both Professional and Patient inherit from the table user. Professional 和 Patient 都继承自表用户。

The user id id a PK.用户 ID 是一个 PK。 Professional.id and Patient.id are primary keys of their tables. Professional.id 和 Patient.id 是它们表的主键。 They're also FK that reference user.id.他们也是引用 user.id 的 FK。

The question here is why when I do select * from Professional I don't get the inerited column from the table User?.这里的问题是为什么当我从 Professional 中选择 * 时,我没有从表 User? 中获得 inerited 列。

I know I can join them but I thought the concept of inheritance was supposed to share the fiels from the table User in this case to the tables Professional and Patient.我知道我可以加入他们,但我认为继承的概念应该在这种情况下将表 User 中的字段共享到表 Professional 和 Patient。

To answer your question - SQL Server is not an OODBMS.回答您的问题 - SQL Server 不是 OODBMS。 Though you logically have defined a type of inheritance, the engine does not provide any direct support for including the inherited attributes in the child "class".尽管您在逻辑上定义了一种继承类型,但引擎不提供任何直接支持将继承的属性包含在子“类”中。 The query "select * from table" will only include columns from the specified table.查询“select * from table”将只包含指定表中的列。 You the developer must write your queries to select the tables and columns your statement needs.的开发人员必须编写查询来选择表和列的声明需求。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM