0

I am making the database design of my website in Microsoft Access 2013 because it has a nice user interface and I believe it will help me understand everything a whole lot better with the UI.

I have to create a relationship between two fields in one table with one field in the other - have I done this correctly (please see the screen capture below)? If not, what would I do to correct my errors?

enter image description here

Thanks in advance.

3
  • The relationships should reference the primary key of the "ips" table, and the "IP ID" is what should be stored in the referencing columns. Commented Jan 3, 2016 at 4:23
  • 1
    Why have an IP ID? Why not simply use IP as the PK?
    – Rick James
    Commented Jan 3, 2016 at 6:16
  • @RickJames: I want to store someones IP address more than once, just in case it changes (which it probably will). IP ID will auto_increment when I create the MYSQL database, IP will hold the proper IP address. Commented Jan 4, 2016 at 0:15

1 Answer 1

0

I'm with Michael, you should reference the IP ID, not the IP. If you don't link to the primary key, whenever you reference [IP used when creating] or [IP last signin], you are going to get the first record found. e.g. you have multiple records with the same IP in you ips table, you are going to always get the result of the first one. This is why primary keys are so important, they ensure you get the same record every time. If you can assume that a particular IP will always have the same Hostname, Location, Region, etc., then you can sue IP as your reference.

On a side note, if you have to run any SQL or VBA against your database, it's a lot easier if you avoid spaces in your names, use Camel case or something else. e.g. "IP used when creating" should be IPusedWhenCreating. This makes any type of programming a lot easier. I'm very oldschool and I like to keep variables to under 8 characters whenever possible. FirstIP and SecondIP, it just means a LOT less typing.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.