php - basic mysql/data storage question: information architecture, not as much code itself -
i'm trying figure out first "more complex" sql application , having bit of hard time conceptualizing best way go simple. understand code, think, around various concepts want know best way think way proceed, , more importantly what terms/how call method, can more research on myself without needlessly bothering people!
i building wp plugin let add number of boxes number of "transactions". basically, transaction 1 can have box 3 boxes called apples, fruits, organes. transaction 2 can have 10 boxes. , on. want way show end user in best way. beginner, (bad, i'm sure) instinct have 1 key called, say, transactions, comma separated list "1,2,3,4,5". then, have table index 1,2,3 , each of these keys have various boxes. grab first csv list db, "explode" array , cycle through, grabbing keys second table reflect #. in second table, each "key" point other keys? confused. best way proceed? kind of code need for? edit: here visual image of i'm looking for:
transaction 1: #12878321: apples, oranges, pears transaction 2: #11239089: berries, oranges, apples transaction 3: #89792834: spaghetti, berries, oranges, pears, apples
i display on page information that. need store transaction number, random code, , "what purchased" (the boxes in example above) end user.
i've done inserts, updates, etc on 1 table never connected (correct word?) 2 tables , don't know if thats way it, create wp table.
i apologize if strange , long question, among 1,000 of tutorials on web, hard understand 1 follow because i'm not familiar terms themselves!
what want (i think) called "many many" relationship. these best handled association table; association table has 2 (relevant) columns; id of record in 1 table, , id of record in second table. way, can create sql statement find of "boxes" (records in table 2) exist given "transaction" (records in table 1); can create query allow find of "transactions" (records in table 1) refer given "box" records in table 2.
for this, need 3 tables:
transactions id, whatever else keep transactions boxes id, contents transactionboxes transactionid, boxid
Comments
Post a Comment