I'm new to db design and have a couple of problems.
I have a job title field in 3 data tables and need to use a validation table to limit the range of values. My question: Do I need to create a separate validation table for each of the data tables, or can I use only one and link it to all the 3 data tables?
Another question: Is it better to have an optional Health Professional field set to Null for a Trainees table, or would you recommend to have a validation table with two values:ye开发者_StackOverflow社区s,no.
Do I need to create a separate validation table for each of the data tables, or can I use only one and link it to all the 3 data tables?
Use one. Each of the other three tables can set a foreign key reference to it.
Is it better to have an optional Health Professional field set to Null for a Trainees table, or would you recommend to have a validation table with two values:yes,no.
Neither. I think this is a better approach.
- Use a Boolean column.
- Declare it to be
NOT NULL
. - Set a default value. Use the most common for your app, either
DEFAULT TRUE
orDEFAULT FALSE
.
If you can design without NULLs, you're usually better off.
Validate all string values before insert data into the db, if you're using php consider using:
$cc = "1234567891234567";
$max_size = 16;
$string_size = strlen($cc);
if($cc > $max_size )
{
echo "your string must be < than $max_size characters";
}
精彩评论