I'm going through a bunch of MySQL DB tables. Several of them have a column called 'domain' (web domain name). Some are set as varchar(60), some varchar(90) etc - you get the idea. Consistancy's a little off.
So, as part of my tidying up, I'm ensuring they all get the same definition (erring on the side of caution).
But what I'm wondering is can you (and if not, why not), create a custom data type as a variable somewhere in the database, and then refer to that when defining a commonly used field. ie, something along the lines of (pseudocode!):
DEF $DOMAIN = VARCHAR(90) NOT NULL DEFAULT ''; INFO $DOMAIN = 'website domain name'; DEF $IP = VARCHAR(15) NOT NULL DEFAULT ''; INFO $IP = 'IP4 Address'; # etc, then, when creating tables, use CREATE TABLE vhosts ( domain $DOMAIN_DEF PRIMARY KEY, ip $IP_DEF );
With me so far? Good :)
And then, be able to run some kind of query on the db that would parse all values for fields defined using a definition and report on the *actual* maximum length currently in use (to help with redefining the field definition later).
# pseudo ANALYZE DATA WHERE DEFINITION IS $DOMAIN_DEF;
Another good thingy would be to be able to redefine the definition on the fly, but ONLY if it affected no values (and die listing tables and records that would be affected if values would be changed).
# pseudo UNLESS ERR REDEFINE $DOMAIN_DEF = VARCHAR(80) NOT NULL DEFAULT '';
Do any databases have anything like this? It would just be so useful to have a reference table of definitions and explanations in plain english.
I know I could script a lot of this, but I wondered if there was anything like this already built into any databases.
Or am I just living in my own little dream world .oO(?)
cLive ;-)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: OT: defining DB fields - working towards consistancy...
by Abigail-II (Bishop) on Jul 15, 2003 at 08:44 UTC | |
by cLive ;-) (Prior) on Jul 15, 2003 at 09:03 UTC | |
by rir (Vicar) on Jul 15, 2003 at 17:58 UTC | |
by herveus (Prior) on Jul 16, 2003 at 11:16 UTC | |
by Abigail-II (Bishop) on Jul 16, 2003 at 11:22 UTC | |
|
Re: OT: defining DB fields - working towards consistancy...
by mpeppler (Vicar) on Jul 15, 2003 at 12:23 UTC | |
by cLive ;-) (Prior) on Jul 15, 2003 at 19:54 UTC |