Moin!
Hallo,
^Das heißt 'Hello', oder die nachfolgende Sprache paßt nicht (zuviel Whisky getestet?). :)
Costumer A buys Products with NO: 12, 13 , 25 -> system says OK, looks for
Tables 12,13,25 -> finds nothing creates table 12, inserts 13 and 25 and
sets sold of each to 1, then creates table 13 and 25 and inserts like it did
in table 12
now cosumter B buys products 13,12,19 -> system says OK, looks for tables
13,12,19 and finds only 12 created, adds 19 into table 12 and updates sold
from 13 in table 12 -> then does this with table 13 and finally creates
table 19 (because new) and inserts like in Cosumter A's way...
Bad idea.
now the question: is MySQL aware of being with over 1500 tables ??? - is
there a better way or more efficent way to do the same ?
Try this:
Die Bestellung von Artikel Nr. 12, 13 und 19 wird in eine einzige Tabelle eingetragen, die im Prinzip nur zwei Spalten enthält: "bestellt_wurde" und "bestellt_wurde_auch". Diese Tabelle enthält aufgrund der Bestellung folgende Einträge:
12 -> 13
12 -> 19
13 -> 12
13 -> 19
19 -> 12
19 -> 13
Du kannst dann ganz simpel abfragen, welche Produkte auch gekauft wurden, wenn gewisse Produkte gekauft wurden.
Ich würde die Tabelle sogar bei jedem Kauf ergänzen, und nicht vorher prüfen, ob die Kombinationen schon mal gekauft wurden, denn dann kannst du statistisch arbeiten und zählen, wieviele Kaufkombinationen vorher schon gemacht wurden. Das würde die Aussagekraft der Information möglicherweise heben.
Wenn ich allerdings mal auf meine vergangenen Einkaufszettel schaue, dann ist eine Kombination beliebiger Produkte kaum sinnvoll: Wer Karotten kauft, kauft auch Senf (damit er was zum Würzen hat?). Wer Senf kauft, kauft auch T-Shirts (weil er sich vollkleckert und keinen Bock zum Waschen hat?). Wer T-Shirts kauft, kauft auch Toilettenpapier (Ähm...???).
- Sven Rautenberg