Support

Account

Home Forums General Issues How do I avoid data redundancy?

Helping

How do I avoid data redundancy?

  • Hi

    I try to build a structure for organizing apartments, families and family members, but I can’t figure how to set it up to fulfil my goal (and to avoid data redundancy).

    An apartment consists of one family, a family consists of one or more members and a member belongs to one and only one family.

    I have created two CPT and a couple of custom fields:

    Families
    ========
    apartment_family (Relationship min 1 and max 1)
    family_members (User)

    Apartments
    ==========
    apartment_family (Relationship min 1 and max 1))

    I can easily connect Families and Apartments via the relationship field (and the ACF Post-2-Post plugin), except that I can’t figure how to avoid adding eg. the same family to more apartments?

    When it comes to the Family members it begins to be even shakier:
    I can add users but like above, I can’t figure how to avoid adding eg. the same member to more families?

    Unlike the Families and Apartments I can’t figure how to make the relation between Families and Users bi-directional. I would like to sync the information about family_members to the Users table. Is this possible?

    Or is it possible to create a function that takes the user_id from the users table and look up in Families to view the corresponding family that the current user belongs to?

    I hope it makes sense to someone, so I can get further. Maybe the solution is to create one more CPT eg. some kind of an index that holds information about family and members?

    All help is appreciated 🙂

  • It would be possible to create a bidirectional relationship between users and a CPT, there is an example of this here https://gist.github.com/codytooker/56dd0bc7a6893d5e7bf5a5c25bc5e8ea

Viewing 2 posts - 1 through 2 (of 2 total)

The topic ‘How do I avoid data redundancy?’ is closed to new replies.