Click here to Skip to main content
15,884,885 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am working to design database structure according to following requirements and need some suggestions.

There are 2 tables User and Item:

User
=================
User ID | User Name

Item
===================
Item ID | Item Name

Now each user is sending and receiving list of items and can also reject any received item and there can be hundreds of items in each of the 3 list.

What can be best approach to save these 3 lists of items for each user?

What I have tried:

Couple of Approaches I have thought is to either:

1. A table each for Sent, Received and Rejected with columns: 'User ID' and 'Item ID' in each.

2. A single table having columns: 'User ID', 'Sent', 'Received' and 'Rejected', each storing a comma separated list of Item IDs, but the list continue to change and grow, so performing string operations to updated the table each time could be expensive.

Can there be any other alternative that could beat above 2?

PS: I also need to be concerned that DB space usage is optimum with the approach I use.

Appreciate your time.
Posted
Updated 12-Dec-20 11:54am
v2

1 solution

Two tables:
Actions:
ID      (IDENTITY or UNIQUEIDENTITY, your preference)
Desc    (NVARCHAR)

ActionLinks
ID         (IDENTITY or UNIQUEIDENTITY, your preference)
ActionId   Foreign key to Actions.ID
UserID     Foreign key to Users.ID
ItemID     Foreign key to Items.ID

I'd probably also throw a few timestamps in there just for audit / tracking purposes.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900