I'm new to databases. Using SQLite3 to store Objects of a Lua script, I want to interlace 2 tables.
Let's say the lua objects look like this:
class_A.name = ""
class_A.currency = 0
class_A.salary = 0
class_A.misc = {}
class_A.customers = {} -- this stores related objects of class_B
class_A:function1() something is something end
class_A:function2() something is something else end
class_B.name = ""
class_B.id = ""
class_B.value = 0
class_B.consultant = {} -- this stores related objects of class_B
class_B:function1() something is different end
Now I'm storing these in SQLite tables. The "relatedObjects"-var should be stored in a 3. table, this should look similar to this:
-- class_A table:
| Idx | Name | currency | salary | misc |
|------|-------|----------|--------|------|
| 1 | john | 1,233.00 | 2,300 | null |
| 2 | eva | 4,100.00 | 1,970 | null |
-- class_B table
| Idx | Name | currency | salary | misc |
|------|----------|----------|--------|------|
| 1 | peterson | 1,233.00 | 2,300 | null |
| 2 | griffin | 4,100.00 | 1,970 | null |
| 3 | simpson | 2,738.00 | 2,100 | null |
--Interleave
--index of the respective table
| consultant | csutomer |
|------------|----------|
| 1 | 2 |
| 2 | 1 |
| 3 | 1 |
| 3 | 2 |
I hope you got my point, don't think this is verry difficult and thus I feel pretty dump right now. The Idx value is AUTOINCREMENT, so ther should not occur any confusion.
The question is HOW TO set up this Interleave table.
Aucun commentaire:
Enregistrer un commentaire