How to make db structure for multiple input in MySQL and PHP
Below is my current structure for MySQL database
id | item_name | item_files
------------------------------------------
1 | Item A 开发者_如何学编程 | file1.zip,file2.zip,file3.zip
2 | Item B | file3.zip
Example I create simple form to fill up Item Name
and Multiple upload files
then store it to db.
Question :-
- How to design the db structure for accept the multiple files?
- There have a way which I don't want to use
explode
,implode
to get thefile1.zip file2.zip file3.zip
Normalize your data tables
items table
id | item_name
--------------
1 | Item A
2 | Item B
item_files table
id | item_id | item_files
-----------------------------------
1 | 1 | file1.zip
2 | 1 | file2.zip
3 | 1 | file3.zip
4 | 2 | file3.zip
精彩评论