php - Customer reviews and calendar entries, etc in a database -


how things customer reviews stored in database? cant imagine there rows each item , columns each review 1 product may have 2 reviews , may have 100+ - id presume stored in separate file reviews surely not 1 file per item! dont know enough storing data able figure 1 out myself!

a similar situation online calendar - there information each appointment (time, duration, location, etc) , there can many of these on each day, every day, users! logical way have table each user appointments in, @ same time seems illogical because if have 1000+ users, thats alot of tables!

basically id know common/best practice way of storing 'big dynamic data'.

customer reviews can stored using 2 tables in one-to-many relationship.

suppose have table containing products/articles/whatever worth reviewing. each of them has unique id , other attributes.

table "products" +-------------------------------------+ | id | name | attribute1 | attribute2 | +-------------------------------------+ 

then make table, name indicating it's about. should contain @ least unique id , column ids other table. let's have email of user submitted review , (obviously) review text itself:

table "products_reviews" +--------------------------------------------+ | id | product_id | user_email | review_text | +--------------------------------------------+ 

so far, good. let's assume you're selling apples.

table "products" +-------------------------------+ | 1 | 'apple' | 'green' | '30$' | +-------------------------------+ 

then, 2 customers come, each 1 buys 1 apple worth 30$ , likes it, both leave review.

table "products_reviews" +-------------------------------------------------------------------------------+ | 1 | 2 | alice@mail.com | 'i these green apples, awesome' | | 2 | 2 | bob@mail.com   | 'these apples rock!'                                 | +-------------------------------------------------------------------------------+ 

so have fetch reviews apples , happy how customers them:

select *  products_reviews  inner join products on products_reviews.product_id = products.id  products.name = 'apple'; 

you can display them under shopping page apples (just don't mention cost 30$).

the same principle applies things online calendar. have 1 table users, , many tables other stuff - appointments, meetings, etc. relate user.

keep in mind, however, things meetings better displayed in many-to-many table, since shared many people (usually). here's link visualizes good, , here's question here on sample code php. go ahead , test yourself.

cheers :)


Comments

Popular posts from this blog

c# - How to get the current UAC mode -

postgresql - Lazarus + Postgres: incomplete startup packet -

angularjs - ng-repeat duplicating items after page reload -