PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > comp.databases.mysql > Unable to create referential integrity
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
Unable to create referential integrity

Réponse
 
LinkBack Outils de la discussion
Vieux 04/11/2007, 15h21   #1
jackal_on_work@yahoo.com
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Unable to create referential integrity

Hi Group,
I have two tables, emp and dept. The dept uses the MYISAM storage
engine and emp uses the INNODB one.

create table dept
(
deptno int primary key,
dept_name varchar(100)
) engine = MYISAM;


create table emp
(
empno int primary key,
ename varchar(100),
deptno int references dept(deptno)
)engine = INNODB;

Now when I try to create the emp table, I find that the foreign key
constraint doesnt get created. I know the fact that MYISAM tables dont
support constraints(correct me if I am wrong), which happens to be the
dept table in my case. But that should not prevent me creating the
referential constraint on my emp table.

If this doesnt work out, do I need to use triggers? Please suggest.


Thanks in advance
Jackal

  Réponse avec citation
Vieux 04/11/2007, 16h29   #2
Paul Lautman
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Unable to create referential integrity

jackal_on_work@yahoo.com wrote:
> Now when I try to create the emp table, I find that the foreign key
> constraint doesnt get created. I know the fact that MYISAM tables dont
> support constraints(correct me if I am wrong), which happens to be the
> dept table in my case. But that should not prevent me creating the
> referential constraint on my emp table.

Why shouldn't it? The referential constraint is operated between the tables,
if one of them doesn't support the constraint I would expect that fact to
prevent it.


  Réponse avec citation
Vieux 04/11/2007, 17h54   #3
Rik Wasmus
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Unable to create referential integrity

On Sun, 04 Nov 2007 15:21:32 +0100, <jackal_on_work@yahoo.com> wrote:

> Hi Group,
> I have two tables, emp and dept. The dept uses the MYISAM storage
> engine and emp uses the INNODB one.
>
> create table dept
> (
> deptno int primary key,
> dept_name varchar(100)
> ) engine = MYISAM;
>
>
> create table emp
> (
> empno int primary key,
> ename varchar(100),
> deptno int references dept(deptno)
> )engine = INNODB;
>
> Now when I try to create the emp table, I find that the foreign key
> constraint doesnt get created. I know the fact that MYISAM tables dont
> support constraints(correct me if I am wrong), which happens to be the
> dept table in my case. But that should not prevent me creating the
> referential constraint on my emp table.


It does prevent it. Just make you dept table INNODB too.
--
Rik Wasmus
  Réponse avec citation
Vieux 05/11/2007, 06h44   #4
jackal_on_work@yahoo.com
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Unable to create referential integrity

Thanks Rick, for the reply. But the challenge here is that the dept
table is being used for Full Text search.

On Nov 4, 9:54 pm, "Rik Wasmus" <luiheidsgoe...@hotmail.com> wrote:
> On Sun, 04 Nov 2007 15:21:32 +0100, <jackal_on_w...@yahoo.com> wrote:
> > Hi Group,
> > I have two tables, emp and dept. The dept uses the MYISAM storage
> > engine and emp uses the INNODB one.

>
> > create table dept
> > (
> > deptno int primary key,
> > dept_name varchar(100)
> > ) engine = MYISAM;

>
> > create table emp
> > (
> > empno int primary key,
> > ename varchar(100),
> > deptno int references dept(deptno)
> > )engine = INNODB;

>
> > Now when I try to create the emp table, I find that the foreign key
> > constraint doesnt get created. I know the fact that MYISAM tables dont
> > support constraints(correct me if I am wrong), which happens to be the
> > dept table in my case. But that should not prevent me creating the
> > referential constraint on my emp table.

>
> It does prevent it. Just make you dept table INNODB too.
> --
> Rik Wasmus- Hide quoted text -
>
> - Show quoted text -



  Réponse avec citation
Vieux 05/11/2007, 11h31   #5
Martijn Tonies
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Unable to create referential integrity

> Thanks Rick, for the reply. But the challenge here is that the dept
> table is being used for Full Text search.


In that case, welcome to MySQL where different storage engines
have different features :-)


--
Martijn Tonies
Database Workbench - development tool for MySQL, and more!
Upscene Productions
http://www.upscene.com
My thoughts:
http://blog.upscene.com/martijn/
Database development questions? Check the forum!
http://www.databasedevelopmentforum.com


  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 01h50.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,12792 seconds with 13 queries