[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4688: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3823)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4690: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3823)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4691: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3823)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4692: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3823)
Webmasterplein.net • Toon onderwerp - [MySQL] error 105 can't create table
Pagina 1 van 1

[MySQL] error 105 can't create table

BerichtGeplaatst: 07 jun 2005 10:34
door matel
Ik ben bezig om relaties te leggen in een mysql database. Alleen loop ik heel de tijd tegen een hardnekkig probleem aan.

Situatie

We maken een website waarop de klant auto's en onderdelen kan bestellen. Dit wordt gemaakt in php/mysql.

Alles gaat uit van de klant. De klant heeft één of meer orders. Op de order kunnen meerdere onderdelen en/of autos staan.

SQL

[syntax="taal"]CREATE TABLE `klant` (
`klant_ID` int(10) unsigned NOT NULL auto_increment,
`k_voornaam` varchar(45) NOT NULL default '',
`k_achternaam` varchar(45),
`k_straat` varchar(50),
`k_postcode` varchar(10),
`k_woonplaats` varchar(50),
`k_telefoon` int(10) unsigned,
`k_geboortedatum` date,
PRIMARY KEY (`klant_ID`),
INDEX (`klant_ID`)
) ENGINE=InnoDB;[/syntax]

[syntax="taal"]CREATE TABLE `verkoper` (
`verkoper_ID` int(10) unsigned NOT NULL auto_increment,
`v_voornaam` varchar(45) NOT NULL default '',
`v_achternaam` varchar(45),
`v_straat` varchar(50),
`v_postcode` varchar(10),
`v_woonplaats` varchar(45),
`v_telefoon` int(10) unsigned,
`v_geboortedatum` date,
`v_functie` varchar(45),
`v_afdeling` varchar(45),
`v_indienst` date,
`v_uitdienst` date,
`v_sofinummer` int(10),
PRIMARY KEY (`verkoper_ID`),
INDEX (`verkoper_ID`)
) ENGINE=InnoDB;[/syntax]

Er bestaat ook nog een tabel autos en artikelen die op dezelfde manier in elkaar steken. De problemen beginnen bij de tabellen order en orderregels.

[syntax="taal"]CREATE TABLE `order` (
`order_ID` int(10) unsigned NOT NULL auto_increment,
`FK_klant_ID` int(10),
`FK_verkoper_ID` int(10),
PRIMARY KEY (`order_ID`),
INDEX (`order_ID`),
KEY `FK_verkoper` (`FK_verkoper_ID`)
CONSTRAINT `klt` FOREIGN KEY (`FK_klant_ID`) REFERENCES `klant` (`klant_ID`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB;[/syntax]

[syntax="taal"]CREATE TABLE `orderregels` (
`FK_order_ID` int(10),
`FK_auto_ID` int(10),
`FK_artikel_ID` int(10),
`or_aantal` int(3),
`or_au_prijs` int(7),
`or_ar_prijs` int(7),
`or_btw` int(2),
`or_k_voornaam` varchar(45),
`or_k_achternaam` varchar(45),
`or_k_postcode` varchar(10),
`or_k_woonplaats` varchar(45),
KEY `FK_order` (`FK_order_ID`),
KEY `FK_auto` (`FK_auto_ID`),
KEY `FK_artikel` (`FK_artikel_ID`),
CONSTRAINT `ord` FOREIGN KEY (`FK_order_ID`) REFERENCES `order` (`order_ID`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB;[/syntax]

Wie ziet waar ik de mist in ga?

BerichtGeplaatst: 07 jun 2005 10:39
door Derk
het probleem van phpmyadmin vind ik:
Ik heb 4 hosts met phpmyadmin
2 met de nieuwste en 2 met een oudere.
Als ik met de nieuwe een MYSQL dump maak kan de oude dit niet lezen en geeft een error
omgekeerd zelfde.
Kijk dus even goed naar de versies van je PHPmyadmin

BerichtGeplaatst: 07 jun 2005 10:44
door matel
Ik kan ze toevoegen in zowel phpmyadmin als in mysql query browser (tooltje voor windows). Ook verschillende versies van mysql maakt niet uit. Hij blijft de foutmelding geven. Bovendien leest hij de andere tabellen wel goed in en gaat het ergens fout in de foreign key.

BerichtGeplaatst: 07 jun 2005 11:31
door Derk
Ik kan maar 1 ding zeggen en dat is de tabellen overnieuw maken

een foreign key heb ik nog nooit van gehoord....

BerichtGeplaatst: 07 jun 2005 11:34
door matel
Dat bestaat zeker wel. Ik heb het wel vaker gebruikt, maar op een andere manier.

BerichtGeplaatst: 07 jun 2005 11:47
door Derk
ik zeg ook niet dat het niet bestaat ik zeg alleen dat ik het niet ken.

BerichtGeplaatst: 07 jun 2005 11:57
door matel
Maar het heeft dan ook geen zin de tabellen opnieuw te maken. Dan loop ik evengoed tegen hetzelfde probleem aan.

BerichtGeplaatst: 07 jun 2005 12:37
door Stef
Heb je al geprobeert de tabel met phpmyadmin zelf te bouwen, kijken of je een andere syntax gebruikt.

BerichtGeplaatst: 07 jun 2005 17:08
door matel

BerichtGeplaatst: 07 jun 2005 20:12
door Derk
je schrijft zelf met de hand die tabel dan?

BerichtGeplaatst: 07 jun 2005 21:00
door matel
Jep. Ik heb wel een hulpprogramma'tje, maar die hielp in dit geval niet omdat die niet aangaf wat precies fout zat. Maar het lag iig aan de punten die ik noemde. Ik kan de tabellen zonder problemen toevoegen nu Very Happy

<hr />Volgens mij is de database nu zonder fouten en liggen de relaties goed. Ik zal hier de dump maar even posten, want er is zeer weinig (tot niets) te vinden op internet over hoe je dit moet aanpakken. Phpmyadmin voegt pas later de constraints toe. Ik vind het best Razz

[syntax="taal"]-- phpMyAdmin SQL Dump
-- version 2.6.1
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Generatie Tijd: 07 Jun 2005 om 22:46
-- Server versie: 4.1.9
-- PHP Versie: 4.3.10
--
-- Database: `loopink`
--

-- --------------------------------------------------------

--
-- Tabel structuur voor tabel `artikelen`
--

CREATE TABLE `artikelen` (
`artikel_ID` int(10) unsigned NOT NULL auto_increment,
`ar_merk` varchar(45) default NULL,
`ar_type` varchar(45) default NULL,
`ar_soort` varchar(45) default NULL,
`ar_prijs` int(7) unsigned default NULL,
`ar_afbeelding` varchar(100) default NULL,
PRIMARY KEY (`artikel_ID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Gegevens worden uitgevoerd voor tabel `artikelen`
--


-- --------------------------------------------------------

--
-- Tabel structuur voor tabel `autos`
--

CREATE TABLE `autos` (
`auto_ID` int(10) unsigned NOT NULL auto_increment,
`au_merk` varchar(45) default NULL,
`au_type` varchar(45) default NULL,
`au_model` varchar(45) default NULL,
`au_bouwjaar` date default NULL,
`au_KMstand` int(6) unsigned default NULL,
`au_transmissie` varchar(45) default NULL,
`au_brandstof` varchar(45) default NULL,
`au_kleur` varchar(45) default NULL,
`au_aantal_deuren` varchar(45) default NULL,
`au_APK` varchar(100) default NULL,
`au_extra_opties` text,
`au_nieuwprijs` int(7) unsigned default NULL,
`au_prijs` int(7) unsigned default NULL,
`au_gewicht` int(5) unsigned default NULL,
`au_grijs_kenteken` enum('ja','nee') default NULL,
`au_kenteken` varchar(10) default NULL,
`au_afbeelding` varchar(100) default NULL,
PRIMARY KEY (`auto_ID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Gegevens worden uitgevoerd voor tabel `autos`
--


-- --------------------------------------------------------

--
-- Tabel structuur voor tabel `klant`
--

CREATE TABLE `klant` (
`klant_ID` int(10) unsigned NOT NULL auto_increment,
`k_voornaam` varchar(45) NOT NULL default '',
`k_achternaam` varchar(45) default NULL,
`k_straat` varchar(50) default NULL,
`k_postcode` varchar(10) default NULL,
`k_woonplaats` varchar(50) default NULL,
`k_telefoon` int(10) unsigned default NULL,
`k_geboortedatum` date default NULL,
PRIMARY KEY (`klant_ID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Gegevens worden uitgevoerd voor tabel `klant`
--


-- --------------------------------------------------------

--
-- Tabel structuur voor tabel `order`
--

CREATE TABLE `order` (
`order_ID` int(10) unsigned NOT NULL auto_increment,
`FK_klant_ID` int(10) unsigned default NULL,
`FK_verkoper_ID` int(10) unsigned default NULL,
PRIMARY KEY (`order_ID`),
KEY `FK_klant_ID` (`FK_klant_ID`),
KEY `FK_verkoper_ID` (`FK_verkoper_ID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Gegevens worden uitgevoerd voor tabel `order`
--


-- --------------------------------------------------------

--
-- Tabel structuur voor tabel `orderregels`
--

CREATE TABLE `orderregels` (
`FK_order_ID` int(10) unsigned default NULL,
`FK_auto_ID` int(10) unsigned default NULL,
`FK_artikel_ID` int(10) unsigned default NULL,
`or_aantal` int(3) unsigned default NULL,
`or_au_prijs` int(7) unsigned default NULL,
`or_ar_prijs` int(7) unsigned default NULL,
`or_btw` int(2) unsigned default NULL,
`or_k_voornaam` varchar(45) default NULL,
`or_k_achternaam` varchar(45) default NULL,
`or_k_postcode` varchar(10) default NULL,
`or_k_woonplaats` varchar(45) default NULL,
KEY `FK_order_ID` (`FK_order_ID`),
KEY `FK_auto_ID` (`FK_auto_ID`),
KEY `FK_artikel_ID` (`FK_artikel_ID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Gegevens worden uitgevoerd voor tabel `orderregels`
--


-- --------------------------------------------------------

--
-- Tabel structuur voor tabel `verkoper`
--

CREATE TABLE `verkoper` (
`verkoper_ID` int(10) unsigned NOT NULL auto_increment,
`v_voornaam` varchar(45) NOT NULL default '',
`v_achternaam` varchar(45) default NULL,
`v_straat` varchar(50) default NULL,
`v_postcode` varchar(10) default NULL,
`v_woonplaats` varchar(45) default NULL,
`v_telefoon` int(10) unsigned default NULL,
`v_geboortedatum` date default NULL,
`v_functie` varchar(45) default NULL,
`v_afdeling` varchar(45) default NULL,
`v_indienst` date default NULL,
`v_uitdienst` date default NULL,
`v_sofinummer` int(10) unsigned default NULL,
PRIMARY KEY (`verkoper_ID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Gegevens worden uitgevoerd voor tabel `verkoper`
--


--
-- Beperkingen voor gedumpte tabellen
--

--
-- Beperkingen voor tabel `order`
--
ALTER TABLE `order`
ADD CONSTRAINT `klt` FOREIGN KEY (`FK_klant_ID`) REFERENCES `klant` (`klant_ID`) ON DELETE CASCADE ON UPDATE CASCADE,
ADD CONSTRAINT `order_ibfk_2` FOREIGN KEY (`FK_verkoper_ID`) REFERENCES `verkoper` (`verkoper_ID`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Beperkingen voor tabel `orderregels`
--
ALTER TABLE `orderregels`
ADD CONSTRAINT `orderregels_ibfk_2` FOREIGN KEY (`FK_artikel_ID`) REFERENCES `artikelen` (`artikel_ID`) ON DELETE CASCADE ON UPDATE CASCADE,
ADD CONSTRAINT `ord` FOREIGN KEY (`FK_order_ID`) REFERENCES `order` (`order_ID`) ON DELETE CASCADE ON UPDATE CASCADE,
ADD CONSTRAINT `orderregels_ibfk_1` FOREIGN KEY (`FK_auto_ID`) REFERENCES `autos` (`auto_ID`) ON DELETE CASCADE ON UPDATE CASCADE;
[/syntax]

De namen van de constraints kun je aanpassen naar wat je zelf wil. Moet ik ook nog doen namelijk Wink

En voor wanneer je opzoek bent naar een handig hulpje, moet je MySQL Query Browser eens proberen. Dat is een klein, handig programma'tje die alles overzichtelijk weergeeft zodat je de fouten misschien sneller ziet.