31 messages in com.googlegroups.pylons-discussRe: sqlalchemy and threadlocal docs o...| From | Sent On | Attachments |
|---|---|---|
| Michael Bayer | 18 Sep 2006 21:50 | |
| Jamie Wilkinson | 18 Sep 2006 22:34 | |
| Alexandre CONRAD | 19 Sep 2006 01:51 | |
| Bayle | 19 Sep 2006 19:45 | |
| Joe | 19 Sep 2006 20:19 | |
| Larry | 19 Sep 2006 20:51 | |
| Joe | 19 Sep 2006 21:29 | |
| Larry | 20 Sep 2006 04:32 | |
| Joe | 20 Sep 2006 07:36 | |
| Michael Bayer | 20 Sep 2006 09:50 | |
| James Gardner | 23 Sep 2006 19:01 | |
| James Gardner | 24 Sep 2006 07:45 | |
| ben adam | 24 Sep 2006 10:28 | |
| ben adam | 24 Sep 2006 10:32 | |
| Sergey Lipnevich | 24 Sep 2006 14:48 | |
| James Gardner | 25 Sep 2006 02:48 | |
| James Gardner | 25 Sep 2006 02:52 | |
| Alexandre CONRAD | 25 Sep 2006 10:54 | |
| Daniel Lyons | 25 Sep 2006 12:43 | |
| Joe | 25 Sep 2006 18:55 | |
| wyatt-bC | 25 Sep 2006 21:43 | |
| John_Nowlan | 26 Sep 2006 09:22 | |
| James Gardner | 27 Sep 2006 05:46 | |
| James Gardner | 27 Sep 2006 05:55 | |
| Michael G. Noll | 29 Sep 2006 07:40 | |
| kevin | 02 Oct 2006 04:22 | |
| owl | 04 Oct 2006 08:31 | |
| paul | 26 Nov 2006 00:17 | |
| Michele Campeotto | 26 Nov 2006 02:40 | |
| Michele Campeotto | 26 Nov 2006 02:46 | |
| paul | 26 Nov 2006 09:19 |
| Subject: | Re: sqlalchemy and threadlocal docs on pylons tutorial![]() |
|---|---|
| From: | Michael Bayer (mike...@zzzcomputing.com) |
| Date: | 09/20/2006 09:50:39 AM |
| List: | com.googlegroups.pylons-discuss |
an important article (well, a blog post that links to an important article) against the usage of surrogate primary keys:
http://spyced.blogspot.com/2006/07/single-column-primary-keys-should- be.html
On Sep 19, 2006, at 11:51 PM, Larry wrote:
Joe wrote:
<snip> it is generally preferable to use "natural" or "standard" IDs as primary keys. Since the page title in the wiki is unique it's a "natural" choice. <snip>
Joe
For almost every project where we used natural primary keys, I've needed to later add some utility to allow the user to alter them. This code needs to look accross every table that reference this primary key and alter it there. Running it without concurrency problems is difficult and so dealing with the entire issue is just extra work and a headache. It also introduces another user interface element that I have to train to users (key changes must be done in single user mode using this special key change menu item, blah-blah-blah). So a while back, I switched to never using natural primary keys. I've also heard that integers are more efficient but it's not the reason I use them.
Surogate primary keys are also the most common pattern I see from experienced DBAs/developers/teams. SQLObject even defaults that way not because it is more simple, but I suspect because Ian and others must think it is good practice.
Even on the wikipedia page you reference, it says, "Having the key independent of all other columns insulates the database relationships from changes in data values or database design (making your database more agile) and guarantees uniqueness. Some database designers use surrogate keys religiously regardless of the suitability of other candidate keys, while others will use a key already present in the data, if there is one."
That said, I don't like my tools to place unecessary restrictions on me. I like that SQLAlchemy will work equally well with databases that I designed years ago, before I saw the light and stopped using natural primary keys. I still like to design my database in the database and I find it trivial to manually add my own integer primary keys to every table. I'm more of a fan of autoload=True and SQLSoup than I am of ActiveMapper although I see the advantage of a Django Data Model Driven framework (or TG-FastData) for standing up new systems with no legacy to worry about and I see how ActiveMapper is a necessary part of that. That's just not usually the space where I usually work and SQLAlchemy is the ideal tool for either situation.
Larry Maccherone
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"pylons-discuss" group.
To post to this group, send email to pylo...@googlegroups.com
To unsubscribe from this group, send email to
pylo...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/pylons-discuss
-~----------~----~----~----~------~----~------~--~---




