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

database schema B&S

 
Dan Murphy
Ranch Hand
Posts: 126
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

The database schema is described in the header of the database file. Although you could read this to determine:

- the name of each field
- the length of each field

I don't see the point, because the assignment actually tells you what these are. Is there any good reason why I should use the information in the file header to determine the schema, rather than the information in the assignment?

Also, the assignament says:

"all fields (which are text only), contain only 8 bit characters, null terminated if less than the maximum length for the field. The character encoding is 8 bit US ASCII"

Do I need to do some sort of conversion (to UNICODE) after reading a field?

Cheers,
Dan
 
Ed Villamizar
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Dan Murphy:

I don't see the point, because the assignment actually tells you what these are. Is there any good reason why I should use the information in the file header to determine the schema, rather than the information in the assignment?


Dan,
You are right, you can just skip the header and get the records from the offset point they start at.

There are a few reasons you might want to actually read and use information in the header:

- To check the magic cookie value if you choose to.
- To make your application more flexible. You can actually dynamically build your GUI even after adding some fields to the data file but this is not a requirement though.
- To check that the file is actually a data file. I used this approach to detect when a file selected by the user wasn't a data file with the expected format. For example if the length of a field name or the length of the fields themselves are negative or excessively big (say > 500) then an exception is thrown.

Ed

[ April 01, 2005: Message edited by: Ed Villamizar ]
[ April 01, 2005: Message edited by: Ed Villamizar ]
 
Dan Murphy
Ranch Hand
Posts: 126
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

There are a few reasons you might want to actually read and use information in the header:

- To check the magic cookie value if you choose to.
...
- To check that the file is actually a data file. I used this approach to detect when a file selected by the user wasn't a data file with the expected format. For example if the length of a field name or the length of the fields themselves are negative or excessively big (say > 500) then an exception is thrown.


Thanks for your respose Ed! The above reasons for reading the header seem similar to me - the purpose of both is to ensure that the file you're reading is actually a data file.


- To make your application more flexible. You can actually dynamically build your GUI even after adding some fields to the data file but this is not a requirement though.

Dynamically building your GUI from the header seems to be way beyond the scope of the assignment, and would introduce a lot of complexity which you probably would not get any extra credit for.

Given that Sun have gone to the trouble to describe the format of the header, I feel that I should read it. But as I already know what it contains (from the description of the schema) I can't think of a good reason why. I'd be very interested to know what others think about this.

Cheers,
Dan
 
Darya Akbari
Ranch Hand
Posts: 1855
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Dan,

I only use the data file format provided in the assignment description. I have Bodgitt & Scarper version 2.1.3

The reason I do it is simply because I imagine that the data file itslef can be replaced by another (this time maybe with another schema). And since the schema information is contained in the data file format description I prefer only this.

Nevertheless it's a good feeling once you parsed through your db file to have the same resulting schema as described in the database schema

Regards,
Darya
 
Dan Murphy
Ranch Hand
Posts: 126
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Instead of building your schema from the file header, you could use the schema provided in the assignment description, but check the header to ensure that the schema described therein is the schema as that in the assignment description. If not, show a message box indicating a fatal error and exit the application.

What about this?

Cheers,
D´┐Żnal
 
Darya Akbari
Ranch Hand
Posts: 1855
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, that's a good idea too. Taking the given database schema as reference and as soon as the given data file does not confirm to the schema you throw an exception for the user.

Regards,
Darya
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic