is it ok to have two rows for friendship between two users in my friends table?

i am working on adding friends feature in my app let's say User A sends a friend request to User B then User B sends to user A , a friend request is it ok to have two rows one when User A send user User B a friend request and vice versa to indicate that these users are friends or is there a better way to do the friendship in my database .
1 Reply
Keef
Keef3w ago
You should focus on playing to the strengths of a relational database and what kind of functions do you want to enable from the choices you make in regards to your schema. So is there a particular reason you find yourself reaching for this route versus just using a simple record with two foreign keys and a status. The query for your approach is more expensive and complicated compared to just an or check on user_a and user_b then a status =1 or something in the latter You can also google sql friendship table if you want a quick answer
Want results from more Discord servers?
Add your server