d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > Database Relations In Phpmyadmin
Add Reply New Topic New Poll
Member
Posts: 13,446
Joined: Dec 6 2008
Gold: Locked
May 18 2015 09:56am
Hello guys,

maybe someone of you can help me. Already got two different tables inside my database, but I want to make relation between them as "one to many".
They are both on InnoDB engine, but still have no clue how to connect record from table A to 5 records from table B.

Iso help =(

regards!
Member
Posts: 6,481
Joined: Jul 5 2009
Gold: 0.70
May 18 2015 12:27pm
Quote (Nothus @ May 18 2015 11:56am)
Hello guys,

maybe someone of you can help me. Already got two different tables inside my database, but I want to make relation between them as "one to many".
They are both on InnoDB engine, but still have no clue how to connect record from table A to 5 records from table B.

Iso help =(

regards!


I'm not sure I fully understand your problem. Your database doesn't necessarily need to know if the relationship is one to many or many to many or whatever. It's the code you write that controls the relationships.

You will want to set up a foreign key on the child table in question, which I could explain if you had more specifics here.

"mysqldump -d -u <username> -p <username_databasename> > dump.sql" to get a dump if your database if you don't know how.
If you'd rather you can PM me with specifics and I can see if I can help you out.
Member
Posts: 18,620
Joined: Jul 26 2008
Gold: 777.00
May 25 2015 01:14am
my guess is that he's talking about setting up the foreign key constraints..

first set an index on the child table's foreign key
second, set the foreign key constraint to point to the parent table's primary key id
u do that by going to phpmyadmin->relation view on the child table structure, then select the dropdown
that should set a foreign key constraint for your child table

^ one to many can be modeled like this..

parent table
|id|

child table
|id|parent_id|

where parent id points to parent_table.id, that means a parent can have many children

hope that helps! :P

This post was edited by gEckoStar on May 25 2015 01:15am
Go Back To Programming & Development Topic List
Add Reply New Topic New Poll