• 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 all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
  • Piet Souris
  • salvin francis
  • fred rosenberger

Database Schema Field length

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

Posts: 11604
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • 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,
And tomorrow is the circus! We can go to the circus! I love the circus! We can take this tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
    Bookmark Topic Watch Topic
  • New Topic