kot13 / bootstrapi

A better framework for building API with PHP. Built using Slim 3, Eloquent, Zend-ACL
88 stars 22 forks source link

Add new entities to DB schema - support for user hierarchy #10

Closed sunsingerus closed 6 years ago

sunsingerus commented 7 years ago

SUPPOSITION Sometimes it is required for users to shape some kind of hierarchy. For example: group-group member relation or senior-junior relation. There are no support for user hierarchy in bootstrapi at the moment.

PROPOSITION Let's introduce support for user hierarchy/relations for bootstrapi. We can add new entity

user_relation
=============
id BIGINT
type INT
user_id_a BIGINT foreign key -> users.id
user_id_b BIGINT foreign key -> users.id
status INT
attributes JSON

Relation between users could be one of:

  1. b created by a
  2. b is a group member
  3. a invitation located in attributes.data.invitation
  4. ... etc ...

Support for 'many-to-many', provided by external relations table, would allow, for example, to join users into multiple groups.

PS. I can implement proposed update

sunsingerus commented 7 years ago

After some thinking, it looks like user relations would be more reasonable/consistent to implement based on connector-relation pair, not or separated user_relation table.