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 > Foreign Key and relationship
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
Foreign Key and relationship

Réponse
 
LinkBack Outils de la discussion
Vieux 05/11/2007, 16h12   #1
N1
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Foreign Key and relationship

I've got some problems understanding how FOREIGN KEY, REFERENCES and
CONSTRAINTS work.
I should not be able to insert data in a column pointed as FOREIGN KEY if
the data is not listed in the column referenced...am I right?

E.g.
- create table One (char character(3) primary key, num numeric(3) foreign
key references Two(x));
- create table two (y character(10) primary key, x numeric(3));

I'd expect to not be able to do something like this
- insert into One values("abc", 123);
if the value "123" is not in Two.x...but I can...what am I missing or
what am I looking for?

Thank everybody.

--
Nuno on zx-6r '04 working in progress...
666 the number of the beast, 70 the number of N1
*** www.gladio.org ***

  Réponse avec citation
Vieux 05/11/2007, 21h55   #2
Kees Nuyt
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Foreign Key and relationship

On Mon, 05 Nov 2007 16:12:20 GMT, N1 <io@me.it> wrote:

>I've got some problems understanding how FOREIGN KEY, REFERENCES and
>CONSTRAINTS work.
>I should not be able to insert data in a column pointed as FOREIGN KEY if
>the data is not listed in the column referenced...am I right?
>
>E.g.
>- create table One (char character(3) primary key, num numeric(3) foreign
>key references Two(x));
>- create table two (y character(10) primary key, x numeric(3));
>
>I'd expect to not be able to do something like this
>- insert into One values("abc", 123);
>if the value "123" is not in Two.x...but I can...what am I missing or
>what am I looking for?
>
>Thank everybody.


Foreign key constraints only work in the InnoDB storage
engine, not MyISAM.
The syntax is accepted for tables with storage engine
MyISAM, but the constraint is not enforced.

HTH
--
( Kees
)
c[_] The amount of time between slipping on the peel and
landing on the pavement is precisely one bananosecond. (#71)
  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 12h04.


É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,15292 seconds with 10 queries