开发者

DB project - improving performance with relationships

I have two tables, let's call them TableA and TableB. One record in TableA is related to one or more in TableB. But there's also one special record within them in TableB for each record from TableA (for example with lowest ID), and I want to have quick access to that special one. Data from both tables aren't deleted - it's a kind of history rarely cleared. How do that the best in terms of performance?

I th开发者_如何学运维ought of:

1) two-way relationship, but it will affect insert performance

2) design next table, with primary key as FK_TableA (for TableA record exactly one is "special") and second column FK_TableB and then create view

3) design next table, with primary key as FK_TableA, FK_TableB, make FK_TableA unique and then create view

I'm open for all other ideas :)


4) I'd consider an indexed view to hide the JOIN and row restriction

This is similar to your options 2 and 3 but the DB engine will maintain it for you. With a new table you'll either compromise data integrity or have to manage the data via triggers

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜