Results 1 to 9 of 9
  1. #1
    anonymust's Avatar
    anonymust is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2013
    Location
    Home
    Posts
    9

    Question Same Items Different Keys?


    How can I make a relationship / table with two item that are the same?

    I'm making a database with items found in my local supermarkets.


    and two supermarkets sell the same package of frozen salmon, but they have different barcodes

  2. #2
    JoeyB is offline Advanced Beginner
    Windows 8 Access 2013
    Join Date
    Nov 2013
    Location
    The Netherlands / Australia
    Posts
    54
    Give your products a ID number.
    Make a separate table for barcodes and give these barcodes the ID numbers from the products. Now more barcodes are related to one product.

    hope it helps

  3. #3
    Demerit's Avatar
    Demerit is offline Competent Performer
    Windows 7 32bit Access 2007
    Join Date
    Nov 2013
    Posts
    125

    You may do this

    Create two tables as JoeyB said Say:

    TblProducts
    ProductID Autonumber
    ProductName Text
    BarcodeID Number


    TblBarcode
    BarcodeID Autonumber
    BarcodeName Text or Number

    Link the two tables using BarcodeID and enforce refferential intergrity

    Hope it helps

  4. #4
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows XP Access 2003
    Join Date
    Aug 2013
    Posts
    7,862
    @ Demerit,

    Your solution would create unnecessary records in tblProducts. The OP states that products with the same description have many barcodes.

  5. #5
    Demerit's Avatar
    Demerit is offline Competent Performer
    Windows 7 32bit Access 2007
    Join Date
    Nov 2013
    Posts
    125
    If that is the case, then a Foreign key "ProductID" should be added to TblBarcodes on which the relationship should b created. And BarcodeID should be deleted from TblProducts.

  6. #6
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    You'll need three tables to handle your need:

    1. A PRODUCT table (autonumber PK is fine) along with any information you want to record
    2. A STORES table (autonumber PK is fine) along with any store related information
    3. A BARCODES table (autonumber PK is fine as well) a FK to the PRODUCT table, a FK to the STORES table along with the barcode information

    the barcodes table is known as JUNCTION table where you are forcing a relationship between two tables that are not linked directly through an intermediary table.

    This is the same type of structure I've been trying to get across to Demerit on his own project

  7. #7
    anonymust's Avatar
    anonymust is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2013
    Location
    Home
    Posts
    9
    I think I just realized my DB is pretty much useless....

    I found that out today when I was scanning the barcode on some banana's that I has to weighed.
    Now I have to codes for Banana's.. because the barcode i scanned was the supermarkets code (both codes from the same supermarket) and I cant figure out how the barcode is encoded.

    Its not a duplicate barcode, but it will be a double entry for banana's in my DB

    I need to redesign my DB from the group back up again.

  8. #8
    anonymust's Avatar
    anonymust is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2013
    Location
    Home
    Posts
    9
    Quote Originally Posted by JoeyB View Post
    Give your products a ID number.
    Make a separate table for barcodes and give these barcodes the ID numbers from the products. Now more barcodes are related to one product.

    hope it helps
    I was thinking about that, but I will be using a form along with my USB lazer barcode reader when filling in data

  9. #9
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows XP Access 2003
    Join Date
    Aug 2013
    Posts
    7,862
    Quote Originally Posted by anonymust View Post

    Its not a duplicate barcode, but it will be a double entry for banana's in my DB
    Post #6 addresses this issue. Make a special table to manage your barcodes. Each barcode record can have an FK for your product description and an FK for the product's respective store. No duplicate barcodes, but you can have many unique barcodes associated with one product from a single store. This should address the issue you are having with bananas.

    The trick is building a form that is flexible enough to manage updating and querying the tables.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Registry keys
    By ashu.doc in forum Access
    Replies: 1
    Last Post: 10-27-2012, 12:19 AM
  2. question about keys
    By johny in forum Access
    Replies: 3
    Last Post: 03-24-2012, 06:57 AM
  3. Need help with foreign keys
    By acdougla17 in forum Access
    Replies: 1
    Last Post: 09-26-2011, 03:50 PM
  4. Items With Which items Most Commonly
    By vansicklej in forum Access
    Replies: 3
    Last Post: 08-10-2011, 11:05 AM
  5. Tab or Enter keys
    By rwatkins in forum Forms
    Replies: 3
    Last Post: 05-11-2011, 03:22 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums