sql - What is the best practise for relational database tables in mysql? -


I know, there is a lot of information on mysql out there but I do not really answer this specific and really simple question I was able to:

Say I have two tables:

USERS (with many areas, such as name, street, email, etc.) and group (with many areas Too)

relationship (I think?) 1: n, this user can be a member of many groups.

What I'm doing is creating another table named USERS_GROUPS_REL. This table has only two fields:

us_id (the unique key of the table users) and gr_id (the table GROUPS unique Key)

In PHP I do a query to join.

Is this "best practice" or is there a better way?

Thanks for any indication!


Hi all,

Thanks for your quick and helpful support, knowing that I was on the right track, enhances my mysql-confidence. : -) Many people commented, my example is not 1: n but many people just as a quick SQL-text: -)

Is this the correct word? 1: n many many n: 1 a lot n: many people many?

You describe a lot of relationships with that relationship, using many users You can be a member of the group for your purposes, this is actually the right way to go.

One-to-many and one-to-one relationships do not require a link or a cross-reference table (USSRSOGGOL).

You can find this tutorial useful:


Comments

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -