Hi there,
I have a simple ‘tbl_category’ table which is used in a ‘tbl_users’ table.
Each user can only have one category, so I’d like to store the category id in the ‘tbl_users’ table rather than have a ‘tbl_users_category’ atable, as this seems a little redundant because there would only be one row for each user in the ‘tbl_users_category’ table.
So my layout is like this:
tbl_ category:
id category
1 categoryA
2 categoryB
3 categoryC
...etc
tbl_users:
id user category_id
1 userA 1
2 userB 1
3 userC 3
etc...
Is there a way to use the relations properties in the users model so that I an pull out the correct category name, eg: UserA is in category ‘categoryA’ in the above example. Or would it be easier just to write a new function in the users model to get the category using the users model data (i.e. for userA, find category with id 1) and output?
Thanks,
Stu