• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

DB Create/Update/Delete

 
Tim Fernandez
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

DO you think this approach is ok?

Create -> add record at the bottom or replace a deleted record
Update -> delete record (set delete flag to 1) and add updated record
Delete -> delete record (set delete flag to 1)

regards,
Tim
 
Jan Groth
Ranch Hand
Posts: 456
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi tim,

maybe i'm overlooking something, but i cannot see why you should want to split "update" into "delete" & "create" (assuming that your lock mechanism works ... ;-) )
a simple lock-change-unlock will do the same, don't you think?

plus (better: minus): an updated record can have a new number / position in the data file. this would make the algorithm unneccesary complicated. you'll be glad about consistent record numbers when it comes to gui-handling...

the rest is okay, obviously.

many greetings,
jan
 
Tim Fernandez
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jan,

Thanks for the reply!
If this is the case,then im gonna do something
like this instead,

readByte(); for the flag
writeBytes(String) -> Does this overwrite the existing
string in the file or does it insert this to the file and move
the existing ones to another location in the file?

regards,
Tim
 
Jan Groth
Ranch Hand
Posts: 456
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi tim,

well, i used a RandomAccessFile, it's pretty simple: you jump to a position and write the next bytes, overwritting whatever was there before.

i'm sure there are different ways, but i found this one most suitable ;-)

greetings,
jan
 
Tim Fernandez
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Jan,

Yah, I tried using RandomAccessFile and it overwrites it.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic