Understanding How to Name a Table

Asked 2 years ago, Updated 2 years ago, 34 views

I'm a beginner in SQL.

I'm thinking of developing a household account book app at home to study, but I can't decide the name of the table.

Specifically, I am worried about XXX below.
"Monthly_expense" is mentioned as a candidate, but
It doesn't fit me well, so please give me some advice.

■ Table name
1.XXX—Table that manages annual expense information
■ Column name
ID id
Year_month
Category catg_id
Category name catg_name
Name
Quantity item_num
Price

■ Table name
2.catg_master —Table for managing expense categories
■ Column name
Category ID catg_id
Category Name catg_name

Dear Kabichan,

Thank you for pointing it out.
I have corrected it as follows.
The correction part is ○ and the deletion part is x.

■ Table name
○1.expense: Table for managing expenditure information by year
■ Column name
ID id
○ Date of expenditure: expense_date
Category catg_id
x Category name catg_name
Name
Quantity item_num
Price

■ Table name
2.catg_master —Table for managing expense categories
■ Column name
Category ID catg_id
Category Name catg_name

sql

2022-09-30 19:13

1 Answers

Perhaps this kind of question is not a stack overflow, but a software engineering question, but it seems that there is no Japanese version of software engineering, so I will answer it just in case.

Naming conventions vary from person to person and company, so it's just my personal opinion, but first of all, year_month data type is datetime and ExpenseDate.I think that it will be more flexible to take out data such as daily, monthly, and yearly.

In that case, I think Expense would be good for the table name (in the sense that it is not limited to monthly).

Also, although this is not mentioned in the question, you do not need to include catg_name in the Expense table.The advantage of relational database is that catg_name is to extract catg_name by join the two tables.


2022-09-30 19:13

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.