Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. 1:1 Relationships

1:1 Relationships

Scheduled Pinned Locked Moved Database
saleshelpquestion
6 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    Brendan Vogt
    wrote on last edited by
    #1

    Hi, I'm a little confused with my table relationships. I have a Customer table and Title table. Title is something like Mr., or Miss., etc. I have a foreign key reference in the Customer table to the Title. How would I read this relation. ...for each customer there is only 1 title, and for each title there is only one customer, or ...for each customer there is only 1 title, and for each title there is one or many customers?? This is a 1:1 relation, or 1:M? Please help. Regards

    J R S 3 Replies Last reply
    0
    • B Brendan Vogt

      Hi, I'm a little confused with my table relationships. I have a Customer table and Title table. Title is something like Mr., or Miss., etc. I have a foreign key reference in the Customer table to the Title. How would I read this relation. ...for each customer there is only 1 title, and for each title there is only one customer, or ...for each customer there is only 1 title, and for each title there is one or many customers?? This is a 1:1 relation, or 1:M? Please help. Regards

      J Offline
      J Offline
      John Gathogo
      wrote on last edited by
      #2

      This is how you read: For each customer you can only have one title, and for each title you can have one or more customers.

      1 Reply Last reply
      0
      • B Brendan Vogt

        Hi, I'm a little confused with my table relationships. I have a Customer table and Title table. Title is something like Mr., or Miss., etc. I have a foreign key reference in the Customer table to the Title. How would I read this relation. ...for each customer there is only 1 title, and for each title there is only one customer, or ...for each customer there is only 1 title, and for each title there is one or many customers?? This is a 1:1 relation, or 1:M? Please help. Regards

        R Offline
        R Offline
        Rob Philpott
        wrote on last edited by
        #3

        As John says, a foreign key provides a one-to-many relationship. A one-to-one relationship doesn't make much sense as you may as well combine the tables into one. I'm not sure you can even create such a relationship because you'd have to simultaneously insert into both tables in order not to break the constraint. Anyone?

        Regards, Rob Philpott.

        C 1 Reply Last reply
        0
        • R Rob Philpott

          As John says, a foreign key provides a one-to-many relationship. A one-to-one relationship doesn't make much sense as you may as well combine the tables into one. I'm not sure you can even create such a relationship because you'd have to simultaneously insert into both tables in order not to break the constraint. Anyone?

          Regards, Rob Philpott.

          C Offline
          C Offline
          Colin Angus Mackay
          wrote on last edited by
          #4

          Rob Philpott wrote:

          A one-to-one relationship doesn't make much sense as you may as well combine the tables into one. I'm not sure you can even create such a relationship because you'd have to simultaneously insert into both tables in order not to break the constraint. Anyone?

          1-to-1 relationships can make sense in some circumstances when dealing with optimisation of very large rows, especially if some of the columns are only very rarely neaded. It is also useful when dealing with joining separately maintained systems that need to keep in sync (e.g. if you buy in a third party system and want to extend it without touching its database tables) Typically it would actually be a zero-to-one because you insert one row then they other. Parent ------ ID PK Col1 Col2 Col3 Child ----- ID PK FK Col4 Col5 Col6 The Child row is optional, but there can be only one as its primary key is also the foreign key (which forces the oneness of the relationship)


          Upcoming FREE developer events: * Glasgow: SQL Server Managed Objects AND Reporting Services ... My website

          1 Reply Last reply
          0
          • B Brendan Vogt

            Hi, I'm a little confused with my table relationships. I have a Customer table and Title table. Title is something like Mr., or Miss., etc. I have a foreign key reference in the Customer table to the Title. How would I read this relation. ...for each customer there is only 1 title, and for each title there is only one customer, or ...for each customer there is only 1 title, and for each title there is one or many customers?? This is a 1:1 relation, or 1:M? Please help. Regards

            S Offline
            S Offline
            Skanless
            wrote on last edited by
            #5

            This is a 1:M relationship. The reason being that you can have many Mr. or Mrs. Customers but a customer can only be ONE either Mr. or Mrs. Anyone???

            Skan If you knew it would not compile why didn't you tell me?!?!?!

            C 1 Reply Last reply
            0
            • S Skanless

              This is a 1:M relationship. The reason being that you can have many Mr. or Mrs. Customers but a customer can only be ONE either Mr. or Mrs. Anyone???

              Skan If you knew it would not compile why didn't you tell me?!?!?!

              C Offline
              C Offline
              Colin Angus Mackay
              wrote on last edited by
              #6

              Skanless wrote:

              Anyone???

              Do you mean other than the two people who answered the question before you?


              Upcoming FREE developer events: * Glasgow: SQL Server Managed Objects AND Reporting Services ... My website

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups