M
M
Maxim Dyachenko2012-10-24 16:29:21
PHP
Maxim Dyachenko, 2012-10-24 16:29:21

Schemaless for MYSQL, how?

After getting acquainted with mongoDB, there was a desire to get rid of the installer that creates the database structure in my ORM.
The idea is to catch when the driver swears that we do not have a table, and create a table, if there is not enough column, create a column.
The typing problem has been solved - when reading, in any case, we will have NULL in the field, since there has not yet been a record, and when writing, we have a data type (not a variable type, but a field type including set and enum, because inside the module the data structure is typed So the

question is - how do you think how crooked it is?
The second question - are there pitfalls?
As practice shows, many have gone through the idea of ​​displaying pages by replacing the output of a 404 error.
The disadvantage is obvious - there is no indexing, because for a search engine it is 404, and a crap error log.
Are there similar pitfalls here?

PYSY: The task is considered in the context of php, because if I put Python, for example, then I can easily put some kind of noSQL with shemaless next to it and I will not reinvent the wheel. Clarification because there may be some nuances in the implementation.

UPD: First of all, your opinion about the approach is of interest, not ready-made solutions. Those. OK / bad, or there “it’s better to do it this way”, ready-made solutions are of course interesting, but disassembling someone else’s big engine to understand how it works is not so easy ... Thank you :)

Answer the question

In order to leave comments, you need to log in

6 answer(s)
M
MikhailEdoshin, 2012-10-24
@MikhailEdoshin

Schema less. Shemaless is, presumably, a saying of Gollum the pervert.

E
egorinsk, 2012-10-26
@egorinsk

It will be bydlokod. In the best traditions of the inhabitants of warm India. And adding a field to a large table in general can take hours, so your script will cheerfully fall off on a timeout. But even if it was done instantly, it would be a bydlokod.
Do you want schemaless? You just make one entity table with 3 fields: id, type, blob (in the blob you dump the JSON version of the object). But in general, schemaless is an extremely stupid idea. The database offers an additional level of validation and data organization, and young programmers who are lazy to learn the SQL language, let's say, scream that they don't need this SQL.
Naturally, no one can offer a normal alternative to proven reliable solutions, and mongo looks like a primitive Key Value storage with javascript for game developers (because these comrades could not even master SQL). All serious organizations use SQL.

A
avalak, 2012-10-24
@avalak

You might be interested in RedBeanPHP . It solves a similar problem.

H
Hint, 2012-10-24
@Hint

With JOIN there will be no problems? Determine where exactly the field is missing.

S
Sergey, 2012-10-25
Protko @Fesor

It's very, very crooked. It's better to apply EAV and dance from here.
In general, there are no problems using MongoDB as an add-on to MySQL.

N
nikita2206, 2012-10-26
@nikita2206

This is ok for development (I would even say that it is quite convenient), but in production this feature must be disabled (otherwise EAV is needed).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question