递归数据库设计方法

时间:2013-06-17 06:08:30

标签: database

我只是在教自己数据库,而我正试图以关系形式对现有问题进行建模。它有点乱,但简化: 我有一个Foo表,其中包含大量Foos,每个Foo都有一对多链接到BarsBarID。麻烦的是,一个Bar可能还有很多其他Bars的一对多关系,我无法思考如何对此进行建模并避免讨厌的查询。任何建议欢迎。

Foo [ FooID   …   BarID ]

Bar [  BarID   …   OtherBars??]

1 个答案:

答案 0 :(得分:2)

你可以拥有这样的表:

FooMaster[FooId, and other foo cols but no barid]
FooBarRel[Fooid, Barid]
BarMaster[Barid, and other bar details but no barid of other bars]
BarBarRel[Barid, RelBarid]
相关问题