MySQL Forums
Forum List  »  German

Re: Produktdatenbank mit Produkteigenschaften
Posted by: Simon Maier
Date: March 12, 2012 04:01AM

Es dreht sich alles um die "att" tabelle die die ganzen attribute/eigenschaften beinhaltet, ich wollte es nur vereinfacht darstellen.

Wirkliche Fremdschluessel wie bei InnoDB habe ich nicht, es sind beides MyISAM
Alle 3 Tabellen die ich habe:

###############
Tabelle attnames, zur umwandlung des Attribut Namens
attnames -> attnames.id gehoert zur tabelle att.attnames_id
CREATE TABLE IF NOT EXISTS `attnames` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`cat_id` int(10) unsigned NOT NULL COMMENT 'bevorzugte gruppe ueberfluessig',
`si` varchar(50) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,
`grund` varchar(10) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,
`is_float` tinyint(1) NOT NULL COMMENT 'Wird hier ein Zahlenwert erwartet',
`prefix` tinyint(1) NOT NULL COMMENT 'ist ein prefix erlaubt',
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;

###############
Tabelle parts ( Die Teile Tabelle selbst, zur umwandlung parts_id zum Produktnamen)

CREATE TABLE IF NOT EXISTS `parts` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`man_id` int(10) unsigned NOT NULL,
`cat_id` int(10) unsigned NOT NULL,
`herstellernr` varchar(150) COLLATE utf8_unicode_ci NOT NULL,
`seotext` varchar(150) COLLATE utf8_unicode_ci NOT NULL,
`text` text COLLATE utf8_unicode_ci NOT NULL,
`stamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
UNIQUE KEY `man_id` (`man_id`,`herstellernr`),
UNIQUE KEY `seotext` (`seotext`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 ;

###############
Die Attribute Tabelle.
parts_id -> parts.id (Verbindung zur Parts tabelle)
attnames:id -> attnames.id (Verbindung zum Attribut Namen)
In dieser Tabelle soll die ganze Teilauswahl geschehen, auch ohne die Tabellen
parts und attnames, sollte die Funktionieren, gibt dann ebend nur die parts_id wieder.

CREATE TABLE IF NOT EXISTS `att` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`parts_id` int(10) unsigned NOT NULL,
`attnames_id` int(10) unsigned NOT NULL,
`val_f` double NOT NULL,
`val_s` varchar(100) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `key_parts` (`parts_id`,`attnames_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=25 ;

INSERT INTO `att` (`id`, `parts_id`, `attnames_id`, `val_f`, `val_s`) VALUES
(1, 1, 1, 0, 'blau'),
(2, 2, 1, 0, 'blau'),
(3, 1, 2, 2.00034589e+16, ''),
(4, 2, 2, 1e+23, ''),
(5, 3, 2, 0.022, ''),
(6, 4, 2, 1e+15, ''),
(7, 5, 2, 1e-15, ''),
(8, 6, 2, 1.099511627776e+16, ''),
(9, 7, 2, 1.28e-12, ''),
(10, 1, 3, 0, 'zwei-beinig'),
(11, 2, 3, 0, 'vier-beinig'),
(12, 3, 3, 0, 'zwei-beinig'),
(13, 4, 3, 0, 'vier-beinig'),
(14, 5, 3, 0, 'zwei-beinig'),
(15, 6, 3, 0, 'vier-beinig'),
(16, 7, 3, 0, 'zwei-beinig'),
(17, 3, 4, 5.6, ''),
(18, 4, 4, 5, ''),
(19, 5, 4, 7, ''),
(20, 6, 4, 7.1, ''),
(21, 7, 4, 0.04, ''),
(22, 5, 5, 5000, ''),
(23, 6, 5, 6000, ''),
(24, 2, 5, 4500, '');

Options: ReplyQuote




Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.