lundi 13 février 2017

How to design table 1 unique id storing 10 datas

Vote count: -1

I am learning database with mysqli.

I want to know how can I design a table in a way that I can store 10 different datas per unique id but only in 1 table?

is that even possible? or is that the way to do it? should I have 2 different table?

here is what I need

  • id primary key, auto_increment
  • username varchar (30) (should I index this?)
  • wish_list varchar(255)
  • timestamp timestamp

here is what I want it to look like

| id | nickname | wish_list     | timestamp |
| 1  | name1      | wish list1    | 1/3/17       |
|     |                  | wish list2    | 1/3/17       |
|     |                  | wish list10  | 1/4/17       |
| 2  | name2      | wish list1    | 1/4/17       |
|     |                  | wishlist2     | 1/4/17       |

it's a rough sketch but lets say I have a input field on first page to input username and I can input up to 10 data per unique id/nickname on next page.
next time user visits and input username, that user can add something to wishlist.

*forget about security. so anyone can add other users wishlist.
I am doing this because I want to know the process of the database, how it works.

asked 2 mins ago

Let's block ads! (Why?)



How to design table 1 unique id storing 10 datas

Aucun commentaire:

Enregistrer un commentaire