• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Database Schema Field length

 
adriano lorentino
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

It's my first post here on this forum. So first I just want to thanks everybody who helps and participates to this place. I'm sure it will be very helpfull for me to achieve this certification!

My question here is about the database schema, and specially the length of each fields. I've seen many example and also found this approach on Andrew Monkhouse's book:

On the model or DTO (For example DVD if we talking about example from the book) there's for each field, an associated FIELD_LENGTH constant that define the max length of the field.

In my opinion I feel this way the model become a little bit heavy, and I would want to extract this informations about the length of each field in an other way.

My idea is to put in a "common" package an Enum that would manage this. For example to have something like that:


Then to get the max value of a field instead of using


you can now just use something like


Just want to have your opinions about this idea, as I don't want to take any risk by doing some risky-non valuable custom solutions that can cost me some precious point to this certification....

Thanks for your help

Adrien
 
Roel De Nijs
Sheriff
Posts: 10662
144
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Adrien,

Welcome to the JavaRanch!

That is a valid approach. You can also opt to read the database schema dynamically, which will make your Data class reusable for other database files.

Kind regards,
Roel
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic