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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T05:44:55+00:00 2026-05-15T05:44:55+00:00

What would be an appropriate way to do this, since mySQL obviously doesnt enjoy

  • 0

What would be an appropriate way to do this, since mySQL obviously doesnt enjoy this.
To leave either partitioning or the foreign keys out from the database design would not seem like a good idea to me. I’ll guess that there is a workaround for this?

Update 03/24:

http://opendba.blogspot.com/2008/10/mysql-partitioned-tables-with-trigger.html

How to handle foreign key while partitioning

Thanks!

  • 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-15T05:44:56+00:00Added an answer on May 15, 2026 at 5:44 am

    It depends on the extent to which the size of rows in the partitioned table is the reason for partitions being necessary.

    If the row size is small and the reason for partitioning is the sheer number of rows, then I’m not sure what you should do.

    If the row size is quite big, then have you considered the following:

    Let P be the partitioned table and F be the table referenced in the would-be foreign key. Create a new table X:

    CREATE TABLE `X` (
        `P_id` INT UNSIGNED NOT NULL,
            -- I'm assuming an INT is adequate, but perhaps
            -- you will actually require a BIGINT
        `F_id` INT UNSIGNED NOT NULL,
        PRIMARY KEY (`P_id`, `F_id`),
        CONSTRAINT `Constr_X_P_fk`
            FOREIGN KEY `P_fk` (`P_id`) REFERENCES `P`.`id`
            ON DELETE CASCADE ON UPDATE RESTRICT,
        CONSTRAINT `Constr_X_F_fk`
            FOREIGN KEY `F_fk` (`F_id`) REFERENCES `F`.`id`
            ON DELETE RESTRICT ON UPDATE RESTRICT
    ) ENGINE=INNODB CHARACTER SET ascii COLLATE ascii_general_ci
    

    and crucially, create a stored procedure for adding rows to table P. Your stored procedure should make certain (use transactions) that whenever a row is added to table P, a corresponding row is added to table X. You must not allow rows to be added to P in the “normal” way! You can only guarantee that referential integrity will be maintained if you keep to using your stored procedure for adding rows. You can freely delete from P in the normal way, though.

    The idea here is that your table X has sufficiently small rows that you should hopefully not need to partition it, even though it has many many rows. The index on the table will nevertheless take up quite a large chunk of memory, I guess.

    Should you need to query P on the foreign key, you will of course query X instead, as that is where the foreign key actually is.

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

Sidebar

Related Questions

Which would be a more appropriate repository to host a small, XCode, Objective-C based
In what situation would it be more appropriate for me to use a bitset
Or would a conventional client-server VCS be more appropriate? I'm currently using TortoiseSVN, but
I would like to change this: // use appropiate lang.xx.php file according to the
What's an appropriate way of measure a PHP objects actual size in bytes/kilobytes? Reason
I am sure there is a good way of solving this, but it's something
I'm having a brain cramp trying to understand the appropriate way to use JGoodies
Initially, I wasn't sure whether this was the appropriate place for this question, but
If I have a json like follows, what would be the most efficient way
I know this might be more appropriate at Ask Different, but as I tried

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.