Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

[URLyBird 1.3.3] - What if I need to create new record without deleted flag?

 
RIO YOU
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Simply,

1. No Longer exist deleted flag record section.
########################################################################
I understand reuse the deleted flag tuple to insert new data.

When i need to create new another record more and more when there is no longer exist deleted flag record section.

Increate the data file? or throw DuplicateException?
########################################################################


2. Is it possible locking whole database file during accessing database?
########################################################################
Is it possible locking whole database file during accessing database?
or should I implement locking algorithm for each record?
########################################################################

Any comments could be happy for me. ^^
 
Jeroen T Wenting
Ranch Hand
Posts: 1847
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what do you think?
How do you think Oracle (for example) handles such situations? Does it give you an error when you try to insert a record into a new table?
 
Oricio Ocle
Ranch Hand
Posts: 284
Debian Firefox Browser Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In your specifications. Read carefully method comments in the interface.
What they mean?
 
Anton Golovin
Ranch Hand
Posts: 527
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by RIO YOU:
Simply,

1. No Longer exist deleted flag record section.
########################################################################
I understand reuse the deleted flag tuple to insert new data.

When i need to create new another record more and more when there is no longer exist deleted flag record section.

Increate the data file? or throw DuplicateException?
########################################################################


2. Is it possible locking whole database file during accessing database?
########################################################################
Is it possible locking whole database file during accessing database?
or should I implement locking algorithm for each record?
########################################################################

Any comments could be happy for me. ^^


The problem one should consider is what happens if the computer should suddenly crush? This in my view should determine how data gets handled.

You can avoid the problem if you resolve to return a success message on any IO operation only after the IO operation was done.

That said, you can keep a list of the numbers of deleted records in memory, provided you change the list only after successful IO. That way, you do not have to re-read the database file for every record you want to replace. It is faster to cache the deleted-records numbers.

Why am I saying all this? So that you apply the same to the solution to your question.

When you run out of the deleted records, you should append a new record at the end of the file. To do that safely, you need to lock the file. To write anything to a file, you need to lock the file.

Thankfully, the exam lets you get away with assuming only one thread can access the database file at one time. So you can just lock the whole file and not worry about read/write distinc operations.
 
Adam Nace
Ranch Hand
Posts: 117
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by RIO YOU:
Simply,

1. No Longer exist deleted flag record section.
########################################################################
I understand reuse the deleted flag tuple to insert new data.

When i need to create new another record more and more when there is no longer exist deleted flag record section.

Increate the data file? or throw DuplicateException?
########################################################################


2. Is it possible locking whole database file during accessing database?
########################################################################
Is it possible locking whole database file during accessing database?
or should I implement locking algorithm for each record?
########################################################################

Any comments could be happy for me. ^^


1. I would just append new records to the end of the file. Note, however, that this may require you to perform defragmenting and shrinking occasionally, as your database might start to get sparse if too many records are deleted without being replaced (I'm not sure if the graders will really be picky on this point, however. Anybody else know about this?)

2. I would lock at the record level if possible. What if three clients all want access to different records: Then if you lock the whole database, the second and third must all wait for the first to get an unrelated record.

In general, to achieve the highest parallelism, you want to synchronized the narrowest scope possible

- Adam
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic