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).
users
can have multiplebag
s (one many)bags
have 1type
type
has fieldsname
,description
- a
bag
'stype
can either be:- chosen predetermined set of values; or
- i preload these in database
- specified user
- if
user
application approved, customtype
added 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:
bag
hasid
ofuser
bag
hasid
oftype
- populate
type
table predetermined values, , return viewuser
chose from
the set of rules above ready-to-go if type
s predetermined.
the challenge when there to approved values.
to handle new type
s,
- all custom
type
s will still addedtype
table type
table haveapproved
,date_approved
field- if predetermined, values
1
, current database upload/default time respectively. - if new, values null @ first updated once
user
specified them approved.- i
select
thembag
,join
user
these 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