Results 1 to 12 of 12

Thread: Access Primany Key question

  1. #1

    Thread Starter
    Addicted Member GenocideOwl's Avatar
    Join Date
    Jul 2006
    Location
    Ohio
    Posts
    144

    Resolved Access Primany Key question

    so I want my database to be naturally ordered by company then product. Problem is companies own multiple products and products can be owned by different companies. Thus I can't set the primary key to Company like I want to.
    How do I make my table ordanize by company?
    Last edited by GenocideOwl; Jul 12th, 2006 at 09:24 AM.

  2. #2
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Re: Access Primany Key question

    Company should be the first column in this table.

    Product should be the second column.

    The primary key should be both of these two columns - a two segment primary key.

    Is that what you mean?

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

  3. #3

    Thread Starter
    Addicted Member GenocideOwl's Avatar
    Join Date
    Jul 2006
    Location
    Ohio
    Posts
    144

    Re: Access Primany Key question

    how do you do a mutli-segment primary key?

  4. #4
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Re: Access Primany Key question

    Sorry - I'm MS SQL SERVER - not ACCESS - so I can't specifically answer that question - are you using a GUI or wizard to create the table?

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

  5. #5

    Thread Starter
    Addicted Member GenocideOwl's Avatar
    Join Date
    Jul 2006
    Location
    Ohio
    Posts
    144

    Re: Access Primany Key question

    I use the "Create table is Design View" option

  6. #6
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: Access Primany Key question

    Select the two Columns and hit the Primary Key Button.

    Having Said that.... would it make more sence to normalize it a little and have a Company table and then a Product table? .... eh... but then Company name would get duplicated in the Product table.... is there other info about the Company that you track other than the name, like addresses or phone numbers? If so, then it might make sense to use two tables, other wise, just use one, and a composite key.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  7. #7
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Re: Access Primany Key question

    TG - I was just about to PM you - thought you might know the ACCESS answer to this question...

    I assumed that there was only a CUSTOMER ID in this table - I agree with you that a separate table for customer demographic data makes sense if it's needed.

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

  8. #8

    Thread Starter
    Addicted Member GenocideOwl's Avatar
    Join Date
    Jul 2006
    Location
    Ohio
    Posts
    144

    Re: Access Primany Key question

    actually they will be organized by three total things, Company - Product - Barge product came on
    Barge is always unique, but I want Company then product to be the main way of sorting the list

  9. #9
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: Access Primany Key question

    If all you are looking for is sorting, then add a ORDER BY clause to the end of your SELECTS. Don't rely on keys to do that for you automagicaly, you'll never get the result you want. KEys don't sort.... only CLUSTERED INDEXes will sort the data, but that's only because it physically moves the data into order... but again, that's a poor way to default the sort order. Your best action for sorting is to add a ORDER BY clause.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  10. #10

    Thread Starter
    Addicted Member GenocideOwl's Avatar
    Join Date
    Jul 2006
    Location
    Ohio
    Posts
    144

    Re: Access Primany Key question

    I don't know a lot about access...so how do you add a "by order" to it?
    I have all the various keys set to index

  11. #11
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: Access Primany Key question

    It would be part of your SELECT statement, not part of the table design.

    How are you selecting your data to display?

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  12. #12

    Thread Starter
    Addicted Member GenocideOwl's Avatar
    Join Date
    Jul 2006
    Location
    Ohio
    Posts
    144

    Re: Access Primany Key question

    I don't know what you mean by "select statement" really

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width