hi, i am a newbie to databases.
I have a table called ' records'.
with fields as
id bios computer ram CDROM
id is the primary key of the table 'records'.. Now each id is also related to other id(s) of the same table.. like
like id=3 can be related to id=4,5,6,7,8 ... How can i store this information records table.. Currently i am adding a new column in table 'records' names as related_entries and storing the related ids and comma seperated. is this a good approach..?? or there is some better ways.. i want this schema to be very good use of db concepts..
id bios computer ram CDROM related_entries
3 OK OK OK OK 4,5,6,7,8,9,0
4 OK OK OK OK 7,3,5,6,7
5 OK OK OK OK 55,22,33,2
thanking in anticipation.
regards.
help: mapping ER to database
Moderator: General Moderators
Re: help: mapping ER to database
No, it's not a good approach.ijlal2 wrote:Currently i am adding a new column in table 'records' names as related_entries and storing the related ids and comma seperated. is this a good approach..?? or there is some better ways.. i want this schema to be very good use of db concepts..
You should remove the column and create a new table related_records instead.
The table should look like this:
Code: Select all
records_id (int)
related_records_id (int)If you have record with id=1 and related records with id=2,4 then:
records table
Code: Select all
id | ....
1 | ....
2 | ....
3 | ....
4 | ....Code: Select all
records_id | related_records_id
1 | 2
1 | 4There are 10 types of people in this world, those who understand binary and those who don't
Re: help: mapping ER to database
thanks VladSun. Thats nice.