Re: using UID in DB
| From: | Paul M Foster | Date: | Wed, 31 Mar 2010 02:37:28 +0000 |
| Subject: | Re: using UID in DB | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-303636@lists.php.net to get a copy of this message | ||
On Tue, Mar 30, 2010 at 02:18:53PM -0700, Tommy Pham wrote:
> On Tue, Mar 30, 2010 at 2:04 PM, Paul M Foster <paulf@quillandmouse.com> wrote:
> > On Tue, Mar 30, 2010 at 01:36:27PM -0700, Tommy Pham wrote:
> >
> >> Hi,
> >>
> >> I'm just wondering if anyone on this list using some type of
> >> UID/UUID/GUID in any of the DB? If so, what DBMS/RDBMS are you using
> >> and how many rows do you have for the table(s) using it? What data
> >> type are you using for that column?
> >
> > If I understand you correctly, I use a single table, "users". Either
> > MySQL or PostgreSQL (depending on the application). There is one record
> > per user, and that record contains a serial/sequential ID, set by the
> > system, a user ID which is varchar(8), email address which is
> > varchar(255), username which is varchar(50) and a password which is
> > varchar(32) and stored encrypted.
> >
>
> Hi Paul,
>
> In the case of mysql, it would be UUID and the value would look like this:
>
> 22ea1df1-3c40-11df-ab7a-200cd91e08cf
>
> and the case of postgresql,
>
> A0EEBC99-9C0B-4EF8-BB6D-6BB9BD380A11
> {a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11}
> a0eebc999c0b4ef8bb6d6bb9bd380a11
>
> which is 36 CHAR length (including dashes not braces) and is not quite
> like identity insert (autoincrement). You could store it as
> binary(16) - in mysql - but you'll need to implement UDFs to convert
> between binary & char. Is that what you're using? or Are you using an
> INT type?
Unless you have some compelling need to store a number like this, I
don't see the need to. What I store is what is called in PostgreSQL a
"serial" value. MySQL calls it "auto_increment". You store all the other
values as a row, and the DBMS adds in the "auto_increment"/"serial"
value for you. It's an integer, *usually* one larger than the last value
entered.
Paul
--
Paul M. Foster