-
March 15th, 2009, 05:26 PM
#1
[MySQL 5.1 & PHP] Proper table relation
What would be a proper design of the relationships for this case?
Table 'one' has column "id", which is primary key and few other columns.
Table 'two' has column "applies", which is primary key and few other columns.
Table 'one' has 10 records / rows with "id"s values:
7
19
18
13
16
15
20
23
24
25
Table 'two' has 5 records / rows with "applies"s values:
15
16
18
23-24-25
7-13-19-20
What this means, for example, is that row with "applies"s value: 7-13-19-20, holds values in columns that are valid / applicable for
rows with "id"s values 7, 13, 19 & 20, from table one.
Rows 7, 13, 19 & 20, are alway joined to row 7-13-19-20.
I need a better way.
How to do it?
HINT: Table 'one' MUST NOT be altered!
Ipsens
-
March 16th, 2009, 05:58 AM
#2
Re: [MySQL 5.1 & PHP] Proper table relation
Hi all.
I don't understant exactly what you mean...
If your problem is to link table two to table one to get one-to-many relationship, you can add the ID column to table two as foreign key for table one.
I hope this will help you.
-
March 16th, 2009, 08:18 AM
#3
Re: [MySQL 5.1 & PHP] Proper table relation
It can't be done, as it would had to be added to table 'one'
And table 'one' has always more rows and few rows from table 'one' are related to ONE row of table 'two'.
So as I can't modify table 'one', I will need to create table 'three', which will only hold information about relations between table 'one' & 'two'.
Is there a better way?
Ipsens
-
March 16th, 2009, 11:47 AM
#4
Re: [MySQL 5.1 & PHP] Proper table relation
I see...
The 1-to many relationship is between table one, which is the "many" side, and table two which is the "one" side of relationship; so you should add a column to table one, but you can't.
In this case you have to create the table three to link table one and two. This is a ugly solution, but I don't see other.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|