1️⃣ 𝗜𝗻𝗶𝘁𝗶𝗮𝗹 𝗗𝗲𝘀𝗶𝗴𝗻 𝗜𝘀𝘀𝘂𝗲: The ExpenseCategory
model was used as a junction table, creating a many-to-many relationship between Expense
and Category
.
2️⃣ 𝗨𝗻𝗻𝗲𝗰𝗲𝘀𝘀𝗮𝗿𝘆 𝗖𝗼𝗺𝗽𝗹𝗲𝘅𝗶𝘁𝘆: In most expense management systems, an 𝗲𝘅𝗽𝗲𝗻𝘀𝗲 𝗯𝗲𝗹𝗼𝗻𝗴𝘀 𝘁𝗼 𝗼𝗻𝗹𝘆 𝗼𝗻𝗲 𝗰𝗮𝘁𝗲𝗴𝗼𝗿𝘆, making ExpenseCategory
unnecessary.
3️⃣ 𝗥𝗲𝗱𝘂𝗻𝗱𝗮𝗻𝘁 𝗥𝗲𝗹𝗮𝘁𝗶𝗼𝗻𝘀𝗵𝗶𝗽𝘀: Instead of having an indirect link via ExpenseCategory
, Expense
can have a 𝗱𝗶𝗿𝗲𝗰𝘁 𝗳𝗼𝗿𝗲𝗶𝗴𝗻 𝗸𝗲𝘆 to Category
.
4️⃣ 𝗗𝗮𝘁𝗮𝗯𝗮𝘀𝗲 𝗢𝗽𝘁𝗶𝗺𝗶𝘇𝗮𝘁𝗶𝗼𝗻: Removing ExpenseCategory
reduces extra joins, making queries simpler and 𝗶𝗺𝗽𝗿𝗼𝘃𝗶𝗻𝗴 𝗽𝗲𝗿𝗳𝗼𝗿𝗺𝗮𝗻𝗰𝗲.
5️⃣ 𝗦𝗶𝗺𝗽𝗹𝗶𝗳𝗶𝗲𝗱 𝗖𝗼𝗱𝗲𝗯𝗮𝘀𝗲: The new approach eliminates redundant code, making entity relationships 𝗲𝗮𝘀𝗶𝗲𝗿 𝘁𝗼 𝘂𝗻𝗱𝗲𝗿𝘀𝘁𝗮𝗻𝗱 𝗮𝗻𝗱 𝗺𝗮𝗶𝗻𝘁𝗮𝗶𝗻.
6️⃣ 𝗨𝗽𝗱𝗮𝘁𝗲𝗱 𝗖𝗮𝘁𝗲𝗴𝗼𝗿𝘆 𝗠𝗼𝗱𝗲𝗹: The Category
entity remains unchanged, storing names like "Food," "Transport," and "Entertainment" along with descriptions.
7️⃣ 𝗨𝗽𝗱𝗮𝘁𝗲𝗱 𝗘𝘅𝗽𝗲𝗻𝘀𝗲 𝗠𝗼𝗱𝗲𝗹: The Expense
entity now directly includes CategoryId
as a foreign key, simplifying data retrieval.
8️⃣ 𝗘𝗮𝘀𝗶𝗲𝗿 𝗤𝘂𝗲𝗿𝘆𝗶𝗻𝗴: Fetching all expenses under a category no longer requires joining an extra table, making 𝗟𝗜𝗡𝗤 𝗮𝗻𝗱 𝗦𝗤𝗟 𝗾𝘂𝗲𝗿𝗶𝗲𝘀 𝗺𝗼𝗿𝗲 𝗲𝗳𝗳𝗶𝗰𝗶𝗲𝗻𝘁.
9️⃣ 𝗙𝗮𝘀𝘁𝗲𝗿 𝗗𝗲𝘃𝗲𝗹𝗼𝗽𝗺𝗲𝗻𝘁 & 𝗠𝗮𝗶𝗻𝘁𝗲𝗻𝗮𝗻𝗰𝗲: A cleaner design means 𝗳𝗲𝘄𝗲𝗿 𝗯𝘂𝗴𝘀, 𝗲𝗮𝘀𝗶𝗲𝗿 𝗱𝗲𝗯𝘂𝗴𝗴𝗶𝗻𝗴, 𝗮𝗻𝗱 𝗿𝗲𝗱𝘂𝗰𝗲𝗱 𝗰𝗼𝗺𝗽𝗹𝗲𝘅𝗶𝘁𝘆 when adding new features.
🔟 𝗙𝗶𝗻𝗮𝗹 𝗗𝗲𝗰𝗶𝘀𝗶𝗼𝗻: The ExpenseCategory
model was 𝗱𝗲𝗹𝗲𝘁𝗲𝗱 𝗳𝗿𝗼𝗺 𝗯𝗼𝘁𝗵 𝘁𝗵𝗲 𝗲𝗻𝘁𝗶𝘁𝘆 𝗹𝗶𝘀𝘁 𝗮𝗻𝗱 𝘁𝗵𝗲 𝗱𝗮𝘁𝗮𝗯𝗮𝘀𝗲, simplifying the design while keeping it functional.
Top comments (0)