Friday, October 30, 2009

Re: Database design

First of all - I suggest you drop the table_singular_name_id format
for your tables primary key and use the CakePHP expected primary key,
which is just named "id" - nothing else! That will make your life
easier!

Playing with your tables and relationships:
Student hasAndBelongsToMay Course - and vice verse.
Course hasMany Assignment - Assignment belongsTo Course.
Student hasAndBelongsToMany Assignment - and vice verse.

The mark is in the AssignmentStudent model - which is the
hasAndBelongsToMany model between Student and Assignment.

Enjoy,
John

On Oct 30, 3:11 pm, japaternoster <japaternos...@googlemail.com>
wrote:
> Hi,
>
> I am relatively new to database design and have only made some
> relatively simple CakePHP apps, but am currently working on a new
> project with some slightly more complicated database relationships.
>
> --Students----------------
> student_id
> student_name (I want to leave this as a single item)
> year
>
> --Courses----------------
> course_id
> name
> shortname
> type
>
> --Assignment----------------
> assignment_id
> type
> value
> description
>
> --Marks----------------
> mark_id
> result
>
> The idea is that each *student* takes x *courses* and each *course*
> has y *assignments*, so each *student* has a *mark* for an
> *assignment* of a *course*. Is this the easiest way of doing this?
>
> Also, what does this mean for HABTM/has many relationships?
>
> Thanks
>
> Jack
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

No comments: