0

I need a small help. I am new to postgres and django. I am creating a project in django where there will n number of clients and their data is saved into the database on monthly basis. So my doubts is should i go with only a single table and save all the data inside it or do I have an option to create individual tables dynamically as the user approaches and then save the values into those table?

3
  • It would be a bad idea to use different tables for different clients especially if the clients would be many. Its better to have one table with many client. Depending on the data structure you may have to use foreign keys and just create a table for client and another table for mostly recurring values. e.g. Client table and country table and just like them Commented Apr 12, 2017 at 11:21
  • @Tushortz What i was having in mind was to limit the table size. I need to store the monthly data for the clients and i was guessing if the tables are different for different clients then each table will just carry its own data. even writing the query might be easy. What do you think? Commented Apr 17, 2017 at 4:36
  • In the long run, it will still be a bad idea to maintain the data @Vivek Cu Commented Apr 18, 2017 at 10:44

1 Answer 1

1

In fact you do not need to create a special table for each customer. SQL databases is designed in a manner to keep all similar data in one table. It is much easier to work with them in such a way.

At a moment I'd like to recommend to read about relational databases to better understand ways how to store data in it. Then you'll see how to better design application and data storage.

Sign up to request clarification or add additional context in comments.

3 Comments

Thanks for the advice @Eugene, but what i was thinking to store them as individually as the table size wont grow large(as i need monthly data to be stored) and also i can keep the data for individual clients as separate. I just wanted to know if there was a way possible to do that.
@VivekCu, I understand your idea. But I'm not sure it'll be best solution for a long term. Lots of tables are much harder to maintain. BTW, what problem do you want to solve? May be there's some standard solutions.
Thanks for the solution @Eugene. I guess i will move ahead with a single table for storing all the values.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.