开发者

Handling tables of different types in ASP.NET MVC

开发者 https://www.devze.com 2022-12-18 07:41 出处:网络
I am designing a database for an ASP.NET MVC application.I\'m an expert in neither, and I\'m curious what the best approach would be for the following database snippet:

I am designing a database for an ASP.NET MVC application. I'm an expert in neither, and I'm curious what the best approach would be for the following database snippet:

We will be storing Events in our database. Each event will be of a different type with various fields exclusive to one or some of the types. An example:

开发者_StackOverflowEvents
* Id
* EventTypeId
* AllEventTypes_Field

EventType0
* EventId (FK)
* EventType0_Field

EventType1
* EventId (FK)
* EventType1_Field

We'll have a handful of event types in the end. I am tempted to put all fields into one large Events table, with nullable fields where appropriate. Or, we can separate out the tables into Supertype/Subtype: Events, EventType1, EventType2, etc (As above).

For the database design portion, I want to choose what makes the most sense and is "easiest" for the MVC framework. Essentially: what path will yield the least amount of headaches? :)

For super/sub types, would it be a matter of dragging over the Events table and creating classes for each subtype off of the main Events table?


This Microsoft article discusses optional one-to-one relationships, which is essentially what you are describing:

http://msdn.microsoft.com/en-us/library/dd326769(VS.85).aspx

0

精彩评论

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

关注公众号