No video

How to manage Many-To-Many relationships in a Data Model? |Data Modeling Tutorial |BI Consulting Pro

  Рет қаралды 60,958

BI Consulting Pro

BI Consulting Pro

Күн бұрын

Пікірлер: 71
@hjk4575ma
@hjk4575ma 15 күн бұрын
Thanks a lot! It solved my problem.
@BIConsultingPro
@BIConsultingPro 9 күн бұрын
Glad it helped!
@Android.26
@Android.26 8 ай бұрын
Very good step by step and an excellent case scenario . Your video and analytics solved my many-to-many problem
@BIConsultingPro
@BIConsultingPro 7 ай бұрын
Glad it helped!
@ShreyasSinha
@ShreyasSinha 6 ай бұрын
Help for Viewers. to UNDERSTAND the example in the VIDEO. Student Table has ID Column ---> this ID is actually Student ID. He does not mention this in the video !!! Same way the ID in Class Table is not Index it is actually CLass ID. Index is different and ID is different. ID is CLDB1123 it is identification for simplicity he has taken 1 2 3 which looks like Index. Both tables have Student ID and Class ID that's how he is able to make a connection.
@dcpowered
@dcpowered 2 жыл бұрын
Very clear and helpful video. Thanks!
@BIConsultingPro
@BIConsultingPro 2 жыл бұрын
Glad it was helpful!
@asifmohammed2329
@asifmohammed2329 Жыл бұрын
Please answer below questions 1) I believe wrong data is used in example. In the class table - Math, German, English, computer each have 2 different class ID. I understand each class can be taken by multiple students, but each class cannot have 2 different class ID. 2) You said using direct many to many relationship is not going to workout, but did not explain what will be the issue if we use it. Because when i used it i did not find any issue when using data from tables and filters. can you explain why not to use it? 3) Why did you use both "Student ID" and "Class ID" in enrollment table. When just using "Student ID" in enrollment table will be sufficient in this case. When i used just "Student ID" enrollment table i am getting same results. Am i missing something here?
@BIConsultingPro
@BIConsultingPro Жыл бұрын
I understand. However, please watch the video again, and understand the context where I am talking. If you still think it's not correct, let me know. I'll definitely try my best to resolve your query.
@MarkovChains223
@MarkovChains223 10 күн бұрын
For anyone that may have had similar questions, I think I can answer these: 1) I think his example data may have been unclear, misleading, or poorly constructed, but I'm not sure which. If you had class_id in the Student table, each student should have multiple rows; same thing for if you have student_id in the Class table, but his example data doesn't clearly show that (particularly in the Student table, where each student only has one row). The reason the class ID's look weird is because the ID column of that table is the primary key, which MUST be unique. Because student_id is included in the class table, each class must have multiple rows. As such, in order for the ID column to be the primary key, it isn't unique to each class, but rather each class-student pair. 2) Which brings me to the problems with having many-to-many relationships between tables. It is precisely BECAUSE there is a many-to-many relationship between students and classes that the primary key/ID in the class table *cannot* correspond to unique classes (the ID column in the Student table can't correspond to a unique student, either, but his example data doesn't really show that). There are numerous issues with many-to-many table relationships, but the core problem is that it *forces* the tables to duplicate data. Extending his example a bit, imagine if the class table had a dozen or so other columns about who teaches the class, what grading scale they use, what time it takes place, what day(s) it takes place, etc., etc. Because you have the student_id in there, because it's a many-to-many relationship, all of the data specific to each class is duplicated a number of times equal to the number of students it has. Which means you're wasting a ton of memory on storing redundant info, any queries to that table are much slower and typically require a lot of extra complexity, changing something like the time a class is held at requires updating numerous rows (and if you miss any rows, you now have conflicting data, which is the absolute LAST thing you want), etc. Duplicate data is basically the enemy of any relational database; it causes all sorts of problems down the line that you REALLY want to avoid. It might not seem to have much effect when you're dealing with very small, simple data sets, but it can have a MASSIVE effect once your data size and/or complexity starts to grow. Eliminating as much data duplication as possible is basically the central goal of relational databases (transactional ones, at least; sometimes some duplication can be practically useful, but it's generally something you want to avoid). 3) In order to avoid many-to-have relationships, the Enrollment table *needs* at least 3 columns: a primary key (call it enrollment_id), and 2 foreign keys (class_id and student_id) AND class_id needs to be removed from the student table, as well as student_id from the class table. The purpose of the "bridge table", i.e. the enrollment table is to essentially remove the foreign keys from the main tables (student_id from Class, and class_id from Student) and store them in a table that specifies the relationship between each student and each class, such that you no longer need duplicate rows in the Class table for each student and vice versa. Done correctly, you will have 1 ID in the Student table per student, and 1 ID in the Class table per class; you'll also have many enrollment_id's per student_id, but only 1 student_id per enrollment_id, as well as 1 class_id per enrollment_id and many enrollment_id's per class_id. Then if, for example, you want to change the time a class occurs, you only need to make a single change in the Class table, rather than make the change for every student in the class. You can now query, update, add, and remove student data and class data *independently from one another*! If a student drops a class, you now only need to remove a single row, from the enrollment table; if you didn't make change, and kept the direct many-to-many relationship between the Student and Class tables, every time a student dropped a class, you'd have to remove a row or value in BOTH the Student table AND the Class table (and, again, if you forget to do so in one of the tables, you'll then have conflicting data and you won't be able to tell whether or not the student was enrolled in that class anymore). All in all, he basically just kinda did it wrong, using what appears to be poorly constructed example data. I have no doubt he understands how to fix many-to-many relationships, though; the confusion and errors are more likely just the result of the fact that it can be difficult to come up with good, illustrative example data and teach based on it in a clear and comprehensive way. ESPECIALLY when you're used to doing things like this in an applied setting where things are always 1000x messier; "ideal" data that's useful for demonstrating core concepts can almost seem foreign and incomprehensible after awhile. It's why "teaching" and "doing" are two very different skill sets; not all who can do something can teach it, and not all who can teach something can do it.
@shwetkumar1719
@shwetkumar1719 4 ай бұрын
Thank you 😊
@kalyanreddy6260
@kalyanreddy6260 Ай бұрын
Hello sir Sir each class must have it own id right, here i see multiple id for the same class. For eg when we use clss id in a table visual and count the number of student for that class id. In that case how we determine correct class id . Id 4 may be english class and id 8 will be english class.
@samsonwoldemichael5742
@samsonwoldemichael5742 11 ай бұрын
Sorry, this sounds clearly wrong. Cartesian product means any possible relationship between two sets (all ordered pairs). So joining to such bridge table definitely creates duplicated result sets.
@ThansiRoopa
@ThansiRoopa Жыл бұрын
Sorry to say may be this is wrong, ID column is not having repeated Id's to avoid m-m relationship. instead using bridge you can use directly 1-1 relationship right?, correct me if i am wrong
@abhilashjoseofficial
@abhilashjoseofficial Жыл бұрын
Just a silly doubt.What is the need for creating the bridge table, the many to many relationship is working right
@ronakchoudhary7089
@ronakchoudhary7089 Жыл бұрын
Best explanation
@cpcdev
@cpcdev Жыл бұрын
Thank you this was very helpful
@user-lu5cy5gv9v
@user-lu5cy5gv9v 3 ай бұрын
Hi bro, please show the demo for how to check final value in many to many relationship in the visual "Report view"
@BIConsultingPro
@BIConsultingPro 3 ай бұрын
Thank you. Definitely, will do a demo on it. Thank your for your feedback.
@luisfernandomacedo1451
@luisfernandomacedo1451 Жыл бұрын
When we do this with a table that contains thousands of rows, the result for the cartesian product is going to triple the number of rows. Did that to a table I am manipulating, with 3.779 rows, the combination jumped to more 15 millions rows.
@BIConsultingPro
@BIConsultingPro Жыл бұрын
Yes, this would certainly do. However, you can try just to keep ID columns from both (many) sides of the table in a separate table (only unique values) and that may solve your problem. Or you may create two different dimensional tables.
@mazkaibil9108
@mazkaibil9108 Жыл бұрын
Love the video. Thank you!
@Ahmad-yv5zx
@Ahmad-yv5zx 9 ай бұрын
well explained
@pramodprem2243
@pramodprem2243 Жыл бұрын
How to modelling if there is no common columns from two tables?
@BIConsultingPro
@BIConsultingPro Жыл бұрын
If there is no keys are there, you may combine one or more column, and create it. However, in relational database there is always a relationship between the tables, otherwise you cannot do it. You must create a relationship.
@usman_oz
@usman_oz 2 жыл бұрын
Will the filter flow work in this case ? The filter directions are from normal tables to Bridge table. Eg:- If I have a table visual with student details from student table and a filter visual from the class table on the canvas to see all students from students table who are enrolled for a particular class. As per the flow, I understand that bridge table would get filtered but the filter context would not traverse further into students table. Hope I'm able to explain and pls correct me if I didn't understand or am wrong. Thx
@BIConsultingPro
@BIConsultingPro 2 жыл бұрын
Of course, that would work. There is already another video, where I have explained about it. Watch this video: kzfaq.info/get/bejne/qpd4krV_2bewlJ8.html
@usman_oz
@usman_oz 2 жыл бұрын
@@BIConsultingPro yeah I already saw that when it was released few weeks ago by you and there it was clear.
@dilipkumar-ck1nc
@dilipkumar-ck1nc 2 жыл бұрын
Hi I have 3 tables containing many to many relationship so I drag one date column to slicer and I start filtering the data it was showing properly
@anindadatta164
@anindadatta164 27 күн бұрын
Is it possible to have two new single column dimension tables " student table" and " Class table" having only unique student id and class id, and connecting those dim tables separately to fact tables
@BIConsultingPro
@BIConsultingPro 18 минут бұрын
I'll request you to watch our latest video on "Many to Many relationships" and read the following: Yes, it's possible and often recommended to create two new single-column dimension tables (e.g., "Student Table" with unique Student ID and "Class Table" with unique Class ID). You can then connect these dimension tables separately to your fact table(s) using a one-to-many relationship. This approach helps in simplifying many-to-many relationships, improves performance, and provides better control over data relationships and filtering in Power BI.
@jlcw74901
@jlcw74901 2 жыл бұрын
hi, I followed your instruction but after making Cartesian product, power bi does not allow one to many relationship as making Cartesian product will duplicate the keys (in your example, the student ID)
@BIConsultingPro
@BIConsultingPro 2 жыл бұрын
I have tried the same, and it's working for me. You can try to remove the duplicate. Please do share your feedback too.
@ansumansatpathy3923
@ansumansatpathy3923 7 ай бұрын
There is no need for a cartesian product. It will inflate table size. Since only those record combinations which exist in Student and Class are sufficient. Then from Class to Enrollment its 1-many and from Student to Enrollment 1-many.
@renukapremkumar3318
@renukapremkumar3318 Жыл бұрын
What do I do if this problem occurs when I'm using a star schema? When I use a bridge table like this, it becomes a Snowflake schema, which is not good from performance perspective?
@BIConsultingPro
@BIConsultingPro Жыл бұрын
Hi Renuka, Star Schema won't be a snowflake schema with multiple fact tables. this would still be a star schema only. support.sisense.com/kb/en/article/design-a-schema-with-more-than-one-fact-multi-fact-schema
@tajlala7367
@tajlala7367 2 жыл бұрын
HI , nice demo. if i have two tables with one ID column whose ID is repeating in both tables , then i make link table with column by appending tables and remove duplicates. is this approach is good or not? because some cases it is not giving me accurate result, Please guide
@BIConsultingPro
@BIConsultingPro 2 жыл бұрын
Well, ideally, it should be done like this only as you have mentioned. However, instead of Append you should merge tables. Merging would act like a join. However, appending only works when both tables have the same columns
@akshaypatil8155
@akshaypatil8155 Жыл бұрын
primary key and foreign key, both indicates same set of information and one to many cardianlity is done. Here you are using two different columns which does not obey primary key-foreign key relationships....please explain do we also form cardinality between two differenet columns in power BI in real world????
@BIConsultingPro
@BIConsultingPro Жыл бұрын
In the context of using a bridge table to eliminate many-to-many relationships in a data model, the primary key and foreign key relationships are indeed essential, but they may not always follow the traditional primary key-foreign key setup. Let's break down the concept: Many-to-Many Relationships: In a many-to-many relationship, one or more records from one table can be related to multiple records in another table, and vice versa. This creates ambiguity in the data model, as it cannot be directly represented in a relational database. Bridge Table: A bridge table is used to resolve many-to-many relationships. It acts as an intermediary table between the two related tables, breaking down the many-to-many relationship into two separate one-to-many relationships. Primary Key and Foreign Key: In the context of the bridge table, both the primary key and the foreign key play crucial roles. The primary key of the bridge table is usually a combination of the primary keys from the two related tables. This combined key acts as a unique identifier for each relationship in the bridge table. On the other hand, the foreign keys in the bridge table reference the primary keys of the related tables. These foreign keys establish the one-to-many relationship between the bridge table and the related tables. Cardinality in Power BI: In Power BI, the relationship between tables is defined based on the cardinality. Cardinality describes how the rows in one table are related to the rows in another table. In the context of the bridge table, the cardinality is typically set to "One" on the side of the bridge table and "Many" on the sides of the related tables. This one-to-many cardinality relationship between the bridge table and the related tables ensures that each record in the bridge table is linked to one record in each of the related tables. As a result, the many-to-many relationship is effectively resolved. In the real world, bridge tables are commonly used in scenarios where there are complex relationships between entities, such as in sales transactions with multiple products and customers, or in data models involving many-to-many relationships between dimensions and fact tables. Using bridge tables allows for a more flexible and efficient data model, making it easier to perform analytics and reporting in Power BI.
@biswadeepchettri2353
@biswadeepchettri2353 Жыл бұрын
Sir.. In class 10th IT book..chapter rdbms... In the explanation of Many to many relationship..it says that.. "in this relationship, no table has the Primary key column" till now i m unable to understand this.. How could it be possible? In openoffice, I tried to.make a table without PK column but.i could not.. This book is wrong or..i could not understand? Plzz reply sir
@BIConsultingPro
@BIConsultingPro Жыл бұрын
I didn't get. . What do you mean by "In this relationship" here? Could you please explain it so that I can help you. Also, you can email me with the reference book snapshot along with your query at connect@biconsultingpro.com
@biswadeepchettri2353
@biswadeepchettri2353 Жыл бұрын
@@BIConsultingPro ok sir..i will send you the photo....in your mail id..ok sir..
@AverageJoe-Ohio
@AverageJoe-Ohio Жыл бұрын
This example seems abit off. So how did the many in the class ID and student ID columns magically become 1-to-many with the bridge when duplicates in each table were the original issue? Also when you created the new custom column, why didn't you just pull in the specific student ID column vs the entire table and then having to eliminate all the other columns yet again? Seems abit redundant doing it this way but hey, I'm only adding my 2 cents
@BIConsultingPro
@BIConsultingPro Жыл бұрын
Thanks for your feedback. You can help us to improve it if you have any idea.
@aniketgode9643
@aniketgode9643 Жыл бұрын
I have joined silver plan . still perks not being executed. please acknowledge
@BIConsultingPro
@BIConsultingPro Жыл бұрын
Which one is not executed? You can write me an email at connect@biconsultingpro.com
@PankajKumarpankaj_lp
@PankajKumarpankaj_lp 2 жыл бұрын
can we use distinct union to create the table
@BIConsultingPro
@BIConsultingPro Жыл бұрын
Both returns different values. Distinct returns a column while UNION returns a table. So, I don't think so it's possible. However, I'll encourage you to try it.
@cosquncg8774
@cosquncg8774 Жыл бұрын
Hi, if in 1th table have 500 rows but in 2nd table have 650 rows will it be work?
@BIConsultingPro
@BIConsultingPro Жыл бұрын
Yes, only corresponding data would come.
@shwetkumar1719
@shwetkumar1719 3 ай бұрын
How to make this for 3 table
@BIConsultingPro
@BIConsultingPro 3 ай бұрын
Here's how you can implement this in Power BI: 1. Power Query Editor: Use Group By and Merge Queries operations to create bridge tables. 2. Data Model: Create relationships between the tables and bridge tables. 3. DAX Measures: Adjust measures to ensure they correctly use the bridge tables for relationships. Note: You need to create bridge tables such as AB, BC and AC
@deepanshusahu3115
@deepanshusahu3115 Жыл бұрын
Can't you combine it with id column it will be solution
@BIConsultingPro
@BIConsultingPro Жыл бұрын
You can try and share the feedback here
@vishalmane1583
@vishalmane1583 11 ай бұрын
Sir can this thik work in SQL
@BIConsultingPro
@BIConsultingPro 11 ай бұрын
It should and it will
@MrPaunty
@MrPaunty Жыл бұрын
Filter not working, watched your another
@MrPaunty
@MrPaunty Жыл бұрын
I am taking my word back, it's working perfectly. Thanks
@BIConsultingPro
@BIConsultingPro Жыл бұрын
Thank you. I am glad it's helping you.
@Mimmyth3cat
@Mimmyth3cat 10 ай бұрын
Hey Add the file for the practise
@BIConsultingPro
@BIConsultingPro 10 ай бұрын
Apologies! this file is not available now.
@frankgovers8420
@frankgovers8420 2 жыл бұрын
Wrong wrong wrong
@BIConsultingPro
@BIConsultingPro 2 жыл бұрын
Hi Frank, thanks for your feedback! Could you please explain a bit more and help me out to correct this?
@frankgovers8420
@frankgovers8420 2 жыл бұрын
@@BIConsultingProFirst your example , you connect student is to class id ( see scheme), wrong. Also in your movie, wrong @@BIConsultingPro which are needed. So extract the numbers from both tables , create a list, convert list into quert, id and then append them, so only the numbers which are needed in the connecting table. Then tou have to reverse the filters, use crissfilter. Your totals will not be ok, use sumx and i hasone value
@frankgovers8420
@frankgovers8420 2 жыл бұрын
Better remove movie
@pravallikam9777
@pravallikam9777 Жыл бұрын
@@frankgovers8420 Sir I have a doubt why we should not have many to relationships .....what problem do we face if we have many to many relationship?
@frankgovers8420
@frankgovers8420 Жыл бұрын
@@pravallikam9777 , your totals can be wrong!!
@user-yg1ge1gh4o
@user-yg1ge1gh4o 11 ай бұрын
I used this steps, but I am unable to solve my many to many relationships
@BIConsultingPro
@BIConsultingPro 10 ай бұрын
You can just create a bridge table with a column with the Ids from both tables and then connect.
Scenario based on Many-to-many relationship | Power BI Interview
7:04
Секрет фокусника! #shorts
00:15
Роман Magic
Рет қаралды 44 МЛН
Can This Bubble Save My Life? 😱
00:55
Topper Guild
Рет қаралды 86 МЛН
PEDRO PEDRO INSIDEOUT
00:10
MOOMOO STUDIO [무무 스튜디오]
Рет қаралды 19 МЛН
Nurse's Mission: Bringing Joy to Young Lives #shorts
00:17
Fabiosa Stories
Рет қаралды 4,8 МЛН
SQL Server Tutorial - One-to-many and many-to-many table relationships
9:51
Looking at Power BI Many to Many
8:47
Guy in a Cube
Рет қаралды 159 М.
Bidirectional relationships and ambiguity
14:02
SQLBI
Рет қаралды 103 М.
How to Correctly Define Many-To-Many Relationships in Database Design
7:07
Create a Many to Many Relationship Model in Power Pivot
10:58
Секрет фокусника! #shorts
00:15
Роман Magic
Рет қаралды 44 МЛН