I am implemented a simple project management application. Each project has various events, and each event can be a different type. Some event information is common, such as name, start date, close date, and comments. I have a projects table which has_many events. My plan is to have several sub-event tables, like event_get_access which will contain an event_id field to link it to table events as well as information specific to a "get access" event (remote access, username, passwords, etc). Another event type might be "upgrade" which stores information about the server to be upgraded, etc. So I have: * a project which has_many events * events which belongs_to :project * sub-events which belong_to :event How do the subevents relate to event? An event will never have more than one subevent, but it may not have any of a particular subevent. Thanks for your help on this? -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Sampath Munasinghe
2010-Aug-19 17:57 UTC
Re: implementing project management and event types
May be my On Fri, Aug 20, 2010 at 12:52 AM, richardsugg <richardsugg-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I am implemented a simple project management application. Each > project has various events, and each event can be a different type. > Some event information is common, such as name, start date, close > date, and comments. I have a projects table which has_many events. > My plan is to have several sub-event tables, like event_get_access > which will contain an event_id field to link it to table events as > well as information specific to a "get access" event (remote access, > username, passwords, etc). Another event type might be "upgrade" > which stores information about the server to be upgraded, etc. > > So I have: > * a project which has_many events > * events which belongs_to :project > * sub-events which belong_to :event > > How do the subevents relate to event? An event will never have more > than one subevent, but it may not have any of a particular subevent. > > Thanks for your help on this? > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > . > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Sampath Munasinghe
2010-Aug-19 18:00 UTC
Re: implementing project management and event types
may be my option wrong. if I do your project i will do this. * a project which has_many events * events which belongs_to :project event has_one sub_event option II * a project which has_many events * events which belongs_to :project sub_event has column "sub_event_id". it just refer the sub_event table On Fri, Aug 20, 2010 at 12:57 AM, Sampath Munasinghe <sampathnisha-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> May be my > > > On Fri, Aug 20, 2010 at 12:52 AM, richardsugg <richardsugg-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>wrote: > >> I am implemented a simple project management application. Each >> project has various events, and each event can be a different type. >> Some event information is common, such as name, start date, close >> date, and comments. I have a projects table which has_many events. >> My plan is to have several sub-event tables, like event_get_access >> which will contain an event_id field to link it to table events as >> well as information specific to a "get access" event (remote access, >> username, passwords, etc). Another event type might be "upgrade" >> which stores information about the server to be upgraded, etc. >> >> So I have: >> * a project which has_many events >> * events which belongs_to :project >> * sub-events which belong_to :event >> >> How do the subevents relate to event? An event will never have more >> than one subevent, but it may not have any of a particular subevent. >> >> Thanks for your help on this? >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Ruby on Rails: Talk" group. >> To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> To unsubscribe from this group, send email to >> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> >> . >> For more options, visit this group at >> http://groups.google.com/group/rubyonrails-talk?hl=en. >> >> >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 19 August 2010 18:52, richardsugg <richardsugg-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I am implemented a simple project management application. Each > project has various events, and each event can be a different type. > Some event information is common, such as name, start date, close > date, and comments. I have a projects table which has_many events. > My plan is to have several sub-event tables, like event_get_access > which will contain an event_id field to link it to table events as > well as information specific to a "get access" event (remote access, > username, passwords, etc). Another event type might be "upgrade" > which stores information about the server to be upgraded, etc. > > So I have: > * a project which has_many events > * events which belongs_to :project > * sub-events which belong_to :event > > How do the subevents relate to event? An event will never have more > than one subevent, but it may not have any of a particular subevent.Have you looked at Single Table Inheritance, which would allow multiple types of event all in one table (rather than have subevents of different types)? Otherwise I think you could have Event has_one :sub_event_type_one has_one :sub_event_type_two and so on. Then SubEventTypeOne belongs_to :event etc. It does not matter if a particular event does not have a particular type of subevent, if you try to access event.sub_event_type_one and it does not have one then you will get nil Colin -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Sorry for the delay -- I forgot to subscribe to the thread and didn''t realize I had responses until I checked manually. I thought about STI, but it seems that I would have a very complex table. I did not realize, however, that I could include a bunch of has_one statements -- I assumed that since an event would have a particular subevent based on the event_type, that the has_one wouldn''t work. Since it will (just have to check for nil and know which event_type I''m working with), I think your second opinion would work. Thanks! On Aug 19, 3:49 pm, Colin Law <clan...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> On 19 August 2010 18:52, richardsugg <richards...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > > > > > > I am implemented a simple project management application. Each > > project has various events, and each event can be a different type. > > Some event information is common, such as name, start date, close > > date, and comments. I have a projects table which has_many events. > > My plan is to have several sub-event tables, like event_get_access > > which will contain an event_id field to link it to table events as > > well as information specific to a "get access" event (remote access, > > username, passwords, etc). Another event type might be "upgrade" > > which stores information about the server to be upgraded, etc. > > > So I have: > > * a project which has_many events > > * events which belongs_to :project > > * sub-events which belong_to :event > > > How do the subevents relate to event? An event will never have more > > than one subevent, but it may not have any of a particular subevent. > > Have you looked at Single Table Inheritance, which would allow > multiple types of event all in one table (rather than have subevents > of different types)? > > Otherwise I think you could have > Event > has_one :sub_event_type_one > has_one :sub_event_type_two > and so on. > > Then > SubEventTypeOne > belongs_to :event > etc. > > It does not matter if a particular event does not have a particular > type of subevent, if you try to access event.sub_event_type_one and it > does not have one then you will get nil > > Colin-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.