Re: Primary Key and Unique Key

Tech-Archive recommends: Speed Up your PC by fixing your registry

From: argusy (argusy_at_slmember.on.net)
Date: 08/23/04

  • Next message: Lishi Liu [MSFT]: "RE: Primary Key and Unique Key"
    Date: Mon, 23 Aug 2004 21:43:02 +0930
    
    

    yes.
    You might get garbage, but you can relate any key to any field in any other table.
    i.e.
    T1

    ID (autonumber) primary, unique
    ClassID (number) not unique
    StudentID (number) unique
    surname (text) no key
    Firstname (text) no key

    T2

    ID (number) primary, unique
    subject (text) not unique

    I could relate T1 studentID with T2 classID, but that would be stupid
    I could relate T1 ID with T2 studentID, (again stupid)
    I could relate T1 classID with T2 ID, and this WOULD be useful

    none (except one is declared as "primary")

    The primary key is the one you've declared as primary.
    (It may or may not be unique, but always take the view that any primary key you declare IS
    unique)

    Argusy

    fniles wrote:
    > Thanks. I am still confused.
    > So, does it mean that both primary key and unique keys
    > can also be related to other tables ?
    > So, what are the difference between the two keys ?
    > What are the difference between primary key and the
    > secondary keys ?
    > Thanks.
    >
    >
    >>-----Original Message-----
    >>"Fie Fie Niles" <fniles@wincitesystems.com> wrote in
    >
    > message
    >
    >>news:%23tvz2UwhEHA.704@TK2MSFTNGP12.phx.gbl
    >>
    >>>Is it correct that primary key can be related to other
    >>
    > tables, but
    >
    >>>unique keys don't ?
    >>
    >>No
    >>
    >>--
    >>Reply to the group so all can participate
    >>VB.Net... just say "No"
    >>
    >>.
    >>
    >


  • Next message: Lishi Liu [MSFT]: "RE: Primary Key and Unique Key"

    Relevant Pages

    • Re: Help with indexes on a query
      ... All tables in a relational model should have a primary key. ... since you didn't declare a PRIMARY KEY or UNIQUE constraint ... who should know the data), I guess that the combination of VorderingId, ... defining a primary key or unique constraint always ...
      (microsoft.public.sqlserver.server)
    • Re: Student Sport Database - advice on my design, please?
      ... StudentID AUTOINCREMENT PRIMARY KEY ... ,StudentSurname VARCHAR NOT NULL ... AcademicYear VARCHAR NOT NULL PRIMARY KEY ... REFERENCES tblAcademicYears (AcademicYear) ...
      (microsoft.public.access.tablesdbdesign)
    • Re: Adding Records to Sub-Form by Default
      ... When I click to add a new record, the 1st table will be all blanks for user ... StudentID <Primary Key> ... StudentID <foreign key link to Students> ...
      (microsoft.public.access.formscoding)
    • Re: From varchar(max) to xml
      ... this thing together on SQL 2000. ... ADD CONSTRAINT PK_Numbers PRIMARY KEY ... CREATE TABLE TestInput(INT PRIMARY KEY, ... DECLARE @temp_str VARCHAR ...
      (microsoft.public.sqlserver.xml)
    • Re: For John Vinson - Continued from Dee
      ... >>I'm unclear about the two field primary key. ... if either StudentID or CourseID is ... > wouldn't want an enrollment record which enrolls a student in no class ...
      (microsoft.public.access.gettingstarted)