When I started thinking seriously about building DohFlo, it was tempting to jump straight into ASP.NET Core and start creating pages.
Login page.
Dashboard.
Transactions.
Charts.
Buttons.
All the fun visible stuff.
But before I build those pieces, I need to answer a more basic question:
What information does the application actually need to store?
That’s where I started with the database.
This is the first article in my DohFlo Development Series, where I’m documenting the process of building a personal finance application with C#, ASP.NET Core, Entity Framework Core, SQL, and the other technologies I learn along the way.
The goal isn’t to pretend I know the final architecture before I’ve built the application.
I’m going to build it, make decisions, discover problems, change things, and document what I learn.
For version one, I want to keep the database simple.
What Does DohFlo Need to Do?
Before designing tables, I started with what a user should eventually be able to do.
At a basic level, DohFlo should allow someone to:
- Create financial accounts
- Record transactions
- Track income and expenses
- Assign categories
- Track who was paid
- See account balances
- Eventually create reports and budgets
That gives me clues about the main things—or entities—the database needs to represent.
For the first version, the major ones are:
User
Account
Transaction
Category
Payee
Already, I can begin seeing relationships between them.
Starting With Users
A finance application needs to know who owns the data.
So conceptually:
USER
├── Accounts
└── Transactions
One user can have multiple financial accounts.
For example:
Boolie
├── Checking
├── Savings
├── Credit Card
└── Investment Account
In database terms, that’s a one-to-many relationship.
ONE USER
↓
MANY ACCOUNTS
An Account might eventually contain fields such as:
Id
UserId
Name
AccountType
Balance
CurrencyCode
UserId tells me which user owns the account.
Accounts
An Account represents somewhere money is stored or tracked.
Examples might include:
- Checking account
- Savings account
- Credit card
- Cash account
- Investment account
A simplified table might look like:
Accounts
------------------
Id
UserId
Name
AccountType
Balance
CurrencyCode
I could immediately add twenty more columns.
Bank name.
Account number.
Interest rate.
Credit limit.
Statement date.
Color.
Icon.
But I’m deliberately resisting that.
One thing I’m trying to practice while building DohFlo is:
Don’t design version five while I’m still building version one.
I can always add more later.
Transactions Are the Center of the App
The Transaction table will probably become one of the most important parts of DohFlo.
A transaction might represent:
Paycheck +$2,800
Groceries -$85
Electric Bill -$120
Gas -$42
A basic Transaction could contain:
Transactions
------------------
Id
AccountId
PayeeId
CategoryId
Amount
Date
Notes
IsPending
Now relationships start appearing.
Every Transaction belongs to an Account.
ACCOUNT
↓
TRANSACTIONS
One checking account might have hundreds or thousands of transactions over time.
Again:
ONE ACCOUNT
↓
MANY TRANSACTIONS
Categories
A transaction usually needs some kind of classification.
For example:
Groceries
Housing
Utilities
Transportation
Entertainment
Salary
Freelance Income
I don’t want to store the category text repeatedly inside every transaction if I can avoid it.
Instead, I can create a Category table.
Categories
------------------
Id
Name
Then a transaction can reference the category using:
CategoryId
Conceptually:
Category
↓
Groceries
Transaction
↓
CategoryId = Groceries
One category can be used by many transactions.
ONE CATEGORY
↓
MANY TRANSACTIONS
Payees
I also want to track where money came from or where it went.
That could be:
Giant Eagle
Amazon
Duquesne Light
Employer
Mortgage Company
So another simple table could be:
Payees
------------------
Id
Name
Then:
Transactions.PayeeId
links a transaction to a Payee.
My First Simple Database Picture
At this point, my first version starts looking like this:
USER
|
| 1
|
| many
↓
ACCOUNT
|
| 1
|
| many
↓
TRANSACTION
↙ ↘
PAYEE CATEGORY
Or another way:
Users
↓
Accounts
↓
Transactions
├── Payee
└── Category
This diagram is simple, but it gives me a mental map of the application.
And I can already see how the database will eventually connect to MVC.
DATABASE
↓
EF CORE
↓
CONTROLLER / SERVICES
↓
VIEWMODEL
↓
VIEW
Suddenly the database isn’t an isolated part of the project.
It’s the foundation underneath everything else.
Primary Keys
Each table needs a way to uniquely identify each record.
That’s why I’m using fields like:
Id
For example:
Account
Id = 7
That Id is the primary key.
Even if two accounts have the same name:
Checking
Checking
their IDs remain different.
Id 7 → Checking
Id 12 → Checking
That allows the database to know exactly which record I’m talking about.
Foreign Keys Connect the Tables
Then I have fields like:
UserId
AccountId
PayeeId
CategoryId
Those are foreign keys.
For example:
Transaction
Id = 101
AccountId = 7
PayeeId = 14
CategoryId = 3
Amount = -85.42
That one transaction is saying:
I belong to Account 7.
My payee is Payee 14.
My category is Category 3.
Instead of copying all of the related information into every Transaction row, the database connects records using IDs.
That is one of the main ideas behind a relational database.
Translating the Design Into C#
Eventually Entity Framework Core lets me represent these tables with C# classes.
A simple Transaction entity might start like this:
public class Transaction
{
public int Id { get; set; }
public int AccountId { get; set; }
public int? PayeeId { get; set; }
public int? CategoryId { get; set; }
public decimal Amount { get; set; }
public DateTime Date { get; set; }
public string? Notes { get; set; }
public bool IsPending { get; set; }
}
Notice that some IDs are nullable:
public int? PayeeId { get; set; }
That means I can allow a transaction to exist without requiring a Payee.
Whether that’s the right long-term design is something I can evaluate as the application develops.
And that’s part of the point of this project.
I’m not trying to predict every future requirement before writing the first feature.
What About Split Transactions?
Eventually I want DohFlo to handle more advanced situations.
For example:
Walmart: $150
Groceries $90
Household $40
Pet Supplies $20
One transaction now belongs to multiple categories.
That’s different from:
Transaction
↓
ONE Category
I may eventually need something closer to:
Transaction
↓
TransactionCategorySplit
↓
Categories
That’s a more advanced relationship, and it’s something I want DohFlo to support.
But I don’t necessarily need to solve every part of that on the first screen I build.
I can design enough of the structure to allow the application to grow while still keeping the first implementation manageable.
Why I Started With the Database
Building the database first forced me to stop thinking about buttons and pages for a moment.
Instead, I had to think about the actual domain.
What is an Account?
What is a Transaction?
Who owns it?
What belongs to what?
Which relationship is one-to-many?
Which fields are optional?
Those questions affect nearly every feature I’ll build afterward.
And now when I create something like:
CreateAccountViewModel
I can understand where it fits.
The ViewModel collects information from the user.
The Controller handles the request.
Entity Framework Core maps the C# entity.
And the database stores the Account.
USER
↓
VIEW
↓
VIEWMODEL
↓
CONTROLLER
↓
EF CORE
↓
DATABASE
I’m starting to see the architecture as one connected system instead of separate programming concepts I’m supposed to memorize.
What’s Next for DohFlo?
With the basic database structure mapped out, the next step is to begin turning that design into the application’s actual models and features.
I’ll be documenting things such as:
Designing the Entity Models
↓
Configuring EF Core
↓
Creating Migrations
↓
Building Create Account
↓
Adding Transactions
↓
Adding Validation
↓
Writing Unit Tests
↓
Building the Dashboard
Some things will probably change along the way.
Actually, I’m counting on it.
That’s part of building software.
The goal of this series isn’t to show a perfectly finished application.
It’s to document how I go from an idea, to a database, to C# classes, to working features—and hopefully become a stronger developer while I build it.
