douxunchen3498 2016-05-30 12:38
浏览 87

CRM应用程序的数据库表结构

I am working on a small CRM application based on PHP & MySQL. I am following SaaS architecture. Single Code base and every client have their own database.

  • Keep in mind all contact informations should be imported from CSV.

  • My objective is to allow clients to modify contact table structure. I mean each client can define their own table structure.

Example:

  • A client from photography industry, like to collect customer information as follows:

    Name, Address, City, State, Country, Phone, email, whatsapp

  • Whereas another client from SEO industry, ike to collect customer information as follows:

    First Name, Last Name, Address, City, State, Country, Phone, email, website, skype

What would be the best table structure to match all needs.

I hope I have explained my question clearly, If you face any difficulty understanding my question, please comment, I will correct it.

  • 写回答

1条回答 默认 最新

  • dss087358 2016-05-30 13:12
    关注

    Allowing the client to modify table structure presents several challenges, not in the least is: What happens if they want to change their structure to add or subtract new fields? How do you add validation code? As well as more complex security concerns...

    An Object-Oriented Database would be a good way to implement this, but you have indicated that MySQL is a requirement, so one way to approach this from an architectural perspective is to have a table of customer specific schema where the customer key maps to specific table schema that can be modified dynamically.

    Forms metadata and associated table operations can be stored in the database to dynamically generate the input fields and such required as they are needed. Since the table schema should be re-generated infrequently, this is not much additional overhead.

    Using XML to represent the schema, I once implemented something like this by implementing functions that generated SQL code and HTML forms based on stored schema. When fields were added or changed, the application generated new XML and associated SQL for modifying the table via XSLT.

    E.G.

    Schema       DBtoSchema( Database )
    DataBase     SchematoDB( XML_Schema )
    Schema       DBTabletoSchema( Table )
    DBTable      SchemaToDBTable( XML_Schema )
    SuccessCode  SchemaAddField( XML_Schema, FieldName, FieldType, FieldValidation)
    SuccessCode  SchemaDeleteField( XML_Schema, FieldName)
    SuccessCode  NewTable( Schema )
    SQLCode      GenerateInsertSQL( Schema )
    SQLCode      GenerateDeleteSQL( Schema )
    HTMLCode     GenerateForm( Schema, xsltCode)
     ... and so on .....
    
    评论

报告相同问题?

悬赏问题

  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示
  • ¥15 求三国群英传pl国战时间的修改方法
  • ¥15 matlab代码代写,需写出详细代码,代价私
  • ¥15 ROS系统搭建请教(跨境电商用途)