Currently, the messages table contains both user_email and user_name columns, which is redundant since each user_name is uniquely associated with a user_email. To normalize this design and reduce redundancy:
- Create a new table (e.g.,
users) that stores the mapping between user_email and user_name. Each user should have a unique user_id.
- Refactor the
messages table to replace both user_email and user_name columns with a single user_id column that references the new users table.
- Update the login logic so that when a user logs in, if their
user_email doesn't exist in the new users table, a new record is created. This ensures mlack can distinguish new users from existing ones.
This change will improve data integrity and make user management more efficient.