Joh*_*ith 5 php mysql database-schema
我正在为用户建立一个网站,以便能够创建自己的个人资料页面,其中包含自己的详细信息,用户还可以创建页面(类似于G +和FB上的页面),但是,他们可以将他们当前的个人帐户与他们的页面或使用不同的帐户创建单独的页面.应该有许多不同的页面(页面类型).
我发现了这张照片:
http://tomtenthij.nl/images/stuff/lovdbyless_schema.png
然而,这似乎非常有趣,我怎样才能以更好的方式构建它,例如:College Page,Collect&University Page,或University Page或Hospital Page或Company Page等.每个都有自己的一组属性等等.帮助将不胜感激.我在想是否Page_type可以帮助我将每个分开,具体取决于它是医院还是公司等.
编辑:我是数据库模式的初学者,我对PHP代码没有任何问题.但是想知道为多个用户,页面等构建数据库模式的更好方法.
我认为 @Uours 位于正确的页面上,但我建议采用稍微不同的方法,该方法允许您定义一次属性,然后在各个页面上使用它们。就像是:
page_types
page_type_id (PK)
page_type_name (e.g. College, College & University, University, Hospital, Company, ...)
page_attributes
page_attribute_id (PK)
page_attribute_name (e.g. Name, Address, City, Country, Email, ...)
page_attribute_input_type (e.g. text, checkbox, date, email, password, radio, textarea, select, ...)
page_attribute_input_options (e.g. list of values, size=, maxlength=, pattern=, ...)
page_type_attributes
page_id (PK, FK)
page_attribute_id (PK, FK)
page_attribute_sequence (PK)
page_type_attribute_label (defaults to page_attribute_name but can be overriden in case the same attribute is used more than once on a page)
users
user_id (PK)
user_name
...
user_pages
user_page_id (PK)
user_id (FK)
user_page_type_id (FK)
user_page_name (What the user calls this page)
user_page_attributes
user_page_attribute_id (PK)
user_id (FK)
user_page_id (FK)
page_attribute_id (FK)
user_page_attribute_value
Run Code Online (Sandbox Code Playgroud)
祝你好运。希望这可以帮助。