database design - What is the best way to reference other rows in an SQL table? -


i have table has nodes in them. want have different groups of these nodes if want delete node, have ability delete whole group if wish.

what best way going this?

i thought maybe make table group ids in , add row in each node saying group id belongs to, doesn't seem best method of doing me.

any ideas great,

thanks

similar proposed:

1) create group table, group_id primary key 2) create node table, foreign key node_group 3) define foreign key relationship delete cascade 

if want delete nodes within group, can either delete nodes given group_id or delete group delete child nodes.

if need assign nodes different groups need third table e.g. group_node link group_ids node_ids, don't think wanted that.


Comments