I’m new with Django (and almost with DDBB). I’m creating two models: QUESTIONS and SIGNATURES. I wanted to make some searches in the database attending to the signature of a question. For example search 10 questions of the history signature (or Biology, etc).
The main problem is that every question could belong to different signatures (for example Math and Phisycs).
I thought of a integer field in the QUESTIONS model that gives info of the signatures, for example a binary representaion of the signatures: 1010001 where every position indicates the presence (or not) of the signature associated. The problem with this is that is not enough look at the BBDD but also you have to make calculations before determining if the signature is associated.
This operation will slow too much the search?
I’ve heard of manyToMany fields, would this be a better aproach to solve this situation?
Thanks for your comments
This is easily solvable by using the many to many field. what the many to many field does is create a second table to join the associations. so for example,
besides the table for Question and the table for Signature a third table called appname_question_signature will be created where the primary keys of the question table will be mapped to the signatures. since you can have multiple entries in this table any question can be mapped to any number of signatures and vise versa.
and to query for all history questions you would go