I am constructing the moderation engine in which moderator should be able to save position of the last seen message assuming the total messages entities should from 100k to millions of records.
The message database structure is consist of two tables question and reply and represented as following:
question table:
+-------------------------+------------------+------+-----+---------------------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-------------------------+------------------+------+-----+---------------------+----------------+
| entity_id | int(10) unsigned | NO | PRI | NULL | auto_increment |
| text | mediumtext | NO | | NULL | | |
| customer_id | int(10) unsigned | YES | MUL | NULL |
+-------------------------+------------------+------+-----+---------------------+----------------+
and reply table, parent_id is FK to question.entity_id :
+-------------+------------------+------+-----+-------------------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-------------+------------------+------+-----+-------------------+----------------+
| entity_id | int(10) unsigned | NO | PRI | NULL | auto_increment |
| text | mediumtext | NO | | NULL | | |
| customer_id | int(10) unsigned | YES | MUL | NULL | |
| parent_id | int(10) unsigned | NO | MUL | NULL |
Because this is two separate tables with parent-child relationship the only thought that i have is to create a temporary composite table messages like this:
question1->reply1.1->reply1.2->reply1.3->question2->reply2.1->reply2.2... etc
and make a slice of it, from the last saved position viewed by moderator, assuming the last saved position is id of last viewed message in this temporary table.
So, the questions are:
How to properly construct this temporary table assuming messages and replies will constantly growing ?
Will it affect performance on large entries quantity (we are using MySQL) ?
Is there a better way to implement such functionality ?
I have not much experience in large database constructing and would love to get some advice or critics or any ideas regarding this task from more experienced engineers.
Aucun commentaire:
Enregistrer un commentaire