boristhescot
boristhescot

Reputation: 129

Should I create a model or just use a string

I'm writing a database (using django) and I can either use a string (max 4 chars) in a few places or I can create a model and reference it in those places. I've looked and I can't find good discussion on the merits of either solution. Because this database is going to be quite large, what solution scales better both in performance and size? Thanks!

Upvotes: 0

Views: 46

Answers (1)

Mohammed Shareef C
Mohammed Shareef C

Reputation: 4050

If you just have a string or a few strings which will be constant, just define it in settings.py. And use it like:

from django.conf import settings
print settings.my_string_1

If it is the case, you can save time by avoiding database access.

If you are going to use many strings which may vary over time, or need insertion, update or delete operations frequently, you have to use database to store it. If you already have a database like MySQL or postgres setup in the project, you can use it. If not, it is enough to use sqlite database if the database size is not going to be large enough.

Upvotes: 1

Related Questions