Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 291765

Remove entity_id and entity_type from the comment table and replace with relationship tables

$
0
0

The current changes to the comment.module in #731724: Decouple comment.module from node by turning comment settings into a field introduce a database design that is not ACID compliant. While Drupal itself does not have an ACID compliant database design, there has been considerable work done to take steps towards this. The first of which is to make real foreign key constants #911352: Document that foreign keys may not be used by all DB drivers.

Since foreign keys can only relate to a single table, the design implemented in the changes to comment.module make this impossible.

I propose that these fields are removed the from the schema:

entity_id
entity_type

Instead, it would be better to have a table for each entity that related the comments to that entity.

For instance, for nodes you would have a table called comment_node, the schema would look something like this:

cid
nid

The primary key could simply be cid. If the comment shouldn't be allowed to appear on more than one node, or if it should be able to be on more than one node, it could be a primary key of cid+nid. Regardless a pseudokey of 'id' or 'cid_nid' should not be used.

Since comments will rarely, if ever, be queried across entity types, this change introduces relatively little performance problems.

The goal of this issue is to help make Drupal's database be more stable. When foreign key support is fully implemented into Drupal, this change will prevent the database from containing comments that relate to non-existent entities. This will assist in keeping Drupal's database sanitized.


Viewing all articles
Browse latest Browse all 291765

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>