1

I have a table Expenses and relative table ExpensesCaterory.

The Expenses table can contains a lot of rows of expenses with diferent catergory.

Does it mean that relationship between table are one(expenses) to many(categories)?

Is it correct on the schema?

enter image description here

1 Answers1

0

It is one-to-many relationship but should be the other way around, one category to many expenses. Think of it as one ExpenseCaterory can have many Expense while one Expense can only be in one ExpenseCaterory, as the image in this wiki:

ExpensesCaterory

1 | Taxi Expense
2 | Electricity Expense
3 | Food Expense
4 | Rent Expense

Expenses

1 | 2000 | Taxi Expense
2 | 360 | Taxi Expense
3 | 8500 | Food Expense
4 | 435 | Taxi Expense
3 | 12000| Electricity Expense

Here, you can see that "one" category Taxi Expense is mapped/related to "many" expenses namely 2000, 360, and 435.

The idea is basically that a record from the "one" side (here is ExpensesCaterory) is related to one or more records in the "many" side (here is Expenses).

Related reference:

  • 1
    It should be the reverse. The "many" side should be the "Expense" side while the "one" side should be the "ExpenseCaterory". Think of it as _one "ExpenseCaterory" can have many "Expense" but one "Expense" can only be in one "ExpenseCaterory"_. – Niel Godfrey Pablo Ponciano Sep 26 '21 at 14:07