Ask Me Help Desk

Ask Me Help Desk (https://www.askmehelpdesk.com/forum.php)
-   Access (https://www.askmehelpdesk.com/forumdisplay.php?f=441)
-   -   Need help creating a relationship in Access 2010 (https://www.askmehelpdesk.com/showthread.php?t=516778)

  • Oct 14, 2010, 04:53 PM
    cajalat
    Need help creating a relationship in Access 2010
    Hi all,

    I'm trying to build an access db (I don't know access very well) to keep track of my rechargeable batteries (geeky I know). Here are my tables:

    BatteryType: Just contains the different types of batteries available
    Inventory: contains batterytype, serial number, purchase date, etc
    ChargeHistory: for each inventory item I keep track of when charged, how charged (break-in, refresh, normal), etc

    The above is all good (I think). The last table is where I'm having a difficult time figuring out. My last table is called Electronics. I have all sorts of devices in the house that use the above batteries... remote controls, toys (tons of those), smoke detectors, game consoles, etc. So of these electronic devices use 1xAA, 2xAA, 3xAAA, 2xAAA, 1x9V, etc... you get the idea.

    My question is, how do I design that last table where say a particular toy that takes 4xAA has specific AA's from the Inventory table... i.e. I serialize my batteries.

    Any help greatly appreciated.
  • Oct 14, 2010, 05:03 PM
    ScottGem

    You need another table like so:

    Tblbatteryusage
    BatteryUsageID (PK Autonumber)
    DeviceID (foreign key)
    BatteryID (FK)

    This will allow you to keep track of each battery used in a device.
  • Oct 14, 2010, 05:20 PM
    cajalat
    Quote:

    Originally Posted by ScottGem View Post
    you need another table like so:

    tblbatteryusage
    BatteryUsageID (PK Autonumber)
    DeviceID (foreign key)
    BatteryID (FK)

    This will allow you to keep track of each battery used in a device.

    Thanks Scott... so let me see if I understand this correctly. (again I JUST started to learn access about 3 days ago). Do I create the table above as a join table where I still have an Electronics Table and Inventory Table and a typical tblbatteryusage would have a record like this:

    BatteryUsageID, DeviceID, BatteryID
    Autonumber, Toy1, Serial1_for_batt
    Autonumber, Toy1, Serial2_for_batt
    Autonumber, Toy1, Serial3_for_batt

    How do I limit or control how many Batteries Toy1 gets for instance if only it can take 2 batteries?

    Casey
  • Oct 14, 2010, 05:29 PM
    ScottGem

    I thought that name sounded familiar. Welcome back.

    I would include a separate field in the device table for the # of batteries. Then you can use that to limit the number of records for a given device.
  • Oct 14, 2010, 05:40 PM
    cajalat
    Quote:

    Originally Posted by ScottGem View Post
    I thought that name sounded familiar. Welcome back.

    I would include a separate field in the device table for the # of batteries. Then you can use that to limit the number of records for a given device.

    Thanks Scott. Hopefully this time I'll stick around longer before I get snagged by uncle sam again :)

    I'll try your suggestion and see how far I can go.

    Casey

  • All times are GMT -7. The time now is 03:03 AM.