2010-12-12, 15:24
#1
Jag är inte så bevandrad i SQL men det här är det jag har just nu:
Tyvärr funkar det inte när jag försöker köra en query på detta, utan det ger något kryptiskt felmeddelande.
Kod:
--
-- MySQL 5.0.75
-- Sun, 12 Dec 2010 12:21:06 +0000
--
CREATE TABLE `cities` (
`id` int(10) not null auto_increment,
`city` tinytext,
`country` tinytext,
`province` tinytext,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=swe7 AUTO_INCREMENT=1;
CREATE TABLE `patterns` (
`id` int(10) not null auto_increment,
`pattern` tinytext,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=swe7 AUTO_INCREMENT=1;
CREATE TABLE `items` (
`id` int(10) not null auto_increment,
`type_id` int(10) FOREIGN KEY('type_id') REFERENCES types('id'),
`pattern_id` int(10) FOREIGN KEY('pattern_id') REFERENCES patterns('id'),
`length` float,
`cost` float,
`total_rings` bigint(10),
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=swe7 AUTO_INCREMENT=1;
CREATE TABLE `types` (
`id` int(10) not null auto_increment,
`type` tinytext,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=swe7 AUTO_INCREMENT=1;
CREATE TABLE `orders` (
`id` int(10) not null auto_increment,
`type_id` int(10) FOREIGN KEY('type_id') REFERENCES types('id'),
`item_id` int(10) FOREIGN KEY('item_id') REFERENCES items('id'),
`status` int(10),
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=swe7 AUTO_INCREMENT=1;
CREATE TABLE `users` (
`id` int(10) not null auto_increment,
`first_name` tinytext,
`surname` tinytext,
`street` tinytext,
`street_number` int(10),
`city_id` int(10) FOREIGN KEY('city_id') REFERENCES cities('id'),
`postal_code` int(10),
`current_order_id` int(10) FOREIGN KEY('current_order_id') REFERENCES orders('id'),
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=swe7 AUTO_INCREMENT=1;
Tyvärr funkar det inte när jag försöker köra en query på detta, utan det ger något kryptiskt felmeddelande.