Separate table for IP Addresses??

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ittechguy
    New Member
    • Sep 2015
    • 70

    Separate table for IP Addresses??

    I've never used IP addresses in a database so this has me puzzled. I've done a lot of research and it seems there's many different ways to store IP addresses. Some actually store it as decimal, some as binary. I think my database project is not that large or complicated of a project, so I am planning on just storing IP addresses as text (i.e. 192.168.1.1/24) and require that data be entered in that format before it will write to the table.

    So then, I have a table which stores information about equipment. Then, I have to decide if I want to add 3-4 fields to the equipment table for IP addresses, OR if I want to create another table just for IP addresses and create a one to one relationship between tblEquipment and tblIPAddresses. That is, the PK in tblIPAddresses will be a number (not autonumber) of the FK from tblEquipment.

    In my mind, the reason for me doing this is because an IP address will only ever belong to one piece of equipment at a time. And, it is unique (there will never be duplicates).

    But then I wonder, if i'm using a one to one relationship... should I just put it all in the equipment table? I don't like doing that, because if I think about it, that might make it harder for me to unassign an IP address from one equipment, and assign it to another piece of equipment.
  • NeoPa
    Recognized Expert Moderator MVP
    • Oct 2006
    • 32666

    #2
    First off, as the IPv4 Address value, at its heart, is simply a 32-bit integer, you should probably take advantage of this conversion for any ID field you want to use for them. That's assuming you feel it makes sense to do so at all, of course. Another alternative would be to devise some very simple code to convert from one format to the other and treat it as a simple Long for storage, while displaying it as dot separated string.

    Personally, I see no reason to worry about IP Addresses changing for equipment. People rarely bother to switch out NICs nowadays. They just buy another item with an inbuilt NIC. On the very rare occasions where this does happen then it should be simple enough to update the record for that piece of equipment.

    Comment

    Working...