tabels design

tabels design

by cave man -
Number of replies: 6
the relationship between course table and category table is: many to many
and in moodle database it is : one(category) and many(courses)
and it may be solved just by add new table with name : course
and old mdl_course ------- will be ------> mdl_course_category
and old mdl_course_category ----------> mdl_category

then due to my experience in moodle I know am wrong smile
but WHY sad ?!!

Average of ratings: -
In reply to cave man

Re: tabels design

by Davo Smith -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

I'm not sure I understand what you are asking. In Moodle each course can only be in one category. 


Are you asking for advice about how to modify your local copy of Moodle so that courses can be in more than one category? If so, my advice would be to not do that - most of the code relating to Moodle courses is written assuming the way moodle currently works, so you will have a lot of problems if you change this (including issues with permissions: if the capabilities assigned to the user are different in different categories, then which permissions should be used in the course?)

In reply to Davo Smith

Re: tabels design

by cave man -

you are right in your advise but the question is

"WHY moodle database design has this mistake in relationship between course table and category table ?

note: ELIS plugins resolved this point by adding new concept in its database ,that concept named "course description"

In reply to cave man

Re: tabels design

by Davo Smith -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Hi Cave Man,

You still haven't explained where the mistake is in the database design.

The Moodle system has a 1 to many relationship between categories and courses.

The Moodle database has a 1 to many relationship between categories and courses.

This seems to be consistent (unless I've missed somewhere in Moodle that suggests there is a many to many relationship between courses and categories).

Are you saying there should be a many to many relationship between courses and categories? If so, then you are proposing a (fairly fundamental) change to the way courses and categories work in Moodle (with major implications for the handling of permissions), rather than a mistake in the current implementation.


In reply to Davo Smith

Re: tabels design

by cave man -
I know that Moodle database and system have 1 to many relationship between course and category
but the question is :
as an abstraction concept -apart from Moodle- for relationship type between course concept and category concept ,should that relationship be a "many to many" ..!?
and you have understood what I meant exactly ..

so here where I see mistake in database design and of course I understand the correction of this mistake -if was a real mistake -will cause some changes in whole the system -as I pointed before , ELIS plugin used "Course Description" concept to cover this conflict

thanks smile

In reply to cave man

Re: tabels design

by Robert Brenstein -
May be this old tracker entry MDL-17533 and other entries linked from it can shed some light for you on the past and why 1-to-many relation is all what Moodle has, cave man.
In reply to cave man

Re: tabels design

by Colin Fraser -
Picture of Documentation writers Picture of Testers

According to the basic database theories I learned the many-to-many relationship cannot work, it forces uncertain decision making about what question is being asked. Computers cannot think, so are unable to reason in an abstract manner, and cannot produce accurate results from the context of any question asked, well that is what I have surmised. What can be done is one-to-many, many-to-one, many-to-one-to-many, and one-to-many-to-one relations, but the last two are variations on a theme.

I cannot see where you would consider that the database has an error because it does not support many-to-many relations. That is self-defence.