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 multiple bags (one many)
  • bags have 1 type
  • type has fields name , description
  • a bag's type can either be:
    • chosen predetermined set of values; or
      • i preload these in database
    • specified user
      • if user application approved, custom type added predetermined set.

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 has id of user
  • bag has id of type
  • populate type table predetermined values, , return view user chose 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 added type table
  • type table have approved , 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 them bag , join user these 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

Popular posts from this blog

java - Jasper subreport showing only one entry from the JSON data source when embedded in the Title band -

mapreduce - Resource manager does not transit to active state from standby -

serialization - Convert Any type in scala to Array[Byte] and back -