lundi 5 janvier 2015

One foreign key referring Multiple column (Notification Concept)

I am new in programming, and I want to ask question regarding database schema (I'm using SQLite Database for Android Development)


I have some table, let say :




  1. MsMember


    MemberId


    Password




  2. MsGroup


    GroupId


    GroupName




  3. MsAnnouncement


    AnnouncementId


    AnnouncementName




  4. MsComment


    CommentId


    CommentContent




  5. MsTodolist


    TodolistId


    TodolistTitle




And I want everytime a new row has been inserted to (at least one of) all five tables above, it will create a notification to user, as far as I know, with this concept, I should create a table to store every detail of notification then shows it to user..


And my best opinion so far is I create a table let say MsNotification, then to connect all five tables with this MsNotification I should have foreign key referring to each table..


My Question is would it be possible (and effective) to have a column that has more than one references?


Example :


Foreign key (SourceId) Referring MsMember (MemberId),


Foreign key(SourceId) referring MsComment (CommentId),


Foreign key (SourceId) referring MsAnnouncement (AnnouncementId), and so on.


or is there any better way to implement this concept?


Thank you in advance


Aucun commentaire:

Enregistrer un commentaire