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 6843407
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T00:14:29+00:00 2026-05-27T00:14:29+00:00

The goal: when a User is deleted, all entries for a user in UserCategory

  • 0

The goal: when a User is deleted, all entries for a user in UserCategory should be deleted as well.

The schema:

User:
  actAs: { Timestampable: ~ }
  columns:
    first_name: { type: string(255) }
    name: { type: string(255) }
    company: { type: string(255) }
    email: { type: string(255) }
    phone: { type: string(255) }
    language_id: { type: integer, notnull: true }
    token: { type: string(255) }
    activated: { type: boolean, default: false }
  relations:
    Categories:
       class: Category
       local: user_id
       foreign: category_id
       refClass: UserCategory
       type: many

UserCategory:
  actAs: { Timestampable: ~ }
  columns:
    user_id: { type: integer, notnull: true }
    category_id:      { type: integer, notnull: true }

Category:
  actAs: { Timestampable: ~ }
  columns:
    language_id:  { type: integer, notnull: true }
    name: { type: string(255), notnull: true, unique: false }
    revision: { type: integer, notnull: false }
    icon:     { type: string(255) }
  relations:
    User:
       class: User
       local: category_id
       foreign: user_id
       refClass: UserCategory
       type: many

What happens:

SQLSTATE[23000]: Integrity constraint violation: 1451 Cannot delete or update a parent row: a foreign key constraint fails (testtable.user_category, CONSTRAINT user_category_user_id_user_id FOREIGN KEY (user_id) REFERENCES user (id))

  • 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-27T00:14:29+00:00Added an answer on May 27, 2026 at 12:14 am

    Like greg0ire said, defining a cascade for UserCategory did the job. It missed the relations block entirely:

    UserCategory:
      actAs: { Timestampable: ~ }
      columns:
        user_id: { type: integer, notnull: true }
        category_id:      { type: integer, notnull: true }
      relations:
        User: {onDelete: CASCADE, local: user_id, foreign: id, foreignAlias: Users}
        Category: {onDelete: CASCADE, local: category_id, foreign: id, foreignAlias: Categories}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Goal: The user should not make any changes in the text field in Combobox.
Goal When the user clicks an element (with class="menu" ), the default action should
My goal is logout current session, then delete the running local user profile. And
My goal: the user clicks a button. From the button pops up a two-level
My goal for now is to have a user search for other users who
My goal is to have a user select a year and a month. Translate
My goal is to let the user click on a specific location on a
My goal is to have a jQuery datepicker pop up when the user clicks
My goal: Similarly the Intellisense dropdown in Visual Studio 2008, when the user presses
My goal is to draw a semi-transparent curve. User moves cursor and I draw

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.