Search code examples
mysqlsqlerdsql-optimization

Many to many relationship optimization


I'm working on a system where I hava a table for storing student languages competencies to manage this we created the following architecture :

the table STD_LANGUAGE_COMPETENCIES is representing the associative entity . of a many to many relationship between the STD_LANGUAGE ( french , english, arabic ...) table and STD_LANGUAGE_SKILL ( reading , speaking , writing , teaching) the problem is that STD_LANGUAGE and STD_LANGUAGE_SKILL are not updated by a normal user of the system( student ) they are added by system administrator , and when I try to fetch language competencies for a student the architecture oblige me to do a join on two table in order to get the name of the language and the name of the skill . is there anyway to optimize this schema .


Solution

  • If the language skills are for example: "reading", "writing", "conversation", ecc., without sovrapposition of names, without limit of time for skills, and management client modules, you can put the description directely in STD_LANGUAGE_COMPETENCE table, and remove the foreign key cstraints, while you keep the skills table for combo items to assign or search(by text).

    In this way you can avoid a join..