Offer a database schema for a widget-driven site

I am currently working on a restructuring of my site's database. Since the scheme I have now is not one of the best, I thought it would be useful to hear some suggestions from you.

To start, my site actually consists of widgets. For each widget, I need a table for settings(where each widget instance has its own user settings), a table for common(common elements between instances of the same widget) and userdata(saved user data in the widget instance).

So far I have had the following schema consisting of 2 databases:

  • the first database where I had all the site maintenance tables (for example, users, widgets, logs, notifications, messages, etc.). PLUS table that I added each widget instance for each user who initiated it, is assigned a unique ID (so I have the following columns: user_id, widget_idand unique_id).
  • the second database, where I saved all the data associated with the widgets. This means that for each widget (unique in it widget_id) I had three tables: [widget_id]_settings, [widget_id]_commonand [widget_id]_userdata. In each of these tables, each row contained a unique_iduser widget. In fact, there were all user data stored in widgets.

To give a brief example of how my databases work:

First database:

  • users user_id = 1
  • widgets widget_id = 1
  • users_widgets user_id = 1, widget_id = 1, unique_id = 1

:

  • 1_settings unique_id = 1, ..., ...
  • 1_common , ( )
  • 1_userdata unique_id = 1, ..., ... . , unique_id (, )

, .

"" , 2 . , (1_settings, 2_settings,..., n_settings).

. !

EDIT: , MongoDB CouchDB, ? , , , . , SQL NoSQL ?

+3
2

users_widgets :

id | user_id | widget_id

unique_id users_widgets, - . , , widget_instances, widget_instance_id .

- :

widget_instance_settings

id | widget_instance_id | key | value

, user_id widget_instance_id, - .

widget_common_settings

id | widget_id | key | value

, Elgg.

+6

, ? widget_class ( ) widget_instance (, ).
, widget_class_settings, widget_class widget_instance_settings, widget_instance. widget_instance widget_class . widget_instance users, , .

0

Source: https://habr.com/ru/post/1776457/


All Articles