Reputation: 5
I'm wondering what would be the best database design for a website that lets users (lets assume 10k users) leave notes to themselves accompanied with date. The user would only see their own notes.
An example of what the user would see:
28.9.2014
-Went to store
-Took the dog for a walk
21.9.2014
-Called Mike
Upvotes: 0
Views: 71
Reputation: 5166
Create a users table, then create a notes table. Put the user id into the notes table and only show the notes with that user id.
users
- user_id (INT PK)
notes
- id (INT PK)
- user_id (INT)
- note (TEXT)
- created_at (DATETIME)
SELECT note,created_at FROM notes WHERE user_id=1
Of course, that's a simple example query which would return ALL notes for that user. You would most likely want to do a different query that would retrieve the notes for that day and the specified user.
SELECT note FROM notes WHERE user_id=1 AND DATE(created_at) = CURDATE()
Upvotes: 1