I've recently started getting (somewhat serious with MySQL and databases in general and naturally I am still slightly green when it comes to some of the basic concepts in contrast to how I'm used to doing things in programming languages.
Let's assume I have this table tableBooks and another table tableBoxes and I am looking to store the books that are inside a given box.
In coding, I'd just stick references to the box instances into an array within box and call it a day.
With databases, however, I assume I can't store references to all bookss, rather I have a key in tableBoxes (let's call this Container) that holds the foreign key of the appropriate tableBoxes item.
Is this correct or am I out on the wrong limb?
I am asking because this bottom-up approach seems wasteful to a novice such as myself, e.g., to get all the books in a specific box, I'd have to go through all the books and check if their Container value corresponds to the currently selected box. What if there are thousands of boxes and tens of thousands books?
Thanks in advance and apologies for what probably is an inane question.