php - How to represent "to be approved" elements in database -
i have model has attribute called type type of user's bag (substitute entities confidentiality).
userscan have multiplebags (one many)bagshave 1typetypehas fieldsname,description- a
bag'stypecan either be:- chosen predetermined set of values; or
- i preload these in database
- specified user
- if
userapplication approved, customtypeadded predetermined set.
- if
- chosen predetermined set of values; or
basically new type's existence depends on user's approval status.
i want ask ideal way represent relationship of these 3 objects.
here strategy:
baghasidofuserbaghasidoftype- populate
typetable predetermined values, , return viewuserchose from
the set of rules above ready-to-go if types predetermined.
the challenge when there to approved values.
to handle new types,
- all custom
types will still addedtypetable typetable haveapproved,date_approvedfield- if predetermined, values
1, current database upload/default time respectively. - if new, values null @ first updated once
userspecified them approved.- i
selectthembag,joinuserthese values
- i
- if predetermined, values
here sample tables:
table user { id pk, approved tinyint, date_approved datetime } table bag { id pk, id_user fk references user(id) not null, id_type fk references type(id) not null } table type { id pk, name not null, description not null, approved tinyint not null, date_approved datetime not null } is proposed solution okay or can please suggest better way deal such business logic?
in definition bag can has 1 user , 1 type, it's nothing more link table n:m relation between user , type. looks intention. no need though user's fields, because attributes of type
approved tinyint, date_approved datetime
Comments
Post a Comment