Hi guys!

  I am an old procedural programmer learning Rails and object
orientation.  :)

  I wish to create a little system to help my wife who is a teacher.

  The attached PDF file has the preliminary Entity-Relationship model.

  I am having a rough time trying to put this model into Rails...  :(

  Looking at the model I can think about the SQL code necessary.  But I
think Ruby and Rails is here to help and speed the development process.
;)

  For some examples:

    Who teaches at school "x"?

SELECT people.name FROM people WHERE people.id IN
  (SELECT team_has_teachers.person_id FROM team_has_teachers WHERE
team_has_teachers.team_id IN
    (SELECT teams.id AS team_id FROM teams WHERE teams.school_id =
      (SELECT schools.id AS school_id FROM schools WHERE schools.name =
'x')))


    Who learns from teacher "x"?

SELECT people.name FROM people WHERE people.id IN
  (SELECT team_has_students.person_id FROM team_has_students WHERE
team_has_students.team_id IN
    (SELECT team_has_teachers.team_id FROM team_has_teachers WHERE
team_has_teachers.person_id =
      (SELECT people.id FROM people WHERE people.name = 'x')))


    Who is in team "x"?

SELECT people.name FROM people WHERE people.id IN
  (SELECT team_has_students.person_id FROM team_has_students WHERE
team_has_students.team_id IN
    (SELECT teams.id FROM teams WHERE teams.name = 'x'))


  Any help is welcome!


Best regards,
  Mosoleu

Attachments:
http://www.ruby-forum.com/attachment/8356/ER_model.pdf


-- 
Posted via http://www.ruby-forum.com/.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to