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

 
Liviu Carausu
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
I have a question regarding the database schema. On one side, the database schema is fixed, described in the section "Database schema". On the other side, in the "Data File Format" it is specified how to read the length of each field. Is it legal to use the hardcoded field lengths or they must be read from database ?
Thanks,
Liviu
 
K. Tsang
Bartender
Posts: 3585
16
Android Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In my opinion, you should read the field's length from the file header. The header also contains the magic cookie value, the fields' header names etc.

Since you need to read the cookie value anyway why not read the whole header.
 
Liviu Carausu
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi K,
Thanks for you answer . What are you doing with the field names read from the database ?
Are you comparing them with the field names specified in the database schema ?
My specifications says " Record containing fields in order specified in schema section".
Are you checking the field names read from db against db schema ? A kind of magic cookie to
check if the database file is correct ?
Thanks,
Liviu
 
K. Tsang
Bartender
Posts: 3585
16
Android Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well I don't really do anything with the field names once I read it. But that may change, I may use it for the JTable headings. From the file header, all I cared about is the fields' length, overall length per record, number of fields and the position of the first record. I store these as instance variables in my Data class.

For the magic cookie value once you know what it is, you simply check it whenever you read the file header. People usually read the value once or twice say when client connects or before some methods.

Hope this helps.
 
mohamed sulibi
Ranch Hand
Posts: 169
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi;

i dynamically read the field size and name from the database file; but i sew users ware hardcoded these values and get complete marked. don't forget to document your decision about this. you can search about post that describe this idea.

regards.
 
Roberto Perillo
Bartender
Posts: 2271
3
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is it legal to use the hardcoded field lengths or they must be read from database ?


I hardcoded everything
 
Jeffry Kristianto Yanuar
Ranch Hand
Posts: 759
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I also hardcoded everything in the database schema like magic cookies, fields length, etc. Except I didn't harcoded the database name, I just harcoded the default database that could be change in the JTextField.

In my networking code, I didn't harcoded the port number.


Good Luck !!!


Jeffry Kristianto Yanuar (Java Instructor) SCJP 5.0, SCJA, SCJD (UrlyBird 1.3.2)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic