Ask your own question, for FREE!
Computer Science 7 Online
OpenStudy (anonymous):

What is the difference between ManytoManyField Relationship and a Foreign Key?

OpenStudy (anonymous):

Strange question. A many to many relationship would imply a table that holds the relationships, for example PRIMARY_KEY = 1, FOREIGN_KEY_1 = 23; FOREIGN_KEY_2 = 42 would mean that the record with ID 23 is connected to the record with id 42.

OpenStudy (anonymous):

An example of a many to many relationship would be "teachers can have many students, students can have many teachers." You would represent this by having separate tables for students and teachers, and a table like "courses" that uses foreign keys to link students to teachers. A foreign key is used to eliminate redundancy in a database by taking the primary key of one table and using it in another table. For example, in a table "courses" you may need to include students and teachers in a particular course. To do this, you will need to have a foreign key for TEACHER_ID and a foreign key for STUDENT_ID. These same IDs would be primary keys in separate tables you would have for teachers and students.

OpenStudy (anonymous):

Many to many relationships are typically frowned upon in database design. The suggested trick is to create a junction table where the many to many relationship exists in your structure.

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!