John John - 4 months ago 5x
SQL Question

Designing SQL Server database

I'm new to SQL and database design.

I have a task where I need to create a table with users (student or teacher), each user can be in a group or more, and each group can get one or more tasks to solve.

I created the design, but I think is a problem with the entity

, because when I what to add data there, I can't do it (I have only the ID, but no other data. I'm sure I did something wrong).

Adding data to the
entity is working.

What should I change or how I should add users to the group?

enter image description here


Is this a possible way to do it?

 insert into [group] (group_id) values((SELECT ISNULL(MAX([group_id])+1,1) FROM [group] WITH(SERIALIZABLE, UPDLOCK)))

insert into [Entity3]  values(1,1)  //values(x,y) x - user_id, y - group_id where I want to add the user
insert into [Entity3]  values(2,1)
insert into [Entity3]  values(3,1)

This is working as expected, but maybe something shorter or easier?