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. movement of foreign key

movement of foreign key

Scheduled Pinned Locked Moved Database
question
2 Posts 2 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.
  • M Offline
    M Offline
    Member 11418769
    wrote on last edited by
    #1

    i have three tables 1) products ======================= with following columns: product_id product_cat product_cat_brand product title product_price product_image product_Category ======================= with following columns cat_id cat_title product_Brand ======================= with following columns: brand_id brand_title =============== Question???: ================ so my question is: which table will receive the foreign key of which other table? or in other words how i can make relations between these tables..

    L 1 Reply Last reply
    0
    • M Member 11418769

      i have three tables 1) products ======================= with following columns: product_id product_cat product_cat_brand product title product_price product_image product_Category ======================= with following columns cat_id cat_title product_Brand ======================= with following columns: brand_id brand_title =============== Question???: ================ so my question is: which table will receive the foreign key of which other table? or in other words how i can make relations between these tables..

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      From what you show only the following can be done/makes sense:

      products
      (
      ....
      CONSTRAINT FK_products_cat FOREIGN KEY (product_cat) REFERENCES product_Category(cat_id)
      )

      You need to think again about the layout. It seems that products needs something like product_Brand instead of product_cat_brand. In case this assumption is right then:

      products
      (
      ....
      CONSTRAINT FK_products_cat FOREIGN KEY (product_cat) REFERENCES product_Category(cat_id)
      CONSTRAINT FK_products_brand FOREIGN KEY (product_brand) REFERENCES product_Brand(brand_id)
      )

      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