Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

how to update a list of items? design question

 
Peter Primrose
Ranch Hand
Posts: 755
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I have a 2 tables with the following columns:
Table_A
IdA, Name

Table_B
IdB, IdA, car_number


say there's the following properties:
Table_A
IdA, Name
1 Toyota

Table_B
IdB, IdA, car_number
1 1 101
2 1 102
3 1 109
4 1 230
5 1 343
.
.

GUI: the data in table_b (the car_number) is given as textArea and the user write just numbers inside (100,101...)

Q: say the user returns to the textArea (data already existed in db and the user returns to edit/update the data) and made some changes example deleted number 101 and added 554 and 212

How can I make an UPDATE if I don't have the idBs (there are only numbers in the textArea)? *Assuming I can save an old version of the car_numbers with the idea, how do I still make an update?

thanks for any pointers
 
Jeanne Boyarsky
author & internet detective
Sheriff
Posts: 35977
422
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Peter,
There are two approaches. You can save the ids in a map in memory. Or you can look up the id in the database based on car number.
 
Peter Primrose
Ranch Hand
Posts: 755
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what if I do this:
I Delete all old info and Insert the new one. it will work but is there a trade off for that?
 
D Rog
Ranch Hand
Posts: 472
Linux Objective C Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What other queries do you do against these tables? Because i do not see any reason of having separate ids for every car number.

Regarding delete and re-insert. You can try to add a columnt last, and do a simple update of records setting for new records last to 1 and for old to 0. If you have more records, then you had, then switch to insert mode. I do not see benefits of this approach, however it works in some of my systems.
 
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!