Answer the question
In order to leave comments, you need to log in
Is it possible to write multiple FOREIGN KEYs in one SQL cell?
I'm going to write an application in C ++ Qt , for managing projects at the enterprise (tracking the product development stage, completeness of design documentation, assigning decimal numbers, etc.). There was a question of the organization of SQLite basis. The fact is that not at all stages of development a full house of documents is required - somewhere a list of purchased products is not needed, somewhere approval sheets. A bunch of questions. How to display it in the database?
I came up with such a structure - three tables for types of documents (for CD, for TD and for PD) (Specification, Route map, etc.), three tables for the documents themselves (relative path, title, artist ...) and one table with stages (name, letter ...). So, how to display the fact mentioned above that not all documents are needed at all stages? And if you are tied to the topic of the question, then can I, by specifying the column "required documents" in the "stages" table, push all the IDs of the necessary documents into the cell? Or one cell - one FOREIGN KEY ?
Yes, I asked crumpled, dumped a lot off topic, but this is conscious, since my approach is most likely not correct at all, then can someone tell me how best to design this case?
Answer the question
In order to leave comments, you need to log in
Theoretically, you can stuff the entire list of id records into one field, as a string, as an array, etc., but this is a very bad approach. I understand that you need a many-to-many relationship: there should be a table in which in one column there will be id "stages", and the second id of documents corresponding to these stages.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question