设计数据库,以N层应用程序中使用 [英] Designing a database to be used in N-Tier application

查看:137
本文介绍了设计数据库,以N层应用程序中使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用.NET的N层应用程序(C#,SQL服务器)。我一开始是因为我相信从底部开始将是一个好主意设计数据库。现在我需要在构建数据库您的建议非常灵活。了解该应用程序的目的是建成一个组插件。

I am working on an N-tier application using .NET (C#, SQL Server). I started by designing the database because I believe starting from bottom would a good idea. Now I need your suggestions in building the database to be very flexible. Knowing that the application is intended to built as a group of plug-ins.

该应用程序是为许多不同的硬件设备(汽车,发动机等)
这里是数据库表的一个片段一个遥控器应用程序。

The application is a remote control app for many different hardware devices (Cars, Engines, etc) Here is a fragment of the database tables.


  1. 设备表

  2. 人员表

  3. 用户表

  4. 角色表

  1. Devices Table
  2. Personnel Table
  3. Users Table
  4. Roles Table

正如你所看到的设备表就是代表我们所控制的设备表和因为每个每个设备可以具有比其他欲每个设备链接到其属性可能是在方法的另一个表尽可能优雅或多或少性质。人事表是负责例如该设备的人。汽车司机(有可能是每辆车多个驱动程序),引擎运营商等。

As you can see the devices table is a table to represent the devices we are controlling and since each each device may have more or less properties than others I want to link each device to its properties which might be in another table in way that is as elegant as possible. The personnel table is for the people responsible for the device for example: Car drivers (there might be more than one driver for each car), Engine operator, etc.

用户是应用程序的用户,你可以看到我已经分居了用户和角色分成两个不同的表。

Users are the application users as you can see I have separated the users and roles into two different tables.

我在找的是将设备链接到其属性的一种方式。加,在应用的每个装置是附着设备的一个实例。这意味着我可以附加一个称为设备说:SIM卡到一个名为车载设备。此外,还有关于这方面的任何设计模式?

What I am looking for is a way to link the devices to their properties. Plus, In the application each device is an instance of an attachable device. Meaning that I can attach a device called say: SIM card to a device called Vehicle. Moreover, are there any design patterns regarding this subject?

在此先感谢,并请原谅我,如果我不明确。

Thanks in advance, and please pardon me if I am not clear.

推荐答案

根据您将如何被处理您的数据的层这个数据库的设计可能是一个争论的焦点。如果你使用的EntityFramework一个代码第一种方法,你可以使用创建的逻辑实体,并生成从模型数据库。

Depending on how you are going to be handling your data layer this database design may be a moot point. If you were to use EntityFramework with a code first approach you can create your logical entities using that and generate the database from your models.

大多数ORM基础的解决方案提供了一些方法来创建你的对象关系数据库,但虽然可以快速,方便地获得数据库启动并运行,这将你到底需要什么,如果你想开始你可能会碰到麻烦的模式打球,虽然你可以做的相当很多的推断,以帮助它做幕后的数据库,你想要的方式。

Most ORM based solutions provide some way to create a database from your objects relationship, but although you can quickly and easily get a database up and running which will do EXACTLY what you NEED, if you want to start playing with the schema you may run into troubles, although you can do quite alot of inferring to help it make the database behind the scenes the way you want it.

如果这是一个新建项目,你不需要适应任何传统的数据库系统我想别担心你的数据库的时刻,只是去写你的逻辑模型,并确定它们之间的关系,并让数据存储的担忧处理自己。

If this is a greenfield project and you dont need to accommodate any legacy database system I would stop worrying about your database for the moment and just get to writing your logical models and defining their relationships, and let the data storage concerns handle themselves.

这篇关于设计数据库,以N层应用程序中使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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