HiDd3N
HiDd3N

Reputation: 504

message box design for mysql

I need to create a message box for user login system. Now I have users that can login and do many functionality.

The user table is something like this"

+-----+------+--------+
| uid | name | family |
+-----+------+--------+

Now I need too create a message box which will show users messages. They can view what they sent or what they recieve.

I can create table like this:

+-----------+-----+-------------+------+
| messageid | uid | messagetext | type |
+-----------+-----+-------------+------+

messageid is auto incremented and integer type and type is a boolean variable and, if it is 0, the message is in recieve box. If it's 1 - the message is in sent box, but where is the problem in my case?

I think, if we have autoincrement for this messageid field, this messageid will have very big number in future. For this reason I think this design might be wrong... is there any better solution for my users message box?

Upvotes: 1

Views: 376

Answers (1)

Somnath Muluk
Somnath Muluk

Reputation: 57756

For message it would be like: If it's user to user interaction then:

+-----------+------------+--------------+-------------+--------------+------+
| messageid | sender_uid | receiver_uid | messagetext | message_time | type |
+-----------+------------+--------------+-------------+--------------+------+

Otherwise structure is good.

There wont be any problem due to large number of messageid. take appropriate datatype.

Upvotes: 1

Related Questions