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 for PHP serialized data - possible?
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
Foreign Key for PHP serialized data - possible?

Réponse
 
LinkBack Outils de la discussion
Vieux 05/10/2007, 21h35   #1
Dave
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Foreign Key for PHP serialized data - possible?

Hi,

I have a table1 with a tb1_column that stores PHP serialized data that are
unique integers.
| tb1_column |
-----------
a:5:{i:0;s:1:"9";i:1;s:2:"5";i:2;s:2:"11";i:3;s:2: "100";i:4;s:2:"10";}

I also have a table2 with unique integers (ids) in tb2_column
| tb2_column | descr |
----------
11 | Pears
100 | Plums
9 | Apples
5 | Oranges
10 | Cranberries

What I'm trying to do is to create a foreign key on tb1_column so that if a
number in tb2_column changes or gets deleted, it cascades to the appropriate
segment of the serialized data.
e.g. if an id of Oranges changes from '5' to '24', the tb1_column rows will
get changed in the above example row to:
a:5:{i:0;s:1:"9";i:1;s:2:"24";i:2;s:2:"11";i:3;s:2 :"100";i:4;s:2:"10";}

Is this possible? Can anyone suggest a function that would do that?

Thanks

Dave


  Réponse avec citation
Vieux 05/10/2007, 22h50   #2
Paul Lautman
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Foreign Key for PHP serialized data - possible?

Dave wrote:
> Hi,
>
> I have a table1 with a tb1_column that stores PHP serialized data
> that are unique integers.
>> tb1_column |

> -----------
> a:5:{i:0;s:1:"9";i:1;s:2:"5";i:2;s:2:"11";i:3;s:2: "100";i:4;s:2:"10";}
>
> I also have a table2 with unique integers (ids) in tb2_column
>> tb2_column | descr |

> ----------
> 11 | Pears
> 100 | Plums
> 9 | Apples
> 5 | Oranges
> 10 | Cranberries
>
> What I'm trying to do is to create a foreign key on tb1_column so
> that if a number in tb2_column changes or gets deleted, it cascades
> to the appropriate segment of the serialized data.
> e.g. if an id of Oranges changes from '5' to '24', the tb1_column
> rows will get changed in the above example row to:
> a:5:{i:0;s:1:"9";i:1;s:2:"24";i:2;s:2:"11";i:3;s:2 :"100";i:4;s:2:"10";}
>
> Is this possible? Can anyone suggest a function that would do that?
>
> Thanks
>
> Dave


No that is not how foreign keys work. Using the data like that violates 1NF.
to use advanced facilities like foreign keys and cascade on..., your
database really must be normalised, at least to 1NF on the fields involved
in the relationship.


  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 12h53.


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