danaketh wrote:
> This is solved by using FOREIGN KEY but I'm not sure if MySQL have
> them present or just planned for some future release.
>
> mrfroasty napsal(a):
>> I am quite new to database designs, I have a problem in my design...I
>> can actually feel it, but I am not quite sure if there is a feature in
>> mysql or I have to solve it with programming.
>>
>> Example:
>> CREATE TABLE A (
>>                 user_id int(16) NOT NULL auto_increment,
>>                 ..........other datas
>>                 PRIMARY KEY (user_id)
>>                );
>>
>> CREATE TABLE B (
>>                 user_id int(16) NOT NULL auto_increment,
>>                 ..............other datas
>>                 PRIMARY KEY (contact_id)
>>             );
>>
>> Question:
>> How can I declare that the user_id in my 1st table is related to user_id
>> in the 2nd table...actually I prefer to have it exactly the same user_id
>> in both tables....I think if those 2 entries are the same it will be
>> great, but I am not sure how to achieve this.
>>
>> P:S
>> -Ofcourse I know that I can extract it from TABLE A and save it in TABLE
>> B....but is that a way to go???Because this issue arise in couple of
>> tables in my data structure that I am tending to use in my application(web).
>> -I also know that its possible to  make just 1 big table with lots of
>> columns....but I read its not a good database design...
>>
>> ----->>>>>please advice, running out of ideas :-(
>>
>> Thanks......
>>
>>
>>   
>
> -- 
>
> S pozdravem
>
> Daniel Tlach
> Freelance webdeveloper
>
> Email: [EMAIL PROTECTED]
> ICQ: 160914875
> MSN: [EMAIL PROTECTED]
> Jabber: [EMAIL PROTECTED]

Thanks for the input...after some small research I came across this link
http://articles.techrepublic.com.com/5100-10878_11-6035435.html
....after that I changed my database to something similar to :

CREATE TABLE user_profile (
                             user_id int(16) NOT NULL auto_increment,
                   ................other datas
                PRIMARY KEY (user_id)
               )ENGINE=INNODB;

CREATE TABLE user_contact (
                user_id int(16) NOT NULL auto_increment,
                ..................other datas
                INDEX (user_id),
                FOREIGN KEY (user_id) REFERENCES user_profile (user_id),
                PRIMARY KEY (user_id)
            ) ENGINE=INNODB;

That I think problem solved for now...thanks alot :-)

-- 
Extra details:
OSS:Gentoo Linux-2.6.25-r8
profile:x86
Hardware:msi geforce 8600GT asus p5k-se
location:/home/muhsin
language(s):C/C++,VB,VHDL,bash
Typo:40WPM
url:http://mambo-tech.net


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to