哪个是我的导航的最好的数据库模式? [英] Which is the best database schema for my navigation?

查看:289
本文介绍了哪个是我的导航的最好的数据库模式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个网站,所有网页都悬挂在数据库驱动的树层次结构之上。

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).

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

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

页面呈现HTML内容或执行编程。某些网页可能是子树的根(备用母版和样式表)。

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

请帮助我在Microsoft SQL Server中设置我的节点数据库,供Linq to SQL使用。

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

我有三个想法:


  1. b $ b零nullalbe字段。

  1. Many lightweight tables with almost zero nullalbe fields.

#1许多具有几乎为零nullalbe字段的轻量级表格http://img126.imageshack.us/img126/2016/scan1ro8.gif

具有大量
nullalbe字段的重量级节点表。

Heavyweight Node table with lots of nullalbe fields.

#2具有大量nullalbe字段的重量级节点表http://img124.imageshack.us/img124/9909/scan2xm2.gif

最好的(或最坏的):许多
nullalbe外键给许多
轻量表。

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

a href =http://img124.imageshack.us/img124/1999/scan3wn8.gif =nofollow noreferrer>#3许多nullalbe外键对许多轻量级表http://img124.imageshack.us/ img124 / 1999 / scan3wn8.gif

#3 Lots of nullalbe foreign keys to many lightweight tables http://img124.imageshack.us/img124/1999/scan3wn8.gif

您觉得最适合代表哪些资料?哪个是最容易使用Linq到SQL的?

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.

页面必须是html或代码(但不能同时包含)。

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

链接可能不是根,html或代码。

Links may not be roots, html, nor code.

我可以创建一个ASP.NET网站地图提供程序这样的结构?我应该吗?

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

更新:我问过一个更一般的问题:

Update: I've asked a more general question:

在SQL中处理一对一关系的最佳方式是什么? a>

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

相关问题:

如何在数据库中强制执行数据完整性规则?

推荐答案

我同意在设计Linq时考虑的是低音ackwards。 Joe Celko的书SQL中的树和层次结构对于模式有许多好的想法代表你想要做什么。 Linq应该能够处理这些很好。

I agree that designing with Linq in mind is bass-ackwards. Joe Celko's book "Trees and Hierarchies in SQL For Smarties" has many good ideas for schemas to represent what you're trying to do. Linq ought to be able to deal with these just fine.

这篇关于哪个是我的导航的最好的数据库模式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆