Skip to content

Cruddiy: table relationship support via foreign keys

Read here what Cruddiy is and what it can do for you: here is the code.

TLDR: Cruddiy is no-code Bootstrap 4 PHP form builder for MySQL tables.

I started Cruddiy when the Covid-19 lockdowns happened this spring, to keep me busy. And I released it on GitHub. After 25 stars 🤩 and 13 forks on GitHub and a couple of really encouraging messages on the original Cruddiy post, I thought it was time for an update.

🥳 Cruddiy now supports table relationships via foreign keys. 🥳

This means:

  • You can add new or delete existing table relations by picking columns that have a foreign key relation.
  • You can add specific actions for each table relation, like:
  • Picking specific actions will result in different behavior. Please read up what these mean (mostly you want ON UPDATE CASCADE and ON DELETE CASCADE).

Having table relations in place wil have the following results for Cruddiy:

  • On the Create form the field will be populated with the correct key information.
  • On the Update form: the correct stored value will be preselected but you can still choose (update) different values from the select list.

Note 1: the table relationship builder is the first step in the Cruddiy CRUD creation process. However it is completely safe to ignore this step and move to the next step! I would even strongly advise doing so if you are not sure what you need to do, because it might break things. Also if you just want one or a couple of simple unrelated forms it is perfectly safe to skip this step.

Note 2: the table relationship builder is of course just a GUI for something you can also do in PHPMyAdmin or MySQL from the commandline. However, Cruddiy makes it visible and easier to work with table relations.

Some screenshots:

Table relation builder. One existing relation. And a couple of dropdown lists to create new ones. Feel free to skip this step by hitting ‘Continue CRUD Creation Process’.
In the column form columns with foreign keys are indicated by the blue icon.
A simple two field table. As you can see the second item is preselected (as it should be). However it is still possible to select a different value.

3 thoughts on “Cruddiy: table relationship support via foreign keys”

  1. This is excellent work for its simplicity compared to the commercial scripts and their bloat. That said, a few features such as making form fields changeable would make this A++. I found one seeming glitch in that when I connected to a database with 18 tables, all the dashboard links were created but one button didn’t display its text although it correctly navigated to the correct CRUD page.

    Thanks a million Jan van den Berg.

    1. Thanks for the nice comments Mark! I’ll have to look into the ‘glitch’ (I have never tested it with 18 tables before).
      I am not sure what you with ‘making form field changeable’: the form fields are based on the database column types, I suspect making those changeable could possibly break the database and/or queries.

Leave a Reply

Your email address will not be published. Required fields are marked *