Click here to Skip to main content
15,889,878 members
Home / Discussions / Database
   

Database

 
GeneralRe: string truncation Pin
Luc Pattyn9-Nov-11 11:24
sitebuilderLuc Pattyn9-Nov-11 11:24 
GeneralRe: string truncation Pin
SilimSayo9-Nov-11 14:59
SilimSayo9-Nov-11 14:59 
AnswerRe: string truncation Pin
Luc Pattyn9-Nov-11 15:11
sitebuilderLuc Pattyn9-Nov-11 15:11 
GeneralRe: string truncation Pin
_Damian S_9-Nov-11 15:22
professional_Damian S_9-Nov-11 15:22 
AnswerRe: string truncation Pin
Luc Pattyn9-Nov-11 15:34
sitebuilderLuc Pattyn9-Nov-11 15:34 
GeneralRe: string truncation Pin
_Damian S_9-Nov-11 15:56
professional_Damian S_9-Nov-11 15:56 
GeneralRe: string truncation Pin
Luc Pattyn9-Nov-11 16:08
sitebuilderLuc Pattyn9-Nov-11 16:08 
GeneralRe: string truncation Pin
jschell10-Nov-11 8:27
jschell10-Nov-11 8:27 
Luc Pattyn wrote:
One way to remedy the situation would be to populate, at start-up, some data
structures describing all relevant field widths, and pass this to the GUI stuff,
so it can check all the lengths and warn the user, before attempting an
insert/update. However that seems more effort than elegance, hence me asking
about some best practices and/or easy solutions.


Generate the database API from the database schema.

At the same time, and in a different API, generate validation classes. That includes length validation and not null validations but does NOT include things like foreign key constraints.

The validation classes are used in the database API before attempting to apply the data to the database. They can also be used elsewhere, because they represent their own API.

This idiom probably works better in a standard distributed arch versus stand alone but the idea still applies.

At any rate that is how I do it and have done it that way for years in a variety of different languages.

But that is how I do it so it is "easy".

The "best-practice" is still - validate it. How you achieve the validation and insure its correctness is a different matter.
GeneralRe: string truncation Pin
Luc Pattyn10-Nov-11 9:47
sitebuilderLuc Pattyn10-Nov-11 9:47 
GeneralRe: string truncation Pin
PIEBALDconsult9-Nov-11 15:09
mvePIEBALDconsult9-Nov-11 15:09 
QuestionRe: string truncation Pin
Luc Pattyn9-Nov-11 15:15
sitebuilderLuc Pattyn9-Nov-11 15:15 
AnswerRe: string truncation Pin
PIEBALDconsult9-Nov-11 15:37
mvePIEBALDconsult9-Nov-11 15:37 
GeneralRe: string truncation Pin
Luc Pattyn9-Nov-11 16:02
sitebuilderLuc Pattyn9-Nov-11 16:02 
GeneralRe: string truncation Pin
PIEBALDconsult9-Nov-11 16:08
mvePIEBALDconsult9-Nov-11 16:08 
GeneralRe: string truncation Pin
Luc Pattyn9-Nov-11 16:27
sitebuilderLuc Pattyn9-Nov-11 16:27 
GeneralRe: string truncation Pin
PIEBALDconsult9-Nov-11 16:56
mvePIEBALDconsult9-Nov-11 16:56 
GeneralRe: string truncation Pin
_Damian S_9-Nov-11 16:32
professional_Damian S_9-Nov-11 16:32 
GeneralRe: string truncation Pin
Luc Pattyn9-Nov-11 16:59
sitebuilderLuc Pattyn9-Nov-11 16:59 
GeneralRe: string truncation Pin
jschell10-Nov-11 8:21
jschell10-Nov-11 8:21 
GeneralRe: string truncation Pin
Luc Pattyn10-Nov-11 8:35
sitebuilderLuc Pattyn10-Nov-11 8:35 
AnswerRe: string truncation Pin
PIEBALDconsult9-Nov-11 15:28
mvePIEBALDconsult9-Nov-11 15:28 
AnswerRe: string truncation Pin
Wayne Gaylard9-Nov-11 17:09
professionalWayne Gaylard9-Nov-11 17:09 
AnswerRe: string truncation Pin
Luc Pattyn9-Nov-11 17:28
sitebuilderLuc Pattyn9-Nov-11 17:28 
GeneralRe: string truncation Pin
Wayne Gaylard9-Nov-11 17:42
professionalWayne Gaylard9-Nov-11 17:42 
GeneralRe: string truncation Pin
Luc Pattyn9-Nov-11 17:48
sitebuilderLuc Pattyn9-Nov-11 17:48 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.