用 SQL 建模本体图:两个父亲的问题
我正在 SQL 中使用树来建模本体来指示概念之间的关系。 我的问题是如何在不复制概念的情况下消除图形/树中概念的歧义。
例如。我有课程的概念:“空手道”、“帆船”(可以从教练那里学习的课程)和可以学习这些课程的地方:“健身房”、“划船俱乐部”。在图中它将是:
健身房 游船俱乐部
有 有
课程
空手道 帆船
我如何对该图进行建模,以避免船舶俱乐部开设空手道课程,并且不重复课程的概念?
谢谢!
I'm modelling an ontology in SQL using a tree to indicate relations between concepts.
My problem is how to disambiguate concepts in a graph/tree without replicating concepts.
Eg. I have the concept of courses: "karate", "sailing" (lessons one can take from instructors) and places: "gym", "boat club" where these courses can be taken. In the graph it will be:
gym boat club
has has
courses
of of
karate sailing
How can I model this graph to avoid boat club having karate courses and without duplicating the concept of courses?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我会翻转整个数据架构并将其视为一个图表。为所有概念(节点)(健身房、划船俱乐部、课程、空手道、帆船)准备一张表格,并用另一张表格来创建它们之间的链接(顶点)。该表看起来像这样:
可能需要更多的 SQL 才能在内存中构建所有信息,但此模式将简单地处理这些关系。
I would turn the whole data architecture around and think about this as a graph. Have a table for all the concepts (nodes) - gym, boat club, courses, karate, sailing - and another table to create the links (vertices) between them. That table looks something like:
It may take a lot more SQL to build up all your information in memory, but this schema will handle these relationships simply.
包含数据 Karate 和 Sailing 的表将包含其他两个表的主键作为外键。这将允许您拥有任意数量的每种数据类型,同时仍然能够遍历表以获取信息。
The table that contains the data Karate and Sailing would contain the primary keys for the other two tables as foreign keys. This would allow for you to have as many of each data type as you like while still being able to traverse the tables to get your information.