MySQL Forums
Forum List  »  Newbie

need help with cross referenced tables
Posted by: Noober Bad
Date: May 21, 2009 07:06AM

I have set of records where when users selects particular records the i insert all the record ids to new table(A) with with category id

Table A

id --- record_id---category_id --

With every record_id there are many small tasks associated (1 to many).
SO based upon inserted record_ids i also insert task_id in Table B

Table B

id-----record_id-------Task_id -----category_id

This is when user creating new category

THe problem is when user want to edit the category and selects different record_ids , then i have two solutions

1)Either delete all records with that category_id and insert new record ids

But then i also have to delete Table B records also

2) Second is check if record is already there if not inseret it otherwise update it.
But how will i delete those records which were previously present but not now

e,g Initially i had Record_ids = 3,4,5,6,7
New Record_ids = 1,2,3,4

Now i want to add 1,2 and delete 5,6,7 from table
Also i don't know how to deal with Table B task which are realted to those records

Because i have to delete tasks related to record_d , 5,6,7 and then insert tasks for record_id 1,2

Any help please

Also if user has not chnaged anhthing then i don't want that first i should delete all the records and then again insert it

so please help me

Options: ReplyQuote

Written By
need help with cross referenced tables
May 21, 2009 07:06AM

Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.