• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

B&S: reimplement the database?

 
Javier Corral
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I'm reading my assignment and I'm confused about the structure of the datafile I received. In one section of the assignment I get the Data file format as a dynamic structure of fields. And in another section I get the Database schema, where each field is explicitly specified. Before that, my assignment says that I must reimplement the database code from scratch. I'm wondering whether I must create a dynamic database manager (with all the complexity this implies) or if I can access the data file knowing previously each field. I think, perhaps Sun want's me to know the Data file format just for keeping the structure of the file without altering it.

I'm happy if somebody could bring me some idea.

thanks.
[ August 12, 2007: Message edited by: Javier Corral ]
 
Nina Binde
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Javier,

I guess what you are talking about is the way they have it in the assignment under the following headers as "Data File Format" and the "Database Schema". Both should be describing the same. The "Database Schema" is the detailed form of the "Schema Description section" of the "Data File Format". I hope that is what you asked for.
 
Javier Corral
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you,

I still have one doubt. Should I read the header file although I can manage the database without do it?. The assignment says I must reimplement the database code but I don't find other 'musts' that specify if I'm expected to read the header structure.

thanks again.
 
Romeo Son
Ranch Hand
Posts: 92
Android Eclipse IDE Suse
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Javier,

Your records in the data access file come after the header. So whenever you read/write a record in the database file, you need to skip that header to position your file-pointer properly. So I think you would want to cache it in the memory, so that every time you want to position your file-pointer offset, you will need to skip the header in the file.
The alternative would be to manually calculate it looking at the specification and use that hard coded value, which is not very nice, but I think you will not loose points if you follow this approach.

Regards,
Romeo
 
Gabriel Vargas
Ranch Hand
Posts: 145
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Javier,

I agree with Romeo, we must read all this header information before read the data so why don�t make a read of header in a proper way. I think the use of hardcoded data when is not necesary is a bad practice, it limits usage of the code and difficults in a greater way the maintanibility of the application and later the code would be replaced if a change. I make a helper class to make this read of header and also data and this didn't increase complexity of the application compared with the object oriented implementation obtained.

I hope it helps you.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic