The difference between MySQL and MongoDB database design
MySQL is the star among relational databases, and MongoDB is the leader among document databases. Let’s compare the two through a design example: Suppose we are maintaining a mobile phone product library, which contains not only basic information such as the name and brand of the mobile phone, but also parameter information such as standby time and appearance design. How should we access the data? If you use MySQL, the basic information of the mobile phone is a separate table. In addition, because the parameter information of different mobile phones is very different, a parameter table is needed to save it separately. CREATE TABLE IF NOT EXISTS `mobiles` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `name` VARCHAR(100) NOT NULL, `brand` VARCHAR(100) NOT NULL, PRIMARY KEY (`id`) ); CREATE TABLE IF NOT EXISTS `mobile_params` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `mobile_id` int(10) unsigned NOT NULL, `name` varchar(100) NOT NULL, `value` varchar(100) NOT NULL, PRIMARY KEY (`id`) ); INSERT INTO `mobiles` (`id`, `name`, `brand`) VALUES (1, ‘ME525’, ‘Motorola’), (2, ‘E7’ , ‘ Nokia’); INSERT INTO `mobile_params` (`id`, `mobile_id`, `name`, `value`) VALUES (1, 1, ‘Standby time’, ‘200’), (2, 1, ‘Appearance design ‘, ‘straight’), (3, 2, ‘standby time’, ‘500’), (4, 2, ‘appearance design’,…