|
|
|
|
||||||
![]() |
|
|
LinkBack | Outils de la discussion |
|
|
#1 |
|
Messages: n/a
Hébergeur: |
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 |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
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. |
|
![]() |
| Outils de la discussion | |
|
|