( Fi Fie Foe Fum, I smell the blood of a religious war ) On Fri, Nov 16, 2007 at 01:03:23PM -0600, Ron Johnson wrote: > On 11/16/07 12:54, Sam Mason wrote: > > On Fri, Nov 16, 2007 at 03:50:20PM -0300, Jo??o Paulo Zavanela wrote: > >> How many fields is recomended to create a primary key? > >> I'm thinking to create one with 6 fields, is much? > > > > Normally a primary key would just be a single column. When you start > > going to that many I'd probably have a serial column as the primary key, > > and a UNIQUE index on those six fields. Depends on what you're doing, > > though unless you've got a few years experience I'd be tempted to stay > > away from primary keys of more than a single column. > > Fie on you evil synthetic key lovers. Long live the Natural Key! Really? I started off with everything using sequences and everything was good. Then I found I wanted to do more complicated things so I started to transition to natural keys and things were better. Then I took things too far and wanted something artificial back in my life. I'm back to almost never using natural keys now, mainly because interfacing with the outside world gets too complicated. When I'm just doing stuff inside the database then I can use natural keys and all is good, otherwise things just get too complicated. I'll probably look back in another few years and remember how young and naive I was back now. Sam ---------------------------(end of broadcast)--------------------------- TIP 6: explain analyze is your friend