Skip Navigation

[Resolved] define structure and relationships

This support ticket is created 6 years, 7 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+00:00)

Author
Posts
#767740

Hi,
i'm working on a site for a university.
I have the structure of the objects and the relationships between them and i need help to translate it in a right way with Toolset.

Wordpress: 4.9.5
Toolset Types 3.0-RC
Toolset Views 2.6-RC2

cities: (num 2+) C
degree programs: (num 4+) P
kind of degree programs: (num 2+) K
courses (num 40+) CS
teacher: (num 30+) T
projects: (num 40+) PJ
academic year: (years from '80) AA

There are 2 cities:
- city C1
- city C2

4 degree programs:
- 1 program (P1) for city C1,
- the others 3 programs ( P2 - P3 - P4) for city C2
--- many programs could be assigned to one city

2 kind of degree programs:
- 2 programs (P1 - P2) are 3 year degree (K1)
- the others 2 programs (P3 - P4) are 2 year degree (K2)
--- one kind could be assigned to many programs

40+ courses
--- many courses could be assigned to one programs (CS1-10 to P1, CS11-20 to P2, CS21-30 to P3, CS31-30 to P4)

30+ teachers
--- many teachers could be assigned to many courses

50+ projects
--- many projects could be assigned to one programs
--- many projects could be assigned to many courses in the same program
--- many projects could be assigned to many teachers

academic year
It's like aa2020-2021, period from nov2020 to nov 2021
--- one year could be assigned to many projects
* at today we want to leave this as custom post type, maybe to connect it in future with others custom post types

And the proposed structure:
- Cities / Parent CPT
-- Degree programs / Child CPT
-- Kind of degree programs / Taxonomy?
--- Courses / SubChild CPT
- Teacher / CPT
- Projects / CPT
- Academic year / CPT

With this structure the remaing relantionships to achieve could be:
--- many teachers could be assigned to many courses
--- many projects could be assigned to one programs
--- many projects could be assigned to many courses in the same program
--- many projects could be assigned to many teachers
--- one year could be assigned to many projects

Do you think that this structure and the relationships are a good way to implement it in toolset?

#768578

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

You seem to have thought this through quite logically in terms of how to set up the various relationships, but I'm not sure why you do not use taxonomies rather than post relationships for some of these.

To me it looks like Cities and Kind of programme could both be taxonomies used to categorise programmes, e.g.

P1: C1 & K1
P2: C2 & K1
P3: C2 & K2
P4: C2 & K2

Likewise your academic year looks suitable for a taxonomy.

I think that would make the remaining relationships seems less complex, and queries in WordPress are optimised for taxonomies.

You may have a good reason *not* to use taxonomies in these cases, meaning that your proposed solution working with post relationships could be used as you have proposed.

#768644

Hi Nigel,
thanks for your quick response.

You pointed me to the big question about taxonomy or cpt, for me it seems a questions of ux controls

With Taxonomy:
I can assign one or more Cities to Programme
I can assign one or more Kind to Programme

With CPT:
I can assign only one Cities to Programme
I can assign only one Kind to Programme

Is it right?
Do you think that is better to switch on taxonomy for performance and leave the user to DO NOT CHECK 2 items?

#768768

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

If you specify city < programme as a one-to-many relationship then a programme can only have a single city assigned, correct.

If your concern with taxonomies is that when one city is checked they may check another, well, by the same token if you were using post relationships and one city was assigned there would be nothing to stop a user changing the city that was assigned, right?

This looks like a taxonomy to me, but it's your call.

#768915

>> if you were using post relationships and one city was assigned there would be nothing to stop a user changing the city that was assigned, right?

Yes, but with post relationships he can select always one of them, with taxonomy he can selects more at same time.

I think it is not completely right that i can allow a select with more choices if the selection expected is limited to one.

One way is to use taxonomy and replace the category selection in admin with a dropdown and solve the issue with a different control. The multiselection still remains on wordpress list view and mass editing.

At now I don't know if the ux trouble is significantly less important than performance gain with the use of taxonomy.

#769559

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

It's a judgement call, and one that only you can make.

Either method works, you just have to choose.

IMHO it is not unreasonable to think that if a user edits a programme which is available in Rome and changes it so that it says it is available in Rome and Milan then when it then says on the front end that the programme is available in Rome and Milan then that is to be expected.

You could add something to change the UI to a select box, or there is this plugin which displays the taxonomy checkboxes as radio inputs instead, for example: https://wordpress.org/plugins/radio-buttons-for-taxonomies/

#769623

Thanks Nigel.
I really appreciate your valued help, I finally figured it out.

Great product, great support