Issue
Currently developing a web application using Spring Boot where a user is expected to upload .CSV files with contacts to populate the database.
- Each .CSV file (contacts list) may have a different set of columns (Such as: Name, Email, Address, etc..).
- Each list may contain thousands of records.
- The application involves reading and writing each of the lists individually.
- The app also must provide for insertion/deletion of columns.
Question 1: what is the best approach to insert such data to the database?
So far I could think of two options:
Having a single table which will contain all the data from all of the lists.
OR
Create a new table for every new list.
Question 2: Whilst the first option is easy to implement using Spring Boot's JPA + Hibernate, I'm not sure how to approach the second one. Since the fields are different from list to list, we cannot provide a resource representation class. Any suggestions?
Question 3: Having resource representation classes and using Hibernate is it even possible to dynamically alter database tables (insertion/deletion of columns)?
Solution
I think you should use MongoDB as your database because it saves data in JSON format, record fields can be different from each other, so maybe in your case it is a good choice.
Answered By - Amir Pezeshk