I
I
Ilya2017-10-27 17:08:09
MySQL
Ilya, 2017-10-27 17:08:09

Is it correct to store JSON data in MySql, in the place where heaps of tables are created?

There are users (about 200), and the Portfolio page, which displays 10 tables, all tables have a different number of columns, rows can be changed (added/deleted) by the users themselves.
That is, each user has his own portfolio and, accordingly, his own data in the table.
There are 3 storage options:

  1. Create a general table in MySql that would store 1 row from any table in json format.
  2. Create a page for each table, a table (10pcs) in the MySql database, with the required number of columns
  3. Create a general table with the maximum number of columns and where there are fewer columns, leave the fields empty

Search and sorting by table data is not needed, in what form is it more correct to store information and why?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
B
Barmunk, 2017-10-27
@Barmunk

This is a classic relational structure. Why does it all need to be stored in json?
59f34157583d7365107160.jpeg

T
ThunderCat, 2017-10-28
@ThunderCat

Read normal forms for RDB. Connections. Briefly - tables should contain separate meaningful units of information in separate fields, if these information blocks refer to different entities - these should be different tables. Relationships between entities are correlated through identifier keys. There is ideally no duplication of information in tables, that is, if table A has a value a that can be associated with table B, this value is not recorded in B, but a link is created through a key with table A, or if there can be many such links - a separate table of relationships is created (one-to-many or many-to-many).

Z
Zakharov Alexander, 2017-10-28
@AlexZaharow

You can, of course, only there is one problem - checking the validity of the data before writing it to MySQL. Out of the box, MySQL does not have built-in schema validators. I wrote such a check in Java / JavaScript / Nashorn (so that the same function validates JSON on exit from the page and on entry to the servlet) before saving.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question