如何在关系数据库中进行继承建模?

时间:2022-02-28 16:58:02

My question is regarding Inheritance modeling in Relational Database Systems. I have canonical data model and in that I have some fields related to pricing of product inheriting certain attributes from product table and I want to model this inheritance in MySQL relational database and so,

我的问题是关于关系数据库系统中的继承建模。我有规范的数据模型我有一些与产品定价相关的领域从产品表中继承某些属性我想在MySQL关系数据库中建模这个继承,

"How can we do Inheritance Modeling in Relational Databases ?"

“我们如何在关系数据库中进行继承建模?”

Thanks.

谢谢。

5 个解决方案

#1


29  

Martin Fowler discusses this extensively in his book Patterns of Enterprise Application Architecture book. Get this book and look into:

Martin Fowler在他的《企业应用程序体系结构模式》一书中详细讨论了这一点。看看这本书:

  1. Single Table Inheritance
  2. 单表继承
  3. Class Table Inheritance
  4. 类表继承
  5. Concrete Table Inheritance
  6. 具体表继承

The Website should give you some idea. You might also want to read the section on inheritance mappers. Each of the different approaches have their pros and cons so choose wisely.

这个网站应该会给你一些建议。您可能还想阅读关于继承映射器的一节。每种方法都有各自的优缺点,所以要明智地选择。

#2


9  

Look at these articles for some ideas:

看看这些文章,寻找一些想法:

Mapping Objects to Relational Databases

将对象映射到关系数据库

Inheritance in O/R Mapping

继承在O / R映射

#3


3  

Relational databases don't deal with objects (and, thus, inheritance) - they deal with relationships. What you're really asking is how to map your object structure to your database - and the answer to that is "it depends on your ORM layer".

关系数据库不处理对象(以及继承)——它们处理关系。您真正要问的是如何将对象结构映射到数据库中——答案是“它取决于ORM层”。

Take a look at Mapping Objects to Relational Databases: O/R Mapping In Detail article for some details. If you tell us what software stack you're using, you'll likely get a more to-the-point answer.

查看对象到关系数据库的映射:O/R映射的详细信息。如果您告诉我们您正在使用什么软件堆栈,您很可能会得到更直接的答案。

#4


2  

If you just want to look at some web articles instead of reading a book, you can find some good articles by Googling on:

如果你只是想看一些网络文章而不是阅读一本书,你可以通过谷歌搜索找到一些好的文章:

Generalization Specialization Relational Modeling

The gen-spec pattern covers a lot of the same ground that inheritance does in OOP environments.

gen-spec模式涵盖了与OOP环境中的继承相同的许多方面。

If you google on

如果你谷歌

Generalization Specialization Object Modeling

you'll get a whole new batch of articles, most of which mention inheritance explicitly.

您将获得一组全新的文章,其中大部分都明确地提到了继承。

There is a design technique that's summarized in the following tag under the info tag. This allows you to use subclass tables to "extend" a class table, if you'll allow a strange use of the word "extend". There's some work involved, but it's worth it.

有一种设计技术,在下面的标签类表继承信息标签下总结。这允许您使用子类表“扩展”一个类表,如果您允许使用“extend”这个词的奇怪用法。这里面有一些工作,但值得去做。

#5


1  

Chapter 6 of "Practical Issues in Database Management" is probably an interesting read for you.

“数据库管理中的实际问题”的第6章可能是您感兴趣的读物。

As are all the other chapters, probably, but those don't relate directly to your question.

和所有其他章节一样,可能,但这些都与你的问题没有直接联系。

#1


29  

Martin Fowler discusses this extensively in his book Patterns of Enterprise Application Architecture book. Get this book and look into:

Martin Fowler在他的《企业应用程序体系结构模式》一书中详细讨论了这一点。看看这本书:

  1. Single Table Inheritance
  2. 单表继承
  3. Class Table Inheritance
  4. 类表继承
  5. Concrete Table Inheritance
  6. 具体表继承

The Website should give you some idea. You might also want to read the section on inheritance mappers. Each of the different approaches have their pros and cons so choose wisely.

这个网站应该会给你一些建议。您可能还想阅读关于继承映射器的一节。每种方法都有各自的优缺点,所以要明智地选择。

#2


9  

Look at these articles for some ideas:

看看这些文章,寻找一些想法:

Mapping Objects to Relational Databases

将对象映射到关系数据库

Inheritance in O/R Mapping

继承在O / R映射

#3


3  

Relational databases don't deal with objects (and, thus, inheritance) - they deal with relationships. What you're really asking is how to map your object structure to your database - and the answer to that is "it depends on your ORM layer".

关系数据库不处理对象(以及继承)——它们处理关系。您真正要问的是如何将对象结构映射到数据库中——答案是“它取决于ORM层”。

Take a look at Mapping Objects to Relational Databases: O/R Mapping In Detail article for some details. If you tell us what software stack you're using, you'll likely get a more to-the-point answer.

查看对象到关系数据库的映射:O/R映射的详细信息。如果您告诉我们您正在使用什么软件堆栈,您很可能会得到更直接的答案。

#4


2  

If you just want to look at some web articles instead of reading a book, you can find some good articles by Googling on:

如果你只是想看一些网络文章而不是阅读一本书,你可以通过谷歌搜索找到一些好的文章:

Generalization Specialization Relational Modeling

The gen-spec pattern covers a lot of the same ground that inheritance does in OOP environments.

gen-spec模式涵盖了与OOP环境中的继承相同的许多方面。

If you google on

如果你谷歌

Generalization Specialization Object Modeling

you'll get a whole new batch of articles, most of which mention inheritance explicitly.

您将获得一组全新的文章,其中大部分都明确地提到了继承。

There is a design technique that's summarized in the following tag under the info tag. This allows you to use subclass tables to "extend" a class table, if you'll allow a strange use of the word "extend". There's some work involved, but it's worth it.

有一种设计技术,在下面的标签类表继承信息标签下总结。这允许您使用子类表“扩展”一个类表,如果您允许使用“extend”这个词的奇怪用法。这里面有一些工作,但值得去做。

#5


1  

Chapter 6 of "Practical Issues in Database Management" is probably an interesting read for you.

“数据库管理中的实际问题”的第6章可能是您感兴趣的读物。

As are all the other chapters, probably, but those don't relate directly to your question.

和所有其他章节一样,可能,但这些都与你的问题没有直接联系。