I am building an app on google app engine which has three different kind of Users(ABC,LMN,XYZ).
This is how my model looks like
User(db.Model): email = db.EmailProperty() username = db.StringProperty() password = db.StringProperty() role = db.IntegerProperty() ## role = 1 for ABC;2 for LMN;3 for XYZ ABC(User): name = db.StringProperty() isSuperHero = db.BooleanProperty() LMN(User): nickname = db.StrngProperty() profession = db.StringProperty() # some other random property XYZ(User): department = db.StringProperty() salary = db.FloatProperty()
I want to provide a single login page wherein all the three users will be able to login to the app.
In the datastore i will have 4 different entity User,ABC,LMN,XYZ records.
There are two approaches as I see :
- 1st approach is by extending the User model: This approach has the disadvantage of storing redundant information(username..etc) in User as well as the other 3 entities.
- 2nd approach is by keeping a reference of User in the three entities(thereby eliminating the redundant columns). The disadvantage I see is that to get the User's email i need to get the User's reference(cost involved is high i guess)
So, the question boils down to the basic fundamental: Should I store the redundant columns in all the entities OR should i store a reference of the respective User in the entities. Can someone provide some example of what will be the data cost(read/write) difference for both the approach?