News for hackers. Stuff that matters.
Re:A terrible schema from a clueless programmer by ryukafalz on Sunday November 07, 2021 @11:53AM (#29141092)
What issues did you run into? Having admittedly never done this before, it feels like whenever you need the dotted-quad IP you could just query:

    SELECT INET_NTOA(ip) FROM ips WHERE...
...in MySQL at least. (Which might be why MySQL has this function built in?)

I guess if you ever need to match on a specific prefix storing the numeric IP might be an issue?

Re:A terrible schema from a clueless programmer by Ginden on Sunday November 07, 2021 @12:22PM (#29141384)
> I guess if you ever need to match on a specific prefix storing the numeric IP might be an issue?

If you want to search for range, you can do:

   SELECT INET_NTOA(ip) FROM ips WHERE ip > INET_NTOA(:startOfRange) AND ip < INET_NTOA(:endOfRange)
Re:A terrible schema from a clueless programmer by soheil on Sunday November 07, 2021 @12:12PM (#29141274)
Because as shocking as this might sound like unlike the characters in the movie Matrix I don't have a built-in INET_NTOA function in my retina to see the string form of the IP addresses when glancing at table rows of a large table looking for patterns or a certain IP.
Re:A terrible schema from a clueless programmer by ryukafalz on Sunday November 07, 2021 @12:53PM (#29141711)
How often are you looking at the full contents of a table vs. looking at the results of a query that you could throw an INET_NTOA onto?
Re:A terrible schema from a clueless programmer by soheil on Sunday November 07, 2021 @02:07PM (#29142436)
Many. You also expect me to remember how to spell INET_NTOA and on what fields to use it on. What if I wanted do a quick "SELECT * FROM"? I barely know how to spell English words what makes you think I'm going to remember how to spell INET_NTOA.
Re:A terrible schema from a clueless programmer by Lammy on Sunday November 07, 2021 @03:29PM (#29143209)
I realize you’re describing a general problem and not just this particular example, but fwiw NTOA and friends got a lot easier for me once I learned enough that I stopped trying to “remember how to spell” them and started thinking about them in terms of the underlying concepts, like “Network (as in big-endianness) to ASCII”. Learning the significance of the term “address family” was a big clue for me for self-directed learning in this space :)
Re:A terrible schema from a clueless programmer by mixmastamyk on Sunday November 07, 2021 @05:04PM (#29143950)
dbeaver CE is free.