• 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

[URLyBird] Question about data file!

 
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all, in the instruction file I receive from Sun, I see both the field length (specified explicitly such as: name - 64, size - 4, smoking - 1), and the schema description which allows me to get the length of the field programmatically:
---------------------------
Schema description section.
Repeated for each field in a record:
2 byte numeric, length in bytes of field name
n bytes (defined by previous entry), field name
2 byte numeric, field length in bytes
end of repeating block
---------------------------

My question is that since I can determine the fields' lengths by examine the schema description, why on earth they already explicitly show me that name is of length 64, smoking is of length 1 and so on??? Should I just use one mechanism, either use constants or read the schema, to extract the fields' values and ignore the other?
 
Ranch Hand
Posts: 918
IntelliJ IDE Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Leo


The schema description vary from a file to an other - more simpe you can have different database file with different (data) scheme.
If the database format changes in the future your applcation must be flexible enought to support this changes with minimal (or preferable with none) code changing.
The docuement from sun presents the actual database form but as I said this can change in the future.

Regards Mihai
[ April 10, 2006: Message edited by: Mihai Radulescu ]
 
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Its a design decision you need to make.
Using constants is easier, but will require program changes if the database changes.
Using the schema description may allow the program to continue to work if the database changes, but such design will be complex. I said may because you have to ask yourself, would you be able to anticipate all possible database changes and properly design and code for them?
 
Leo Ho
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks, Mihai & Chen. I guess I would use the schema instead of the constants.

Leo
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic