• 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

Database schema

 
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Bartender
Posts: 3648
16
Android Mac OS X Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 3648
16
Android Mac OS X Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 169
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Bartender
Posts: 2292
3
Eclipse IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Is it legal to use the hardcoded field lengths or they must be read from database ?



I hardcoded everything
 
Ranch Hand
Posts: 759
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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)
 
brevity is the soul of wit - shakepeare. Tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic