Nvim

How to convert relational data in PW pages?

Recommended Posts

Everything is a page in PW so how do I convert this relational data into pages in PW?

TABLE: STUDENTS

| ID | Name                | Age |  
----------------------------------  
| 00 | Heather             | 10  |  
----------------------------------  
| 01 | Rachel              | 10  |  
----------------------------------  
| 02 | Jimmy               | 11  |  
----------------------------------  
| 03 | Lola                | 10  |  
----------------------------------  

TABLE: PETS

| ID | Type         | Pet Name  |
---------------------------------
| 00 | Dog          | Rex       |
---------------------------------
| 01 | Cat          | Thomas    |
---------------------------------
| 02 | Cat          | Fluff     |
---------------------------------
| 03 | Dog          | Kimba     |
---------------------------------

Table: PETS-STUDENTS

| Pet ID | Owner ID |
---------------------
| 00     | 00       |
---------------------
| 01     | 00       |
---------------------
| 02     | 01       |
---------------------
| 03     | 02       |
---------------------
| 01     | 03       |
---------------------

Share this post


Link to post
Share on other sites

Each students and pets table is its own template, each row a page. For a limited set of repeating information like your pet type, a page reference field is most often the way to go. The "pet type" pages can live anywhere in the page tree and can optionally have a PHP template to list all pets of that type. The pets-students relationship can be defined as a page reference field linking from the pet to the student, from the student to the pet or, if you plan to implement complex selectors later on, using the Connect Page Fields module also both ways. The page reference fields can be limited to only show pages with a certain template (student, pet, pet type). Names and age should be regular (text, integer) fields. You could re-use the mandatory title field for the student and pet name and just change the label for it in the individual template's settings. I'd probably also create a "pets" and "students" template (plural) under which the individual entries live in the backend to keep things sorted and allow outputting lists.

  • Home (or another common parent page)
    • Students
      • Heather
      • Rachel
      • ...
    • Pets
      • Rex
      • Thomas
      • ...
    • Pet Type
      • Dog
      • Cat
      • ...

 

  • Like 7

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.