java - How to store multi data for each users in MySQL -


i have data contain user , text rating. need store database. use mysql database , using java, ide netbeans. after storing these, read , insert new user data.

user: data: doing, class: bad       yes, me, class       how you?, class bad  user: b data: doing, class:       yes, me, class bad       how you?, class bad 

how can store these mysql (xampp) or other database this? thank you

you should learn normalization. proper normalization, have @ least 2 tables, user table , data table. data table this:

user      |      data          |  rating _________________________________________         | doing | bad         | yes, me    |         | how you?       | bad b         | doing | b         | yes, me    | bad b         | how you?       | bad 

other things optionally implement:

  1. the data table have unique (auto_increment) id used primary key
  2. you create user table other user info, such first name, last name, etc. primary key here (a, b) link foreign key in data table. use a, b here used, can use auto_increment field if not have userid.

if users have same exact phrases (or many of same phrases), better structure 3 tables: user table, phrase table, , rating table.

in case phrase table this:

phrase_id |      phrase ________________________________ 1         | doing 2         | yes, me 3         | how you? 

and rating table contain composite primary key of both user_id , phrase_id both foreign key reference user , phrase tables. make rating table this:

user_id | phrase_id |  rating _________________________________________       | 1         | bad       | 2         |       | 3         | bad b       | 1         | b       | 2         | bad b       | 3         | bad 

Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -