Friday, October 8, 2010

Created and loaded data into tables

Done:

1) Created two tables:

Stores IP numbers and locId:
CREATE TABLE ipNumbers (ipNum BIGINT NOT NULL,
locId INTEGER NOT NULL,
PRIMARY KEY (ipNum))

Stores test IP addresses and IP numbers:
CREATE TABLE testCensusIPs (ipAddr VARCHAR(15) NOT NULL,
ipNum BIGINT NOT NULL,
PRIMARY KEY (ipAddr))

2) Loaded test data into table testCensusIPs

3) Wrote Java program to test data (insert IP numbers and locId into table ipNumbers). Need debug.

2 comments:

  1. I have a question about the IP address. Currently you are storing the IP address as a varchar(15). One problem with varchars is that they are fairly poor in terms of lookup when you are searching the table for an entry. It would be better to have an int instead of a varchar. While you might want to store the varchar as a separate piece of data, is it possible to use an int for lookup purposes?

    We have had two possible solutions to this problem:

    1) convert the IP to an INT using the following equation:

    if IP = A.B.C.D then int = A*(256^3) + B*(256^2) + C*256 + D

    2) mask the ip address as an int:

    if IP = A.B.C.D then int = 1AAABBBCCCDDD

    For example, 131.162.34.56 = 1131162034056 (leading zeros are important for parsing purposes).

    darcy

    ReplyDelete
  2. Yea, I am trying to convert the IP to an INT by suing the solution one.
    There is a code from Amanda which converts IP to number. I will check if I could use it.

    ReplyDelete