Hello all!
I'm having a bit of a problem conceptualizing a data model here so I'm hoping someone can help me. Basically here's the rundown...
Customers can belong to 1 or more categories (some categories are sub-categories of others). Categories are arranged this way: there are several general categories, each of those has several sub-categories, and those sub-categories each have several of their own categories. What would be the best way to form the relationships between customers and their categories (sub or otherwise)?
What I initially set up so far is this:
I originally thought I could make an associative table that would link the customer_ids to category_ids but I run into the problem of "what if the customer belongs to a sub-category 1 or 2 levels down?". Likewise I don't think it's good practice to have 3 extra columns in the customer table with category, sub-category, etc. loaded into them (is it?). I'm not quite sure how to relate this. Does anyone have any ideas?
Thanks,
jisoo23
I'm having a bit of a problem conceptualizing a data model here so I'm hoping someone can help me. Basically here's the rundown...
Customers can belong to 1 or more categories (some categories are sub-categories of others). Categories are arranged this way: there are several general categories, each of those has several sub-categories, and those sub-categories each have several of their own categories. What would be the best way to form the relationships between customers and their categories (sub or otherwise)?
What I initially set up so far is this:
Code:
customer_table
-customer_id (PK)
-customer_name
-customer_info
category_primary_table
-category_id (PK)
-category_name
category_secondary_table (sub-categories of primarys)
-sub_category_id (PK)
-category_id (FK)
-sub_category_name
category_third_table (sub-categories of secondarys)
-third_category_id (PK)
-sub_category_id {FK)
-third_category_name
I originally thought I could make an associative table that would link the customer_ids to category_ids but I run into the problem of "what if the customer belongs to a sub-category 1 or 2 levels down?". Likewise I don't think it's good practice to have 3 extra columns in the customer table with category, sub-category, etc. loaded into them (is it?). I'm not quite sure how to relate this. Does anyone have any ideas?
Thanks,
jisoo23