Database Management Systems
Introduction
This blog discusses our database management design specifically tailored for credit card data. We start with a visual representation of the Entity Relationship Diagram (ERD) to depict our data architecture. Following this, we proceed to data importation where multiple tables are created to categorize the data, thereby making it easier for users to retrieve the data they need. The data on these tables is sourced from a main table.
Data Import
Firstly, I will CREATE
a database and USE
this database to implement changes.
Then, I will CREATE
the primary table to house the entire database and specify the data type for each column.
Next, I’ll LOAD
the CSV file into this main table. The data will be separated by commas ","
and each new line will be indicated with a "\n"
. The first row will be ignored.
Following that, I will CREATE
the account table, which SELECTS
certain columns from the main table. I will also ADD
table IDs
to this table to facilitate easier connections with other tables.
Similarly, I’ll CREATE
new tables namely: Customer_Information
, Credit_Score, Payment
, and Record
.
1 | DROP DATABASE IF EXISTS creditcard_1; |
Next, we join the tables using the following command:
1 | SELECT r.Record_Table_ID, r.Month, ci.Customer_Table_ID, cs.Score_Table_ID, p.Payment_Table_ID |
Here are some sample queries that can be run on the database:
Find the number of credit cards for customers who have a credit score of ‘Good’ and an annual income greater than $50,000:
1 | SELECT ai.Num_Credit_Card,cs.Credit_Score,ci.Annual_Income |
Find the payment behaviour and monthly balance for customers who have a credit score of ‘Good’, sorted in descending order by monthly balance:
1 | SELECT p.Payment_Behaviour, p.Monthly_Balance, p.Payment_Table_ID, cs.Credit_Score |
Find the names and occupations is Engineer of customers who have a credit score of ‘Good’ and Payment_Behavior of ‘High_spent_Large_value_payments’, sorted in descending order by name.
1 | SELECT ci.Name, ci.Occupation, p.Payment_Behaviour, cs.Credit_Score |
Conclusion
In wrapping up, working on this project has truly opened my eyes to the power and flexibility of database management systems, particularly MySQL. Crafting a system to handle credit card data from scratch, using an Entity-Relationship Diagram (ERD) to map it out, gave me a hands-on understanding of data structures and their importance in organizing complex information.
What really struck me was the experience of building tables, starting from our central ALL_Credit
table and branching out to specialized tables. The transformation from a CSV file to a set of interrelated tables was quite an experience. It was like putting together a puzzle - each table adding a piece to the larger picture, giving us the ability to quickly access and analyze the data we needed.
Performing SQL queries to extract meaningful data was a highlight. From counting credit cards for certain customer profiles to understanding payment behavior trends, each query felt like a new exploration, a chance to discover something unexpected in our data.
Project Members:
- Xiaoge Zhang
- Qiguan Yu
- Hongyi Gao
- Li Shen