0

So ive linked a database controller in visual studio, and via browser i can create, edit, delete etc.

im in the process of building a ticket website project, and wondering how you would go about creating one event - and then on submit it will automatically create x number of records in a ticket table depending on the ticket capacity set in the event details;

i.e event table eventid 1 - eventname; festival - eventdate; 12/02/2014 - ticketavailable;100

ticket table ticket id 1 - 100; eventname festival.

im using mvc - visual studio 2012 - with sql compact server 4.0

  • Before I answer can I just confirm you want to create an event, an event has 100 places and then you want to know how to structure this? – JEV Mar 18 '14 at 14:39
  • Yeah thats what im going for. to create a event with say 100 places available - then to automatically add 100 places in the ticket table. – user3330281 Mar 18 '14 at 15:43

1 Answers1

0

Well I wouldn't go and create 100 records just because an event allows it. That's not a very good system. I imagine you have users? If so model it so an event has 'Limit' Column on it and event can have many users, for example 100. Then you a User can have many events. And you have a UserEvents Table, which has an UserId and a EventId. This will, for the sake of argument, represent a ticket.

Then whenever you go to display for purchase you only display ones that haven't exceeded their limit, and again do this check when inserting new rows incase data has changed.

In addition if you aren't that keen on SQL, you could always use CodeFirst migrations through Entity Framework and this would be easier for you to setup through a series of models.

The ASP.NET site offers a good tutorial that covers it all if you are interested:

Link to Tutorial

Link to MSDN Example

Entity Framework 6 Tutorial Series

JEV
  • 2,494
  • 4
  • 33
  • 47
  • So for a ticketing system?, would each ticket for an event not be created when the event is created, each with its own unique identifier? – user3330281 Mar 18 '14 at 17:44
  • @user3330281 Yes, but that row would be inside the UserEvents Table. Technically you could do some renaming,but the UserEvents table would have : UserId | EventId -- [This is a Candidate key : assuming they can only have 1 ticket. If not add an Id Column in as well] As well as any extra information a ticket would need. – JEV Mar 19 '14 at 10:33