[Pharo-project] relational database and id field

Alexandre Bergel alexandre.bergel at me.com
Thu Apr 7 15:49:11 CEST 2011

> Normally, you should always have a primary key to uniquely identify a record in a database table.  If you have an attribute (or a set of attributes) that can uniquely identify your ComicBook, you don't need an id field.  BUT, if you tell me you're going to store lots and lots and lots of those ComicBook instances, having an id (integer) as the primary key has potential non-negligeable advantages over, say, something like a name.  Mainly because an id (let's suppose it's an INT) takes way less storage than say a name (VARCHAR(30) for instance) and thus more index records can fit into the key buffer in memory.

Ok, I understand.

> 1) yes, always provide a primary key
> 2) if you have already A primary key (even a composite one)
>     2a) if you need performance and are gonna store LOTS of those objects, the smaller the key the better so you could create a surrogate key (the id key) instead of using the "real" primary key
>     2b) if performance is not an issue, you can use what is already available that uniquely identifies your object (row) in the database table


> P.S.  Are you using a particular OO-RDBMS framework?  

No, I am correcting a student thesis :-)
I would probably not use SQL if I had to :-)


> -----------------
> Benoit St-Jean
> Yahoo! Messenger: bstjean
> A standpoint is an intellectual horizon of radius zero.
> (Albert Einstein)
> From: Alexandre Bergel <alexandre.bergel at me.com>
> To: Pharo Development <Pharo-project at lists.gforge.inria.fr>
> Sent: Thu, April 7, 2011 9:19:03 AM
> Subject: [Pharo-project] relational database and id field
> Hi!
> Since there are some experts in databases here, I ask a general question about it.
> Assume that I have to use a relational database to store, let's stay instances of Stef's ComicBook class.
> Should the class ComicBook have a field id to uniquely identify a book?
> Cheers,
> Alexandre
> -- 
> _,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:
> Alexandre Bergel  http://www.bergel.eu
> ^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;.

Alexandre Bergel  http://www.bergel.eu

More information about the Pharo-project mailing list