A
A
alisarin2022-01-22 14:35:07
SQL
alisarin, 2022-01-22 14:35:07

Did you catch... the "semantic cycle"?

In general, from the programming side, the topic of the question relates to the use of the SQL query language, and I see it in the fact that if anyone has encountered the task of identifying semantic cycles (a conditional concept), then they are possible only in a hierarchically organized database, and, therefore, you can talk with him about the principles of organizing such bases. In general, if the database does not have a hierarchical organization, then semantic cycles are hardly possible there.

But what is a "semantic cycle"?

Suppose we know someone, let's say:
1. Engels
But he does not just exist, but also does something:
2. Engels divided all philosophers into two large camps - materialists and idealists
. consequence:
3. The camp of materialists
then in this "camp" was given to consist of some figures, in particular, these are:
1. Engels
...

This completes the cycle. But since the semantic cycle is more harmful than useful, it is useful to break it in this way:

4. Engels belongs to the camp of materialists -
which, on the other hand, harms the unification of data.

In the form of tables, all this is implemented as follows - the tables "a", "b" and "c" are given, where "c" is the link table, we will omit it for simplicity. In the hierarchical base, at the first step, it is possible to record the fields "Engels" in the table "a", "b" - "Engels divided ...", at the second step - in the table "a" the fields "Engels divided ...", "b "-" camp of materialists", on the third - in the table "a" of the field "camp of materialists", "b" - "Engels". The database is built in such a way that the content of the records in the fields of the tables "a" and "b" is unique, and the rows of the table "c" as well.

Now we can move on to programming. To search for a semantic cycle, it is possible to use the following query (for a cycle length of 4 steps, performed by Access97):

SELECT DISTINCTROW al, bd, b_1.d, b_2.d, b_3.d
FROM (((((((((a INNER JOIN c ON a.wl = ci) INNER JOIN b ON c.al = b.wd) INNER JOIN a AS a_1 ON bd = a_1.l) INNER JOIN c AS c_1 ON a_1.wl = c_1.i) INNER JOIN b AS b_1 ON c_1.al = b_1.wd) INNER JOIN a AS a_2 ON b_1.d = a_2.l) INNER JOIN c AS c_2 ON a_2.wl = c_2. i) INNER JOIN b AS b_2 ON c_2.al = b_2.wd) INNER JOIN a AS a_3 ON b_2.d = a_3.l) INNER JOIN c AS c_3 ON a_3.wl = c_3.i) INNER JOIN b AS b_3 ON (b_3.d = al) AND (c_3.al = b_3.wd)
WHERE (((a_1.l) Is Not Null) AND ((a_2.l) Is Not Null) AND ((a_3.l) Is Not Null ));

(tables marked as *_1, *_2, etc. are full copies of tables a, b, c)

What is not available to ordinary users who understand little about programming is building a semantic cycle search query so that it gives results simultaneously with an even and odd number of steps. But, perhaps, this is impossible due to fundamental limitations; in any case, I will be grateful for a hint on how to build a search for any cycles in one query. I will also be grateful for advice on how such a query can be built simpler, if this is by itself possible.

However, the main point of the post is different - maybe he will remind someone of this strange and amazing feature and he will share his experience in designing and using databases, which I call "hierarchical".

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question