Database manager - new multi references are confusing, how to rename?

Just installed the new update (4.8.1).

My tables are a bit confusing now. Here’s an example:

So I haven’t used the UI to create multi references or subtables. It’s using what I already made manually.
It looks a bit confusing, probably due to my own naming convention mixing with wappler’s logic…

How can I make it look like intended?
I think I need to rename my tables… So what is the naming convention that matches with Wappler’s implementation of the database manager?

Example: I have the following structure (these are all many to many)… schools → courses → chapters → lectures.

In plain words: a school can have multiple courses, but a course can be part of multiple schools.
A course can have multiple chapters, each chapter can be part of multiple courses.
A chapter can have multiple lectures, each lecture can be part of multiple chapters.

Is this how I should make it using the UI? ↓

  1. Create 4 tables: schools courses chapters lectures image
  2. Go from top down and add multi references: for example, in schools we add schools_courses image
    Then in courses we add courses_chapters image etc.?

sub tables and multi references (junction tables) when created in Wappler - inherit their parent name as prefix.

So you don’t need to include that in the name.

So when creating courses_chapters under courses - just name it chapters - it will automatically get the prefix courses_

Nesting the tables indicate table prefixes. This is also how we detect the nesting by just analyzing the table prefixes and relation keys.

Thanks @George - trying to understand the concept completely:

Is the following correct? Wappler looks at the prefix and references to decide if it’s a subtable or multi ref table:

  • Subtable: main table users and users_contactinfo (with ref to users.id) this users_contactinfo will become a subtable of users in Wappler

  • Multiref: 3 tables… courses, schools and schools_courses (with 2 refs: courses.id and schools.id) this will become a multi ref table in wappler, visible under the schools table because it’s prefixed with ‘schools’

No, users_contactinfo will become sub table of users that is named just contactinfo

multi reference are actually exact the same as sub tables but they just contain 2 reference keys inside - one to the parent and one to the other table. That makes a junction table. For the naming of multi reference tables - is the same as with sub tables. It is prefixed with the parent table name.

So in your case the courses_chapters junction table will become under courses just chapters
And the schools_courses under schools will become just courses

Once you see that relation - it will all make sense :slight_smile:

1 Like

Thanks @George it’s starting to make sense. I can now debug what happened to my pre-existing tables and see how to go from here

A post was split to a new topic: Database manager use sub tables without prefixes