I want messaging between different parties..
I want to know what is the best way to create tables.
So if the parties were only members and admin.
This is how tables might look like:
members
---------
id | name
admins
------
id | name
messags
--------------------
id | from_id | to_id | subject | detail | date.....
Now problem is how do I join tables.
if a message is from admin I need to join with admin table to find what is the admin name etc.
if a message is from another member I need to self join tables.
If it was a single message I could add another field to messeages like from_type, which may say it is 'Admin' 'Member'. Then I
can first find out whehter to join to member table or admin table and then do the join. But this is not very effecient.
And what happens when I want to display the list of all messages with subject and say if it is a member or admin and then link to their profile using id from that particular table (admin/member etc.).
I also want to keep an option for adding another party who can send messages like and advertiser. Where advertiser too can send message
to users and users can reply back. so advertisers table may be like:
advertisers
--------------
id | name
and I could add this under from_type field in messages table. 'Admin', 'Member', 'Advertiser'
So basically what I want it communication between all the parties, members-members, members-advertsisers, advertisers-members,
admin-members, member-admins.]
For some reason I cannot do this:
UserTable
---------
id | name | usertype
1 jsmith member
2 jdoe admin
3 jbrown advert
I want each type of user to be in different tables.
Is there any efficient solution to this problem?
I want to know what is the best way to create tables.
So if the parties were only members and admin.
This is how tables might look like:
members
---------
id | name
admins
------
id | name
messags
--------------------
id | from_id | to_id | subject | detail | date.....
Now problem is how do I join tables.
if a message is from admin I need to join with admin table to find what is the admin name etc.
if a message is from another member I need to self join tables.
If it was a single message I could add another field to messeages like from_type, which may say it is 'Admin' 'Member'. Then I
can first find out whehter to join to member table or admin table and then do the join. But this is not very effecient.
And what happens when I want to display the list of all messages with subject and say if it is a member or admin and then link to their profile using id from that particular table (admin/member etc.).
I also want to keep an option for adding another party who can send messages like and advertiser. Where advertiser too can send message
to users and users can reply back. so advertisers table may be like:
advertisers
--------------
id | name
and I could add this under from_type field in messages table. 'Admin', 'Member', 'Advertiser'
So basically what I want it communication between all the parties, members-members, members-advertsisers, advertisers-members,
admin-members, member-admins.]
For some reason I cannot do this:
UserTable
---------
id | name | usertype
1 jsmith member
2 jdoe admin
3 jbrown advert
I want each type of user to be in different tables.
Is there any efficient solution to this problem?