List:General Discussion« Previous MessageNext Message »
From:Jim Lyons Date:May 14 2009 4:11pm
Subject:Re: MAC address as primary key - BIGINT or CHAR(12)
View as plain text  
As I said in my post, this is a general principle for me.  Nominal data
should have a data type of some sort of character.  You will never run into
unexpected  problems  down the line.

On Thu, May 14, 2009 at 11:04 AM, Pete Wilson <pete142@stripped> wrote:

>
>
> I'm new to MySQL so can't answer the OP's question, but:
>
> MAC addresses do not by design contain letters. Native MAC addresses are
> 48-bit (6-byte) integers:
>
>  http://standards.ieee.org/getieee802/download/802-2001.pdf
>
> The confusion arises because a MAC address is usually /represented/ as
>  hexadecimal, and that might contain letters, but MAC addresses natively
>  are pure 6-byte integers.
>
> So the issue is whether you want to index by a 48-bit number or a
> 12-character ascii string. For efficiency's sake, I'm guessing you'd choose
> the former.
>
> I'll be interested in the answer, though, from someone with experience.
>
> -- Pete Wilson
>   http://www.pwilson.net/
>
>
> --- On Thu, 5/14/09, Jim Lyons <jlyons4435@stripped> wrote:
>
> > From: Jim Lyons <jlyons4435@stripped>
> > Subject: Re: MAC address as primary key - BIGINT or CHAR(12)
> > To: "Ilia KATZ" <ikatz@stripped>
> > Cc: mysql@stripped
> > Date: Thursday, May 14, 2009, 11:38 AM
> > Definitely CHAR (or VARCHAR).
> >
> > If the format of a MAC address changes at all, you could be
> > in real
> > trouble.  Also, if a MAC address can have a leading 0
> > (I don't know anything
> > about MAC addresses), then storing it as some sort of
> > number could lose
> > that.
> >
> > This is a general rule for me.  A field might only
> > contain numbers (at one
> > particular point in time)  but if those numbers are
> > really nominal data (in
> > which the size or order does not matter) then they should
> > be CHAR or VARCHAR
> > fields anyway.
> >
> > On Thu, May 14, 2009 at 8:26 AM, Ilia KATZ <ikatz@stripped>
> > wrote:
> >
> > > Hi.
> > > Currently I have a table:
> > > 1. MAC address defined as BIGINT
> > > 2. MAC address set as primary key
> > >
> > > Should I consider changing it to CHAR(12)?
> > >
> > > Replies will be appreciated.
> > > Ilia
> > >
> > >
> > >
> > >
> >
> >
> > --
> > Jim Lyons
> > Web developer / Database administrator
> > http://www.weblyons.com
> >
>
>
>
>


-- 
Jim Lyons
Web developer / Database administrator
http://www.weblyons.com

Thread
MAC address as primary key - BIGINT or CHAR(12)Ilia KATZ14 May
  • Re: MAC address as primary key - BIGINT or CHAR(12)Fish Kungfu14 May
    • Re: MAC address as primary key - BIGINT or CHAR(12)kabel14 May
    • RE: MAC address as primary key - BIGINT or CHAR(12)Ilia KATZ14 May
  • RE: MAC address as primary key - BIGINT or CHAR(12)Jerry Schwartz14 May
  • Re: MAC address as primary key - BIGINT or CHAR(12)Thomas Spahni14 May
  • Re: MAC address as primary key - BIGINT or CHAR(12)Jim Lyons14 May
  • RE: MAC address as primary key - BIGINT or CHAR(12)Daevid Vincent14 May
Re: MAC address as primary key - BIGINT or CHAR(12)Pete Wilson14 May
  • Re: MAC address as primary key - BIGINT or CHAR(12)Jim Lyons14 May
Re: MAC address as primary key - BIGINT or CHAR(12)Pete Wilson14 May
RE: MAC address as primary key - BIGINT or CHAR(12)Gavin Towey15 May
Re: MAC address as primary key - BIGINT or CHAR(12)Gavin Towey15 May