Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new entities to DB schema #9

Open
sunsingerus opened this issue May 25, 2017 · 1 comment
Open

Add new entities to DB schema #9

sunsingerus opened this issue May 25, 2017 · 1 comment

Comments

@sunsingerus
Copy link
Contributor

SUPPOSITION

We have one main/meaningful entity provided by bootsrapi - USER. All the rest entities are either auxiliary for user operations (e.g. *_tokens, roles, rights, roles_to_rights) or system maintenance (e.g. migrations, seeds, ,logs). This is nice as a starting point at the very beginning. However, this is not enough even for a decent scaffolding.

PROPOSITION

Let's introduce additional general-purpose entity, reasonably called ENTITY :) and some auxiliary/boilerplate entities in order to provide complex relations between entities and users. Proposed entities are:

ENITITY
--------
id BIGINT
type INT
status INT
owner_id BIGINT foreign key -> users.id
connector_id BIGINT foreign key -> connectors.id
attributes JSON

Entity represents arbitrary entity, owned by a USER (via owner_id) and having arbitrary set of attributes.

CONNECTOR
--------------
id BIGINT
type INT
owner_type INT

Connector represents 'connection point' designed to provide relations between custom entities in the system (like entity <-> entity or user <-> entity, etc). Each entity in the system who intends to establish relations provides its 'connection point' - connector in order to receive or to establish relations.

RELATION or may be called CONNECTION - named relatively to CONNECTOR above
-----------
id BIGINT
connector_id_a BIGINT foreign key -> connectors.id
connector_id_b BIGINT foreign key -> connectors.id
type INT
status INT
attributes JSON

Intended to setup a relation between two entities via their CONNECTORs

Possible relation/connection types:

  1. b is owned by a
  2. b is member of a
  3. b is assigned to a
  4. b is child of a
  5. ... etc ...

Also new attribute in USER entity would be needed - connector

USER
====
... all known fields
connector_id BIGINT foreign key -> connectors.id

Proposed structure would allow to build custom relations between all entity types in the system, opening direct way to construction of entity hierarchies owned by users, attach entities to another entities or users, etc

Imagine the following structure:

  1. entity of type 'event'
  2. entity of type 'collection'
  3. multiple entities of type 'note'
  4. relation 'event'-'collection' of type 'owned'
  5. relation 'note'-'collection' of type 'assigned to'

And as a result, we'll have 'event' with a 'collection' of 'notes' build on custom entity base.

PS. I can implement proposed update

@sunsingerus
Copy link
Contributor Author

DB schema is under discussion, let's produce some kind of generalized solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant