I am building Restful Api for a mobile application. I need to push the notification to user if he has saved the notification setting to true in his profile.
I have created the following structure:
Users Table:
<kbd>id</kbd> <kbd>name</kbd> <kbd>email</kbd>
<kbd>1</kbd> <kbd>Test</kbd> <kbd>test@test.com</kbd>
<kbd>2</kbd> <kbd>Test1</kbd> <kbd>test1@test1.com</kbd>
Notifications Table:
<kbd>id</kbd> <kbd>notification_name</kbd>
<kbd>1</kbd> <kbd>Like Notification</kbd>
<kbd>2</kbd> <kbd>Comment Notification</kbd>
user_notification Table:
<kbd>id</kbd> <kbd>notification_id</kbd> <kbd>user_id</kbd> <kbd>value (0=off, 1=on)</kbd>
<kbd>1</kbd> <kbd> 1 </kbd> <kbd> 1 </kbd> <kbd> 0 </kbd>
<kbd>2</kbd> <kbd> 2 </kbd> <kbd> 1 </kbd> <kbd> 1 </kbd>
<kbd>3</kbd> <kbd> 1 </kbd> <kbd> 1 </kbd> <kbd> 1 </kbd>
<kbd>4</kbd> <kbd> 2 </kbd> <kbd> 1 </kbd> <kbd> 1 </kbd>
In the above table structure I have created a pivot table with an extra field value
for saving settings of a user.
Is there any another great way to do this, in which I can minimize my queries and respond fast