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
    Would one expense be mapped to only one category? Or could one expense be categorized under multiple categories too? – Niel Godfrey Ponciano Sep 26 '21 at 13:40
  • One expense is relative to one category. For exampel amount 2000 is relative to taxi espense –  Sep 26 '21 at 13:43
  • But it can be a lot of expenses for taxi in table expenses –  Sep 26 '21 at 13:44
  • It is one to many, so each category has a lot of expenses, but expense has only one category. –  Sep 26 '21 at 13:56

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:

Niel Godfrey Ponciano
  • 8,708
  • 1
  • 14
  • 29
  • 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 Ponciano Sep 26 '21 at 14:07