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 > Schema Relationship Question
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
Schema Relationship Question

Réponse
 
LinkBack Outils de la discussion
Vieux 03/10/2007, 22h47   #1
JamesHoward
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Schema Relationship Question

I have a set of predefined constants with a set of predefined
relationships and am looking for a way to link them if possible to
ensure data integrity.

An example would be if I wanted to keep track of programs I have
written and I have a table Programs with rows operating system type
and programming language. If both operating system type and
programming language are foreign keys to reference tables (just tables
with a primary key and a name to the element they are referencing) is
there a way to ensure data integrity for possible nonsensical pairings
such as programming language c# and operating system unix?

I know that this question isn't specific to MySQL, but I am
implementing my database in MySQL and so a solution, if there is a
clean one must be implementable in MySQL.

Thanks in advance,
Jim Howard

  Réponse avec citation
Vieux 04/10/2007, 00h58   #2
ZeldorBlat
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Schema Relationship Question

On Oct 3, 5:47 pm, JamesHoward <James.w.How...@gmail.com> wrote:
> I have a set of predefined constants with a set of predefined
> relationships and am looking for a way to link them if possible to
> ensure data integrity.
>
> An example would be if I wanted to keep track of programs I have
> written and I have a table Programs with rows operating system type
> and programming language. If both operating system type and
> programming language are foreign keys to reference tables (just tables
> with a primary key and a name to the element they are referencing) is
> there a way to ensure data integrity for possible nonsensical pairings
> such as programming language c# and operating system unix?
>
> I know that this question isn't specific to MySQL, but I am
> implementing my database in MySQL and so a solution, if there is a
> clean one must be implementable in MySQL.
>
> Thanks in advance,
> Jim Howard


Sure -- create a fourth table that lists all the valid pairs of
operating systems and languages. This table would have foreign keys
to the table of operating systems and the table of programming
languages. Then, your programs table would have a foreign key to this
table instead (foreign key constraints can span multiple columns).

  Réponse avec citation
Vieux 05/10/2007, 18h41   #3
JamesHoward
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Schema Relationship Question

On Oct 3, 5:58 pm, ZeldorBlat <zeldorb...@gmail.com> wrote:
> On Oct 3, 5:47 pm, JamesHoward <James.w.How...@gmail.com> wrote:
>
>
>
> > I have a set of predefined constants with a set of predefined
> > relationships and am looking for a way to link them if possible to
> > ensure data integrity.

>
> > An example would be if I wanted to keep track of programs I have
> > written and I have a table Programs with rows operating system type
> > and programming language. If both operating system type and
> > programming language are foreign keys to reference tables (just tables
> > with a primary key and a name to the element they are referencing) is
> > there a way to ensure data integrity for possible nonsensical pairings
> > such as programming language c# and operating system unix?

>
> > I know that this question isn't specific to MySQL, but I am
> > implementing my database in MySQL and so a solution, if there is a
> > clean one must be implementable in MySQL.

>
> > Thanks in advance,
> > Jim Howard

>
> Sure -- create a fourth table that lists all the valid pairs of
> operating systems and languages. This table would have foreign keys
> to the table of operating systems and the table of programming
> languages. Then, your programs table would have a foreign key to this
> table instead (foreign key constraints can span multiple columns).


Thanks. I am going to give that a shot!

Jim

  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 13h01.


Édité par : vBulletin® version 3.7.2
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
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,11667 seconds with 11 queries