• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

DB Create/Update/Delete

 
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 456
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Jan,

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