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. Database logic...

Database logic...

Scheduled Pinned Locked Moved Database
databasequestion
4 Posts 4 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.
  • K Offline
    K Offline
    KORCARI
    wrote on last edited by
    #1

    I have three different tables in a SQL DB which have at least two common fields amongst each other. Should I just create a new table that is made of these common fields and have these three tables point to it for those fields?

    K M M 3 Replies Last reply
    0
    • K KORCARI

      I have three different tables in a SQL DB which have at least two common fields amongst each other. Should I just create a new table that is made of these common fields and have these three tables point to it for those fields?

      K Offline
      K Offline
      Kschuler
      wrote on last edited by
      #2

      I don't think there is a right or wrong answer to this question. It depends on the data. If the data is vital and it's very important that it's always updated and the same across the three files, you may want to separate and make a fourth table out of it so you only have to update in one location. However, if it's not that vital of information or it very rarely changes you may want to keep it in each file because it's easier to access. Hope this helps.

      1 Reply Last reply
      0
      • K KORCARI

        I have three different tables in a SQL DB which have at least two common fields amongst each other. Should I just create a new table that is made of these common fields and have these three tables point to it for those fields?

        M Offline
        M Offline
        Mark Churchill
        wrote on last edited by
        #3

        Depending on your domain model you could approach this as a reference, or an inheritance relationship. Pick the most appropriate. Reference is say pulling out "Address1, Address2, Address3" into a Address table, and have Customer.Address, Supplier.Address -> Address.ID with a fk relationship. Inheritance is where you take out the Address1-3 columns into a Person table, and have Customer.Id -> Person.ID, and Supplier.ID -> Person.ID. (So every record in supplier or customer must have a record in person - this maps directly to inheritance in your business layer, which can be handy).

        Mark Churchill Director Dunn & Churchill Free Download:
        Diamond Binding: The simple, powerful, reliable, and effective data layer toolkit for Visual Studio.

        1 Reply Last reply
        0
        • K KORCARI

          I have three different tables in a SQL DB which have at least two common fields amongst each other. Should I just create a new table that is made of these common fields and have these three tables point to it for those fields?

          M Offline
          M Offline
          Mycroft Holmes
          wrote on last edited by
          #4

          Read up on Normalisation - this probably going to be the root issue. The common fields in the table should ONLY be IDs, if you are updating data in 3 different tables then your design is wrong.

          Never underestimate the power of human stupidity RAH

          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