Welcome to the discussion about this lecture. Here you can ask questions or post feedback about this specific lecture.
you said each table needs to have a unique ID; doesn’t the Relationships table then also need one or is the unique key the combination of user and group? Thanks
You can give the relationship table an id column if you want. Some projects do it, but you don’t have to as the combination of foreign ids stored in the table are unique for each row which makes the id reduntant.
Hi Ivan in your explantion you have created relationships for the rows such as users. In other words the entries.
But how do you create a relationship between for example 2 columns for example the names linked to the age of the users. Ie whats the relationships between names and age. these are two specific characteristics of an item. Would you need to give an ID to each name and an ID to each age? just like you have given an ID to users?
I feel like you wouldnt need to as there are no individual components to each column. However if you were to go a lot deeper into say the letters within a name linked to age you would have to create a table for each name, and then have an ID for each name as well??
That makes sense. This relationship table is also sometimes referred to as a Concat table as it simple joins the other two fields and is used for fast query searches.
I actually do not get why we need this extra table to connect the two tables. Why can’t we add a column group_id to the table:user. Would that not make clear that that user is part of a certain group.
Ah, or don’t we do this, because a user can be in several groups?
Hey @Merijn, hope you are great.
Now, in terms of programming the SQL database, you could have 1 user that belong to many groups, you could have a table called
users (which contain only data refered to the client, like his ID, address, phone number, etc) and other table called
groups, lets say the
groups table, contains a column which is the ID of a member, that ID is the same of ID of the
user table, in few, that is how you make relationships between tables, so you could have a better way to keep well structured each table (
user only data of user,
groups only data of groups, and so on). Now you have a One to One relationship.
Then, lets say there is another
group2 table, which is identically at the first one, but it’s represent another kind of group (like 1st group: btc club, this 2nd table : eth club). So now you have a One to Many relathionship.
If you have any more questions, please let us know so we can help you!