A simple bank structure made with postgreSQL and .NET Core (C#) 8
The database environment is based on four main tables: accounts, users, persons and transactions.
Using concepts of heritage we have in all relationships a one to one scenario:
- One user Belongs to One account (1:1)
- One person Belongs to One user (1:1)
- One transaction Belongs to One account in column account_sender (1:1) and the same happens with account_receiver (1:1) column.
With account_sender and account_receiver we've got all user, person and account information (It's happen across the keys relationship - primary/foreign key).
This database entity have 8 columns:
- account_id: integer not null (primary key)
- agency: string not null
- number: string not null
- starting_capital: double not null (default 0.0)
- balance: double not null (default 0.0)
- created_at: date not null default NOW()
- updated_at: date not null default NOW()
- deleted_at: date nullable
This database entity have 7 columns:
- user_id: integer not null (primary key)
- email: string not null
- password: string not null
- account_id: bigint not null unique (foreign key)
- created_at: date not null default NOW()
- updated_at: date not null default NOW()
- deleted_at: date nullable
This database entity have 8 columns:
- person_id: integer not null (primary key)
- name: string not null
- last_name: string not null
- tax_id: string not null unique
- birthday: date not null
- user_id bigint not null (foreign key)
- created_at: date not null default NOW()
- updated_at: date not null default NOW()
- deleted_at: date nullable
This database entity have 7 columns:
- transaction_id: integer not null (primary key)
- date_transaction: date not null default NOW()
- account_sender: bigint not null (foreign key)
- account_receiver: bigint not null (foreign key)
- transaction_value: double not null
- transaction_type: EnumTransactionType not null -- EnumTransactionType: ('Pix', 'Transference', 'TED', 'DOC')