[ciapug] Best Practice
Claus
ciapug@cialug.org
Mon, 24 Jan 2005 11:08:03 -0600
On 1/24/2005 10:51 AM, Tim Perdue wrote:
> One thing you could do is set the auto-increment to, say, 10 for each of
> the databases. Then, you start each database at a separate number:
> database 1: the IDs start at 1, database 2: the IDs start at 2 and so
> on. With the auto-increment set to 10, each database will have unique
> IDs, so when you blend it back together in the master database, there
> are no conflicts and you can easily tell which DB the data came from
> originally.
>
> That's probably the "best practice" for what you're doing.
>
> Tim
To guarantee the uniqueness/database-identification I'd recommend adding
a column with the server/database name. To encode the database ID in a
record ID is a bad practice in my opinion for multiple reasons:
1) Not easy to understand
2) You are fixed to a max of 10 servers
3) You can't easily query the data by server ID
4) Nobody said there is an auto-increment field.
The bottom line to best practice is to keep it simple. I can recall a
few times where I created really cool code but after something went
wrong and I had to fix it things always turned out to be stupid code;
way to complicated and hard to maintain. At which point I replaced it
with a way shorter, simpler and more effective code.
If the code or database layout is not easy to understand it's no-good.
And don't do more than what is needed otherwise you are just adding
complexity.
Claus