数据库设计帮助。多对多创建关联表,对吗?
我正在为我的应用程序设计一个非常简单的数据库,其配置如下:
Employee
Carnet
Name
LastName
Area
Name
Document
ID
Employee (FK)
Project (FK)
Project
ID
Company (FK)
Title
Company
Name
CEO (FK)
NIT
Person
Carnet
Name
Lastname
现在这个问题的要点是,一个区域可以有许多文档;并且一个文档可以属于多个区域。
据我所知,这创建了第三个关系表,对吗?
如果我要使用 Linq-to-SQL 作为访问数据库的唯一工具,该表中会包含什么内容,这是否能够工作。
I'm designing a very simple database for my application and it's configured like this:
Employee
Carnet
Name
LastName
Area
Name
Document
ID
Employee (FK)
Project (FK)
Project
ID
Company (FK)
Title
Company
Name
CEO (FK)
NIT
Person
Carnet
Name
Lastname
Now the gist of this question is, an Area can have many Document; and a Document can belong to many Area.
This I'm told, creates a third relationship table, correct?
What would go in that table and would this be able to work if I'm going to be using Linq-to-SQL as the only tool for accessing my database.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的...您将有一个名为 AreaDocuments 的表,其中包含名为 AreaID 和 DocumentId 的列。这种关系是 M x N,其中 M 个实例可以关联到 N 个实例,反之亦然。
示例数据:
如何在代码中处理它:
此链接 如何使用 Linq to Sql 实现多对多关系? 可以提供有关在 LINQ to 中使用这种关系的更多信息SQL。
Yes... You'd have a table called AreaDocuments with columns called AreaID and DocumentId. This kind of relationship is M x N where M instances can be associated to N instances and vice-versa.
Sample data:
How to handle it in code:
This link How to implement a many-to-many relationship using Linq to Sql? can provide more information about using this kind of relationship in LINQ to SQL.