Forum Discussion

cingram11's avatar
cingram11
Regular Visitor
1 year ago
Solved

Relationships/Cardinality

Can someone explain what Relationships and Cardinality do in the context of databases or data modeling? What each particular one does? One to one, Many to one, etc.

  • Anonymous's avatar
    Anonymous
    1 year ago

    Hi cingram11 ,

    Thank you for reaching out to the Microsoft Fabric Community. Also responses provided by AlexisOlson  and speedramps  offer valuable insights, particularly around the concept of column cardinality and how it affects relationship design.

     

    To add further clarity, in the context of Power BI and data modeling, a relationship defines how two tables are logically connected so that data from one table can filter or aggregate data in another. These relationships are governed by cardinality, which refers to how many rows in one table relate to rows in another.

     

    Common types include one-to-one (1:1), one-to-many (1:M), and many-to-many (M:M). For instance, a one-to-many relationship is often created between a dimension table (e.g., Customers) and a fact table (e.g., Sales), where each customer can have many sales records, but each sale belongs to only one customer.

     

    Column cardinality, as explained earlier, describes the number of distinct values in a column and plays a crucial role in determining the most efficient and correct relationship structure. For a detail information in relationship cardinality in Power BI, please refer to the document below: Model relationships in Power BI Desktop - Power BI | Microsoft Learn

     

    Hope this helps. Please reach out for further assistance.
    If this post helps, then please consider to give a kudos and Accept as the solution to help the other members find it more quickly.


    Thank you.

8 Replies

  • Relationships and Cardinality  are 2 different things

    Cardinality is the frequency that somethings occurs

    For example

    The Shop column has low  Cardinality because there is just one value (Asda)
    The Transactiion ID  has high  Cardinality because each is unique
    The Name has medium Cardinality because there are just 3 (Fred, Mark and James)

    This is good learning video about relationships. I recommend you watch it a few times.
    https://www.youtube.com/watch?v=OOs-VWf20E8

    A one to many relationship (as the name suggests) must have a unique value on the parent table.
    For example, the Transaction ID can support a 1:M relataionship because it is unique.
    But Name cant support a 1:M relationship in the above table, because Fred has multiple rows.

    Please click thumbs up and the [accept solution]


     

     

     

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi cingram11 ,

    Thank you for reaching out to the Microsoft Fabric Community. Also responses provided by AlexisOlson  and speedramps  offer valuable insights, particularly around the concept of column cardinality and how it affects relationship design.

     

    To add further clarity, in the context of Power BI and data modeling, a relationship defines how two tables are logically connected so that data from one table can filter or aggregate data in another. These relationships are governed by cardinality, which refers to how many rows in one table relate to rows in another.

     

    Common types include one-to-one (1:1), one-to-many (1:M), and many-to-many (M:M). For instance, a one-to-many relationship is often created between a dimension table (e.g., Customers) and a fact table (e.g., Sales), where each customer can have many sales records, but each sale belongs to only one customer.

     

    Column cardinality, as explained earlier, describes the number of distinct values in a column and plays a crucial role in determining the most efficient and correct relationship structure. For a detail information in relationship cardinality in Power BI, please refer to the document below: Model relationships in Power BI Desktop - Power BI | Microsoft Learn

     

    Hope this helps. Please reach out for further assistance.
    If this post helps, then please consider to give a kudos and Accept as the solution to help the other members find it more quickly.


    Thank you.

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi cingram11 ,

    I wanted to check if you had the opportunity to review the information provided. Please feel free to contact us if you have any further questions. If my response has addressed your query, please accept it as a solution and give a 'Kudos' so other members can easily find it.


    Thank you.

  • Hi cingram11 

    In the context of databases and data modeling—such as in Power BI, SQL Server, or relational databases—relationships define how tables are connected to one another through common fields (typically primary and foreign keys), and cardinality describes the nature of those connections in terms of how many records in one table relate to records in another. The most common types of cardinality are:

    1. One-to-one (1:1): Each row in Table A relates to exactly one row in Table B, and vice versa. This is rare and typically used when data is split into two tables for security, performance, or organizational reasons.

    2. *One-to-many (1: or Many-to-one)**: A single row in the first table relates to multiple rows in the second table. This is the most common relationship. For example, a Customer table (one side) connected to an Orders table (many side), where each customer can have multiple orders.

    3. Many-to-many (M:M): Rows in both tables can relate to multiple rows in the other. For example, a Students table and a Courses table, where each student can enroll in many courses and each course can have many students. This typically requires a bridge (or junction) table to model correctly in relational systems.

    In tools like Power BI, setting the correct relationship and cardinality is crucial because it affects how data is filtered, aggregated, and visualized. A mismatch or incorrect relationship can lead to wrong results, ambiguous joins, or performance issues. Understanding and applying the correct cardinality helps ensure accurate and efficient data modeling.

     

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi @cingram11 ,

    I wanted to check if you had the opportunity to review the information provided. Please feel free to contact us if you have any further questions. If my response has addressed your query, please accept it as a solution and give a 'Kudos' so other members can easily find it.

     

    Thank you.

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi cingram11 ,

     

    May I ask if you have resolved this issue? If so, please mark the helpful reply and accept it as the solution. This will be helpful for other community members who have similar problems to solve it faster.

     

    Thank you.

  • Hi cingram11 

     

    You can accept multiple solutions from helpers and it is polite to do so. Especially if you may need their help again for other questions.  Thank you.