R
Randall Parker
I am designing a database schema. It happens to be in MySQL but I'm trying to keep it
portable to other databases should the project grow.
Anyway, suppose you have VARCHAR fields and will be using ASP.Net and ADO.Net. In
your experience does it make more sense to allow NULL values for VARCHAR fields or
will they behave well and get set to zero length strings when a user doesn't fill in
a text field?
I'm wondering if I should do:
myfield VARCHAR(200) DEFAULT NULL,
or
myfield VARCHAR(200) NOT NULL DEFAULT "",
I'd rather do the latter. NULL is just one more thing to check for and I'd rather
just check for a zero length string when I'm reading stuff out of the database.
Anyone find the best practice here differs depending on the database chosen or the
front-end layers being used to build on it?
portable to other databases should the project grow.
Anyway, suppose you have VARCHAR fields and will be using ASP.Net and ADO.Net. In
your experience does it make more sense to allow NULL values for VARCHAR fields or
will they behave well and get set to zero length strings when a user doesn't fill in
a text field?
I'm wondering if I should do:
myfield VARCHAR(200) DEFAULT NULL,
or
myfield VARCHAR(200) NOT NULL DEFAULT "",
I'd rather do the latter. NULL is just one more thing to check for and I'd rather
just check for a zero length string when I'm reading stuff out of the database.
Anyone find the best practice here differs depending on the database chosen or the
front-end layers being used to build on it?