First: Database names are plural:
students, courses, assignments, marks. The models would then be Student, Course, Assignment and Mark. The id of each database should be just 'id'. Because that's what CakePhp likes, and because it's convention to name *foreign keys* like this: tablename_id - so a foreign key pointing to the students table (id) would be student_id. If you follow that convention, it's easy to spot primary IDs (id) and foreign keys (tablename_id). If you modify the assignment database to look like this: assignment-------------------- id type value description course_id Then you have just linked assignments to a course (course_id is a foreign key). Maybe you could use a lookup table for students participating in courses: courses_students--------------------------- id course_id student_id Then, finally, you have to create a table for each student where the marks are stored. Hopefully this should give you some ideas. The benefit of using Cake conventions all the way is that you can create your app using the console (bake). On Oct 30, 2:11 pm, japaternoster <[email protected]> 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 [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~----------~----~----~----~------~----~------~--~---
