Issue with Foreign Keys

  • So recently I began to start a personal project to push my limits and try to gain an edge on database work. I have been using MySQL and I am using IonnDB to make use of the Foreign Key relational system. I wrote a long document of tables that I could copy and paste to create the required tables needed so I could look at everything at once and feel confident I hadn't missed anything. I ensured that all the tables were in a ladder format to prevent an error by setting a Foreign Key constraint to a table that doesn't exist yet, and I made sure that all the fields were correctly filled out. I continue to receive this following error though.

    #1005 - Can't create table houl.account_network (errno: 150 "Foreign key constraint is incorrectly formed")

    The issue is that I have scanned the entire internet for possible issues and resolutions and even went as far as to rewrite every table manually and enter them into the database one by one but the issue never seemed to disappear. So maybe you guys can figure out the issue, but I'm beginning to figure that it's an issue with IonnDB engine or MySQL. The link to the Pastebin containing all the databases is directly below this.

    https://pastebin.com/d9c4sx68

  • Pay attention to details:

    CREATE TABLE accounts (

    ID INT(11) NOT NULL AUTO_INCREMENT,

    CONSTRAINT FK_SESSION_HISTORY_ACCOUNT FOREIGN KEY(ACCOUNT) REFERENCES account(ID) ON DELETE CASCADE ON UPDATE RESTRICT,

    There is not table "account" in your setup.

    _____________
    Code for TallyGenerator

  • Just an FYI but SSC (SQL Server Central) is a (Microsoft) SQL Server based community; although many will have experience in MySQL (not myself), if you are asking specifically about MySQL you have technically come to the wrong place. 🙂 Certainly posting a MySQL question in the SQL Server 2019 is the wrong place, and you'd be better off asking in MySQL if you are asking on SSC.

    For more complex questions, you may struggle to get an answer here and would be better off asking on a site that is more MySQL focused, or less specifically about SQL Server, instead.

    Thom~

    Excuse my typos and sometimes awful grammar. My fingers work faster than my brain does.
    Larnu.uk

  • Although, we do have a MySQL forum. It doesn't get much love though. I'd post any further MySQL questions there. You're more likely to get people who know about it and can help.

    "The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
    - Theodore Roosevelt

    Author of:
    SQL Server Execution Plans
    SQL Server Query Performance Tuning

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply