Autor | Zpráva | ||
---|---|---|---|
stanislav.strnad@gmail.com Profil |
#1 · Zasláno: 23. 3. 2014, 22:00:20 · Upravil/a: Moderátor (editace znemožněna) 24. 3. 2014, 07:38:21
Dobrý den,
snažím se vytvořit integritní ošetření s FOREIGN KEY, bohužel je mi neustále vyhazována chyba, přitom mám zato, že jsem vše ošetřil podle pravidel. Budu rád za jakoukoliv radu, níže uvádím tabulky: jeste pro doplnění chyba, kterou mi vyhazuje PhpMyAdmin #1005 - Can't create table 'd34480_kultura.STAT' (errno: 150) create table STAT ( id_statu tinyint primary key auto_increment, nazev_statu char (30) unique not null, hl_mesto char (20) not null, rozloha int not null, prezident char (30) not null, pocet_obyvatel int not null, predvolba smallint not null, tel_pol smallint not null, tel_san smallint not null, tel_has smallint not null, cas_vlozeni datetime not null, id_statusu tinyint, id_meny tinyint, id_rezimu tinyint, id_kontinentu tinyint, id_podnebi tinyint, prezdivka varchar (10), FOREIGN KEY (id_statusu) references STATUS (id_statusu), FOREIGN KEY (id_meny) references MENA (id_meny), FOREIGN KEY (id_rezimu) references REZIM (id_rezimu), FOREIGN KEY (id_kontinentu) references KONTINENT (id_kontinentu), FOREIGN KEY (id_podnebi) references PODNEBI (id_podnebi), FOREIGN KEY (prezdivka) references UZIVATEL(prezdivka) ) engine=InnoDB; create table STATUS( id_statusu tinyint primary key auto_increment, status char (20) unique not null ) engine=InnoDB; create table REZIM ( id_rezimu tinyint primary key auto_increment, nazev_rezimu varchar (35) unique not null ) engine=InnoDB; create table KONTINENT ( id_kontinentu tinyint primary key auto_increment, nazev_kontinentu char (20) unique not null ) engine=InnoDB; create table MENA ( id_meny tinyint primary key auto_increment, nazev_meny char (20) unique not null ) engine=InnoDB; create table UZIVATEL ( prezdivka varchar (10) primary key, jmeno char (20) not null, prijmeni char (20) not null, titul_pred char (20) not null, titul_za char (20) not null, email char (50) not null, heslo varchar (40) not null, id_typu_uzivatele tinyint not null references TYP_UZIVATELE (id_typ_uzivatele), id_kraje tinyint not null references KRAJE (id_kraje) ) engine=InnoDB; create table PODNEBI ( id_podnebi tinyint primary key auto_increment, nazev_podnebi char (25) unique not null ) engine=InnoDB; Moderátor Kajman: Vkládej prosím kódy mezi značky [>pre] a [>/pre] (stačí kliknout na ).
|
||
Kajman Profil |
#2 · Zasláno: 24. 3. 2014, 07:39:16
Nejdříve si vytvořte tabulky pro ty číselníky. Teprve poté můžete udělat cizí klíč, který je využívá.
|
||
Časová prodleva: 10 let
|
0