My django application need to collect user data(name age country etc) based on his email domain( 'gmail' as in [email protected]).I wist to create a new table every time i encounter a new email domain. Can this be done in django ?
1 Answer
This is a bad idea. Your tables would all have the same structure. All of your data should be stored in a single table, with a domain column to keep the data separate. Why would you want a different table for each domain? Whatever reason you have, there's a better way to do it.
This idea goes against everything in the design of the relational database, and the Django ORM on top of it.
7 Comments
vyi
So that data of a particular domain can be seperate ! and authentic !
Ned Batchelder
@user1504247: I'm not sure what "authentic" means. For "portable", you can extract rows from your table and move the data somewhere else.
vyi
Authentic so that i can give permission to users to manipulate the data of a specific table only !
Ned Batchelder
@user1504247: In a django app, you typically don't use db-level permissions to protect access to data. You use a single db user, and the Django app accesses the database using that db user. Then you implement access controls in the Django app.
vyi
Initially I was thinking of manually setting up new tables using django.db.connection to achieve the same ! But as you suggest this is a 'bad idea'. Are there absolutely no provision of doing this or a better solution(than having a single table !)?
|