Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7544649
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T08:43:35+00:00 2026-05-30T08:43:35+00:00

I am trying to understand relationships fully, and have gone through alot of tutorials.

  • 0

I am trying to understand relationships fully, and have gone through alot of tutorials. Still i linger on a few things (using MySQLWORKBENCH):
enter image description here
1. Every user can upload a product
2. Every product can have multiple categories, bids, ratings, etc
3. Every user can have multiple phonenumbers
(there are more, but this is the basic setup)

Is this correct?:
1 – I used a 1:n relationship, since every user can upload multiple products.
2 and 3. I used n:m relationship, since there can be multiple products with multiple categories, bids, ratings, etc.

DELETE/UPDATE:
I used ON UPDATE CASCADE and ON DELETE CASCADE everywhere where there is a foreign key…that being ‘product’, ‘category_tags_has_products’, ‘bid_price_has_product’, ‘phone_has_user’.

I tried to delete a product like this (php): mysql_query(“DELETE FROM product WHERE id=’$id'”);
I get a 1054 error, which is a foreign key error.
What are the best practises here? It is to my understanding that i shouldn’t need to do deletions in any other than the parent-table?

Thanx!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T08:43:37+00:00Added an answer on May 30, 2026 at 8:43 am

    You have a lot of identifying relationships, which mean that the foreign key form part of the primary key on the second table. This is not necessary in most instances, and is only really useful in instances such as link tables.

    To this end I would change the user->product link to be non-identifying, which will make user_id a Foreign Key instead of being part of the Primary Key. In workbench the shortcut for a 1:n non-identifying relationship is key ‘2’ (where as ‘4’ is identifying). This in turn should remove the user_id fields from the tables which product links onto.

    When you delete a product, it should cascade to the 3 link tables that it links to. At present it may be that it is trying to delete from users also depending on how the FK is set up. The following should cascade deletions (assuming a deletion is permanent and you just want to clear out all linked records)

    DELETE FROM product -> deletes from any table with product_id in
    DELETE FROM user -> deletes from any table with user_id in

    The same applies for phone, rating, bid_price, category_tags.

    I hope this if of use, if you need any further pointers feel free to shout 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been trying to follow the few tutorials on how to create a
We are trying to model family relationships using neo4j and would like to understand
I'm trying to verify I understand Core Data relationships and/or possibly how to handle
I am trying understand ViewModels deeper and I have read many articles and blogs
here are some generic tables, I am trying to fully understand how to properly
I am trying to understand some things about jump tables and its relationship between
I'm trying to understand relationships and naturally questions appear. What does referencing table mean
I am trying to understand the 1-to-many relationships in datastore; but I fail to
I'm trying to understand inheritance in JavaScript. I'm using prototype to link a child
I have the following relationships: user.rb has_many :ownerships has_many :restaurants, :through => :ownerships restaurant.rb

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.