Rat zwecks DB Struktur

Diese Seite verwendet Cookies. Durch die Nutzung unserer Seite erklären Sie sich damit einverstanden, dass wir Cookies setzen. Weitere Informationen

  • Rat zwecks DB Struktur

    Hallo,

    Ich Code gerade an einem kleinen Shop. In diesen sollen hauptsächlich TS3 Server, mein IRC Interface und kleine Webspace Pakete angeboten werden.
    Nun Suche ich nach einer passenden DB Struktur, kann mich aber nicht entscheiden.

    Meine Struktur ist folgende:

    Quellcode

    1. CREATE TABLE IF NOT EXISTS `ts3_product` (
    2. `id` mediumint(8) NOT NULL AUTO_INCREMENT,
    3. `name` varchar(255) COLLATE utf8_bin NOT NULL,
    4. `description` text COLLATE utf8_bin NOT NULL,
    5. `mini_description` text COLLATE utf8_bin NOT NULL,
    6. `price` varchar(255) COLLATE utf8_bin NOT NULL,
    7. PRIMARY KEY (`id`)
    8. ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin ;
    9. CREATE TABLE IF NOT EXISTS `irc_product` (
    10. `id` mediumint(8) NOT NULL AUTO_INCREMENT,
    11. `name` varchar(255) COLLATE utf8_bin NOT NULL,
    12. `description` text COLLATE utf8_bin NOT NULL,
    13. `mini_description` text COLLATE utf8_bin NOT NULL,
    14. `price` varchar(255) COLLATE utf8_bin NOT NULL,
    15. PRIMARY KEY (`id`)
    16. ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin ;
    17. CREATE TABLE IF NOT EXISTS `space_product` (
    18. `id` mediumint(8) NOT NULL AUTO_INCREMENT,
    19. `name` varchar(255) COLLATE utf8_bin NOT NULL,
    20. `description` text COLLATE utf8_bin NOT NULL,
    21. `mini_description` text COLLATE utf8_bin NOT NULL,
    22. `price` varchar(255) COLLATE utf8_bin NOT NULL,
    23. PRIMARY KEY (`id`)
    24. ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin ;
    25. CREATE TABLE IF NOT EXISTS `kunden` (
    26. `kunden_id` mediumint(8) NOT NULL AUTO_INCREMENT,
    27. `anrede` text COLLATE utf8_bin,
    28. `name` text COLLATE utf8_bin,
    29. `adresse` text COLLATE utf8_bin,
    30. `ort` text COLLATE utf8_bin,
    31. `phone` text COLLATE utf8_bin,
    32. `email` text COLLATE utf8_bin,
    33. `activ` int(11) NOT NULL,
    34. `land` text COLLATE utf8_bin NOT NULL,
    35. `cookie_key` text COLLATE utf8_bin,
    36. `reg_date` int(11) NOT NULL,
    37. `pass` text COLLATE utf8_bin,
    38. PRIMARY KEY (`kunden_id`)
    39. ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin AUTO_INCREMENT=384 ;
    Alles anzeigen


    Praktisch für jede Produkt Kategorie eine eigene Tabelle und die Kunden Tabelle.
    Nun Suche ich eine Lösung wie ich es realisieren kann das Produkte die der User erwirbt alle ANgeziegt bekommt. Die dazugehörige SQL Abfrage wird später folgen wenn die DB steht.

    Ist es ratsam in der Kunden Tabelle 3 weitere Spalten einzufügen für die 3 Produkt Kategorien oder habt ihr andere Lösungsvorschläge?
  • was mir auf den ersten Blick auffällt ist das grauenhafte Denglisch.

    ts3_product , kunden, description, price, id, ort, reg_date, adresse, land .... :thumbdown:


    Du benötigst 3 Tabellen.
    1 customer
    1 products
    1 customer_products

    In customer und products kommen die ganzen Produkte & Kunden rein. customer_products ist die Zuordnungstabelle, diese Tabelle enthält nur "id, product_id, customer_id, created_at(Kaufdatum)".
    1 Kauf = 1 Eintrag


    Um alle erworbenen Produkte anzuzeigen sollte dann auch kein Problem mehr darstellen ;)