Database tables are better?

Recently, I rethought the database design that I did a couple of months ago. The main reason is that last night I read the databse vBulletin schema and saw that they use many, many, tables.

The current β€œidea” that I use for my scheme, for example, my log table, is to store everything in one table, distinguishing between the type of log with an integer:

id, type, type_id, action, message
1 ,    1,     305,      2, 'Explanation for user Ban'
2,     2,    1045,      1, 'Reason for deletion of Article'

Where type 1 = user, type 2 = article, type_id = the ID of the user, article or w/eand action 2 = ban, action 1 = deletion.

Should I change the design to two tables logBans, logSomethingand so on? or is it better to save the method I'm using now?

+3
source share
6

. .

  • ;
  • , ;
  • "" (.. , ).

.

, (3) , . , , ? , , .

(2) Party. CRM, , Person and Organization ( , Company, Association ..). (, , , .. ), , .

(2) ( NULL ). , (2) . , - - , , , , , (, ).

(1), , 3 .

, , , (1). JOINs , - , . (1) ( ).

. , ( , ).

+7

. 1500000000 1 1000 2, 2, . , .

:

  • 1 ?

  • ?

  • - ? (, X )?

+5

, , , type_id, .

+2

. , , enum tinyint , ..

   enum('user','type')

, tinyint - , . , - - , . , enum.

+1

- . , , .

0

, vBulletin. , vBulletin, , , , , , . , , , .

. . , , . , .

-1
source

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


All Articles