O
O
olifem2017-04-25 22:06:04
MySQL
olifem, 2017-04-25 22:06:04

MySQL How to write multiple values ​​in one cell?

users table (user_id[primary], name, citys[external citys_id])
city table (city_id[primary], name)
The citys cell in the users table is foreign-keyed to the city_id cell in the city table
The citys cell in the users table can store more than one values. Those. each user can visit different cities.
How to implement multiple cities for a user, given foreign keys?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton, 2017-04-25
@SPAHI4

I recommend reading about the normalization of the database and the rules for the formation of the plural in English.
In your case, there will be a user_cities relationship table with user_id city_id cells.
You can pervert and make a cities cell with a JSON type, where there will be an array [city1id, city2id, ...]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question