MySQL DB support

Forgive the elementary question, but my novelty in the field of database design leaves me tied up quite often.

I have a website that continues to grow in relation to information families. In the beginning I had one subject that I described, and everything was fine. This subject took up one record and had 34 columns (many now that I looked back) attributed to him descriptive data. As I enter this material more and more, I see that many developers split the data (when it’s practically possible) into separate tables.

Now I have additional tables that relate to the source element, but are not always necessary when describing the source element, so I unlocked them, so they are not requested unnecessarily.

Anyway, I have a new element that I was trying to organize, which is a USER. The user table has typical columns such as username, email address, last_login, path to the linked image, etc. These users make comments, which are stored in another table containing columns with identifiers that relate to the user and the element on which they are commenting.

Now ... I'm going to add the required user profile page to the site. Should I create another table containing only the basic profile data, or add an existing user record with profile data to the original user table? I think housekeeping can be painful if I add the “Delete me from the site” function, since I have to run something that kills the user record, user profile record and any other data associated with this user ID in another tables.

Basically, what I ask is, should I continue this “granular” design method - break everything down into important parts or ever help me consolidate into larger tables? I see several cases where a user deletes his account, I will be left with a bunch of irrelevant data. For example, the starting point is restaurants ... if I create a table for recording "Visits" in restaurants containing a restaurant identifier and a user ID, if a user or restaurant is deleted from the site, this "Visits" table will have a bunch of useless entries in states that "a non-existing restaurant was visited by user 45" or "Restaurant 21 was visited by non-existent user"

, ... , "" .

, Rob

+3
3

" " , . , . , , . DELETE . , , , , , :)

InnoDB, , .

+2

, .

+2

, - "" - . , , , . , , , . .

, . , "rambling_comments varchar (5000)" , , , , "" , , , , . , , , , , , , , , , , .

, , . , . , Item_Descriptive_Data Item_Stock_Data - . - . (, , , .) .

, , . , . , User User_Main User_Profile, , , , User_Profile User_Main? , . , : " , " - : , , , , .

In short, parsing tables for performance reasons is usually a premature optimization. If you find that you have a real performance issue, THEN look at the tables and see if the performance should be denormalized. But don't start parsing your database to avoid a problem that might happen someday.

+1
source

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


All Articles