哪个是我导航的最佳数据库架构?

Which is the best database schema for my navigation?(哪个是我导航的最佳数据库架构?)
本文介绍了哪个是我导航的最佳数据库架构?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

我正在创建一个网站,其中所有页面都挂在数据库驱动的树状层次结构上.

除一个节点外,所有节点都有一个父节点.节点可能具有基于角色的读取权限.某些节点可能有特殊规则(例如:不在导航菜单中显示).

节点可能代表到其他节点的链接(如 Windows 中的快捷方式).节点通常代表页面.

页面显示 HTML 内容或

<小时>

相关问题:
如何在我的数据库中执行数据完整性规则?

解决方案

阅读您的帖子后,我的第一印象是我非常反对让任何一项技术(在这种情况下为 linq)大量使用在您似乎建议的范围内影响数据库架构设计.

我认为您的架构应该几乎相同,无论您选择何种技术来构建业务/表示层.

希望我没有误会你.

I'm creating a web site where all pages hang off a database-driven tree-hierarchy.

All but one node has a parent node. Nodes may have role-based read permissions. Some nodes may have special rules (such as: don't display within navigation menus).

Nodes may represent links to other nodes (like a shortcut in Windows). Nodes typically represent pages.

Pages present either HTML content or execute programming. Some pages may be roots of subtrees (alternate masterpages and stylesheets).

Please help me setup my nodes database in Microsoft SQL Server for use by Linq to SQL.

I've got three ideas:

  1. Many lightweight tables with almost zero nullalbe fields.

  2. Heavyweight Node table with lots of nullalbe fields.

  3. Best (or worst) of both: Lots of nullalbe foreign keys to many lightweight tables.

Which do you feel best represents the data? Which will be easiest to use with Linq to SQL?

How can I keep my data integrity rules within the database? How do I best enforce them within my programming?

  • Nodes must be either (but not both) links or pages.

  • Pages must be either (but not both) html or code.

  • Links may not be roots, html, nor code.

Can I make an ASP.NET Site Map Provider with such a structure? Should I?


Update: I've asked a more general question:

What’s the best way to handle one-to-one relationships in SQL?


Related question:
How do I enforce data integrity rules in my database?

解决方案

My initial impression after reading your post is that I would be very averse to let any one technology (in this case linq) heavily influence the database schema design to the extent you seem to be suggesting.

I think your schema should be pretty much the same, regardless of what technology you then chose to build your business/presentation layers.

I hope I haven't misunderstood you.

这篇关于哪个是我导航的最佳数据库架构?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

相关文档推荐

Is Unpivot (Not Pivot) functionality available in Linq to SQL? How?(Linq to SQL 中是否提供 Unpivot(非 Pivot)功能?如何?)
How to know if a field is numeric in Linq To SQL(如何在 Linq To SQL 中知道字段是否为数字)
Linq2SQl eager load with multiple DataLoadOptions(具有多个 DataLoadOptions 的 Linq2SQl 急切加载)
Extract sql query from LINQ expressions(从 LINQ 表达式中提取 sql 查询)
LINQ Where in collection clause(LINQ Where in collection 子句)
Orderby() not ordering numbers correctly c#(Orderby() 没有正确排序数字 c#)