Total newbie here, regarding sqlite, so don’t flame too hard 🙂
I have a table:
index name length L breadth B height H
1 M-1234 10 5 2
2 M-2345 20 10 3
3 ....
How do I put some tabular data (let’ say ten x,y values) corresponding to index 1, then another table to index 2, and then another, etc. In short, so that I have a table of x and y values that is “connected” to first row, then another that is connected to second row.
I’m reading some tutorials on sqlite3 (which I’m using), but am having trouble finding this. If anyone knows a good newbie tutorial or a book dealing with sqlite3 (CLI) I’m all ears for that too 🙂
You are just looking for information on
joins and the concept offoreign key, that although SQLite3 doesn’t enforce, is what you need. You can go without it, anyway.In your situation you can either add two “columns” to your table, being one
xand anothery, or create a new table with 3 “columns”:foreign_index,xandy. Which one to use depends on what you are trying to accomplish, performance and maintainability.If you go the linked table route, you’d end up with two tables, like this:
When you want the
xandyvalues of your element, you just use something likeSELECT x, y FROM XandY WHERE foreign_index = $idx;To get all the related attributes, you just do a
JOIN: