Dan
Dan

Reputation: 724

Handling tables of different types in ASP.NET MVC

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:

Events
* 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?

Upvotes: 2

Views: 326

Answers (1)

Robert Harvey
Robert Harvey

Reputation: 180788

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

Upvotes: 1

Related Questions