First crack at an app. I have a friend with a private school that I''m trying to create a scheduling system for. So I have Coordinators creating school courses. Once the course is created the coordinator can assign multiple instructors, and then assign students to the course and instructor. So is this right? class Coordinator has_many :courses end class Course belongs_to :coordinator has_many :instructors end class Instructor has_many :courses has_many :students end class Student belongs_to :Instructor end Then the other thing I want to do is set a date and time for each course. So would I create this also: class CourseDate belongs_to :course end class CourseTime belongs_to :coursedate end Thanks in advance, Mark -- 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.
You may want to consider using a :through association. The coordinator may be better defined as a role type. Within a course people have a role: coordinator or student. The relationship between people and the course is through the role. Keeping the role object will indexing on the participants in the course. On Aug 6, 2011, at 1:07 AM, MC wrote:> First crack at an app. I have a friend with a private school that I''m > trying to create a scheduling system for. > > So I have Coordinators creating school courses. Once the course is > created the coordinator can assign multiple instructors, and then > assign students to the course and instructor. So is this right? > > class Coordinator > has_many :courses > end > > class Course > belongs_to :coordinator > has_many :instructors > end > > class Instructor > has_many :courses > has_many :students > end > > class Student > belongs_to :Instructor > end > > > Then the other thing I want to do is set a date and time for each > course. So would I create this also: > > class CourseDate > belongs_to :course > end > > class CourseTime > belongs_to :coursedate > end > > > > Thanks in advance, Mark > > -- > 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. >-- 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.
On Aug 6, 9:07 am, MC <amev...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> First crack at an app. I have a friend with a private school that I''m > trying to create a scheduling system for. > > So I have Coordinators creating school courses. Once the course is > created the coordinator can assign multiple instructors, and then > assign students to the course and instructor. So is this right?Are you even going to need to have students that belong to multiple instructors? Are you going to want to know what course the student is taking ? From the associations you''ve given you don''t seem to be storing that bit of information, the best you could work out is that given their instructor there are only certain courses they could be doing.> > Then the other thing I want to do is set a date and time for each > course. So would I create this also: > > class CourseDate > belongs_to :course > end > > class CourseTime > belongs_to :coursedate > endWithout a full understanding of your problem (perhaps you are managing repeating occurrences of courses etc.) this feels a little overkill to be honest. would date/time columns on your courses table not suffice? Fred> > Thanks in advance, Mark-- 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.
I think having the flexibility of having a student and or instructor assignable to different courses may come in handy. We may want to have records of past course participants. That''s why a through association on a role may work out best. On Aug 6, 2011, at 2:42 AM, Frederick Cheung wrote:> > > On Aug 6, 9:07 am, MC <amev...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> First crack at an app. I have a friend with a private school that I''m >> trying to create a scheduling system for. >> >> So I have Coordinators creating school courses. Once the course is >> created the coordinator can assign multiple instructors, and then >> assign students to the course and instructor. So is this right? > > Are you even going to need to have students that belong to multiple > instructors? Are you going to want to know what course the student is > taking ? From the associations you''ve given you don''t seem to be > storing that bit of information, the best you could work out is that > given their instructor there are only certain courses they could be > doing. > >> >> Then the other thing I want to do is set a date and time for each >> course. So would I create this also: >> >> class CourseDate >> belongs_to :course >> end >> >> class CourseTime >> belongs_to :coursedate >> end > > Without a full understanding of your problem (perhaps you are managing > repeating occurrences of courses etc.) this feels a little overkill to > be honest. would date/time columns on your courses table not suffice? > > Fred >> >> Thanks in advance, Mark > > -- > 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. >-- 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.
Frederick, I would want to be able to see what students are being taught be what instructor. And yes I would want to be able to know what the course the student is taking. So from my current setup are you saying I wouldn''t get that? Or would I get that if I used a :through association? I''m sort of having a tough time wrapping my head around the associations. I read the rails guide on associations but it''s not sticking yet. Is the whole point of associations being able to make calls to the records because of active record''s built in capabilities? With regard to what you mentioned about CourseDate and CourseTime and just making them additional columns. Could I still call that information and post it to a calendar some how? My confusion over relationships starts making me think that I should make everything an object class. Has anyone else felt this way? Is there a guideline for when you make something it''s own class as opposed to just making it a column in a table? Mark On Aug 6, 2:42 am, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Aug 6, 9:07 am, MC <amev...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > First crack at an app. I have a friend with a private school that I''m > > trying to create a scheduling system for. > > > So I have Coordinators creating school courses. Once the course is > > created the coordinator can assign multiple instructors, and then > > assign students to the course and instructor. So is this right? > > Are you even going to need to have students that belong to multiple > instructors? Are you going to want to know what course the student is > taking ? From the associations you''ve given you don''t seem to be > storing that bit of information, the best you could work out is that > given their instructor there are only certain courses they could be > doing. > > > > > Then the other thing I want to do is set a date and time for each > > course. So would I create this also: > > > class CourseDate > > belongs_to :course > > end > > > class CourseTime > > belongs_to :coursedate > > end > > Without a full understanding of your problem (perhaps you are managing > repeating occurrences of courses etc.) this feels a little overkill to > be honest. would date/time columns on your courses table not suffice? > > Fred > > > > > > > > > > > Thanks in advance, Mark-- 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.
Mark, Here are some question I would raise in designing a domain model for an app like this: - Can students and or instructors participate and or coordinate more than one course simultaneously? - Do you want to retain record of past participation? The reason why I pointed out the role pattern using :through is it allows you to append extra information to the association using a mediatory model class. If the answer to these two questions is no, it''s completely not needed. FYI - The models are object classes in their own right. Everything in a Rails application is the a model if not acting upon or displaying results or searching (controller), or conveying model state (views). I tend to design applications from the model upward. I think in terms of model as the value of the application, controller as workflow, and the view agnostic of browser, API, or other. But I am coming from JEE. Peepcode, Meet Rails 3 Part 2 in specific walks the reader through building a project management system for the DeathStar. It would be a good screencast to watch and show you how to implement your app as the sample project is similar to what you are trying to do. If you don''t want to buy, suggest you download and review the sample code for the project. Alternatively, if you can give us a little more information on your business logic, we can point you in the right direction to implement the model. Cheers, Rafael On Aug 6, 2011, at 4:43 PM, MC wrote:> Frederick, > > I would want to be able to see what students are being taught be what > instructor. And yes I would want to be able to know what the course > the student is taking. So from my current setup are you saying I > wouldn''t get that? Or would I get that if I used a :through > association? > I''m sort of having a tough time wrapping my head around the > associations. I read the rails guide on associations but it''s not > sticking yet. Is the whole point of associations being able to make > calls to the records because of active record''s built in > capabilities? > > With regard to what you mentioned about CourseDate and CourseTime and > just making them additional columns. Could I still call that > information and post it to a calendar some how? > > My confusion over relationships starts making me think that I should > make everything an object class. Has anyone else felt this way? Is > there a guideline for when you make something it''s own class as > opposed to just making it a column in a table? > > Mark > > On Aug 6, 2:42 am, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > wrote: >> On Aug 6, 9:07 am, MC <amev...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> >>> First crack at an app. I have a friend with a private school that I''m >>> trying to create a scheduling system for. >> >>> So I have Coordinators creating school courses. Once the course is >>> created the coordinator can assign multiple instructors, and then >>> assign students to the course and instructor. So is this right? >> >> Are you even going to need to have students that belong to multiple >> instructors? Are you going to want to know what course the student is >> taking ? From the associations you''ve given you don''t seem to be >> storing that bit of information, the best you could work out is that >> given their instructor there are only certain courses they could be >> doing. >> >> >> >>> Then the other thing I want to do is set a date and time for each >>> course. So would I create this also: >> >>> class CourseDate >>> belongs_to :course >>> end >> >>> class CourseTime >>> belongs_to :coursedate >>> end >> >> Without a full understanding of your problem (perhaps you are managing >> repeating occurrences of courses etc.) this feels a little overkill to >> be honest. would date/time columns on your courses table not suffice? >> >> Fred >> >> >> >> >> >> >> >> >> >>> Thanks in advance, Mark > > -- > 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. >-- 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.
On Aug 7, 12:43 am, MC <amev...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Frederick, > > I would want to be able to see what students are being taught be what > instructor. And yes I would want to be able to know what the course > the student is taking. So from my current setup are you saying I > wouldn''t get that? Or would I get that if I used a :through > association?It depends on the reality you are modelling. At the moment, a student belongs_to instructor, which has_many courses - how can you extract from that which course a student on. Is it really the case that a student always has the same instructor, no matter what combination of courses?> I''m sort of having a tough time wrapping my head around the > associations. I read the rails guide on associations but it''s not > sticking yet. Is the whole point of associations being able to make > calls to the records because of active record''s built in > capabilities? >Using associations does get you all that, but before thinking about that I think you need to step back and think about the data you are trying to model and what questions you will need to be able to answer. For example with you current setup, you can''t represent a student having one instructor for their Spanish course and a different one for their Russian literature (but only you can say whether or not this restriction is ok). To me if feels like you want a join model between courses and students that defines which courses a student is taking and with which instructor, but I don''t know precisely what the reality that you are trying to model> With regard to what you mentioned about CourseDate and CourseTime and > just making them additional columns. Could I still call that > information and post it to a calendar some how? > > My confusion over relationships starts making me think that I should > make everything an object class. Has anyone else felt this way? Is > there a guideline for when you make something it''s own class as > opposed to just making it a column in a table? >You haven''t said what is in those tables. If they just a simple date and a simple time column, then i don''t think there''s any reason. If you''re managing a more complicated schedule then it might deserve its own table (e.g. if course date meant something like ''tuesdays and thursdays''). Bottom line is I would ask myself for the given situation - what data might I be duplicating - how does this change my ability to ask (efficiently) the questions that I want to answer (e.g. ''what courses are on today'' or ''when does this course start) If there''s no benefit to having a separate table then that suggests to me that the things in question are more naturally just attributes. Fred.> Mark > > On Aug 6, 2:42 am, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > wrote: > > > > > > > > > On Aug 6, 9:07 am, MC <amev...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > First crack at an app. I have a friend with a private school that I''m > > > trying to create a scheduling system for. > > > > So I have Coordinators creating school courses. Once the course is > > > created the coordinator can assign multiple instructors, and then > > > assign students to the course and instructor. So is this right? > > > Are you even going to need to have students that belong to multiple > > instructors? Are you going to want to know what course the student is > > taking ? From the associations you''ve given you don''t seem to be > > storing that bit of information, the best you could work out is that > > given their instructor there are only certain courses they could be > > doing. > > > > Then the other thing I want to do is set a date and time for each > > > course. So would I create this also: > > > > class CourseDate > > > belongs_to :course > > > end > > > > class CourseTime > > > belongs_to :coursedate > > > end > > > Without a full understanding of your problem (perhaps you are managing > > repeating occurrences of courses etc.) this feels a little overkill to > > be honest. would date/time columns on your courses table not suffice? > > > Fred > > > > Thanks in advance, Mark-- 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.