I have an iOS app that currently uses MySQL as the database backend to store about 2000 records and 10,000 photos. I want to refactor my Objective-C to use Parse instead of the current MySQL and I'm wondering what would be the best way to move my MySQL data to Parse?
Here is the current MySQL structure of my database.
SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
--
-- Database: `mysqlToParsePlatform`
--
-- --------------------------------------------------------
--
-- Table structure for table `awesome_authentication`
--
CREATE TABLE `awesome_authentication` (
`authentication_id` int(11) NOT NULL auto_increment,
`username` varchar(100) NOT NULL,
`password` varchar(100) NOT NULL,
`name` varchar(100) NOT NULL,
`role_id` int(11) NOT NULL,
`is_deleted` int(11) NOT NULL,
`deny_access` int(11) NOT NULL,
PRIMARY KEY (`authentication_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=6 ;
-- --------------------------------------------------------
--
-- Table structure for table `awesome_categories`
--
CREATE TABLE `awesome_categories` (
`category_id` int(11) NOT NULL auto_increment,
`category` varchar(100) NOT NULL,
`category_icon` varchar(100) NOT NULL,
`created_at` int(11) NOT NULL,
`updated_at` int(11) NOT NULL,
`is_deleted` int(11) NOT NULL,
PRIMARY KEY (`category_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=4 ;
-- --------------------------------------------------------
--
-- Table structure for table `awesome_news`
--
CREATE TABLE `awesome_news` (
`news_id` int(11) NOT NULL auto_increment,
`news_content` text NOT NULL,
`news_title` varchar(100) NOT NULL,
`news_url` varchar(100) NOT NULL,
`photo_url` varchar(200) NOT NULL,
`created_at` int(11) NOT NULL,
`updated_at` int(11) NOT NULL,
`is_deleted` int(11) NOT NULL,
PRIMARY KEY (`news_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=3 ;
-- --------------------------------------------------------
--
-- Table structure for table `awesome_photos`
--
CREATE TABLE `awesome_photos` (
`photo_id` int(11) NOT NULL auto_increment,
`photo_url` varchar(200) NOT NULL,
`thumb_url` varchar(200) NOT NULL,
`store_id` int(11) NOT NULL,
`created_at` int(11) NOT NULL,
`updated_at` int(11) NOT NULL,
`is_deleted` int(11) NOT NULL,
PRIMARY KEY (`photo_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=10167 ;
-- --------------------------------------------------------
--
-- Table structure for table `awesome_ratings`
--
CREATE TABLE `awesome_ratings` (
`rating_id` int(11) NOT NULL auto_increment,
`rating` int(11) NOT NULL,
`user_id` int(11) NOT NULL,
`created_at` int(11) NOT NULL,
`updated_at` int(11) NOT NULL,
`store_id` int(11) NOT NULL,
PRIMARY KEY (`rating_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=32 ;
-- --------------------------------------------------------
--
-- Table structure for table `awesome_reviews`
--
CREATE TABLE `awesome_reviews` (
`review_id` int(11) NOT NULL auto_increment,
`review` text NOT NULL,
`store_id` int(11) NOT NULL,
`user_id` int(11) NOT NULL,
`created_at` int(11) NOT NULL,
`updated_at` int(11) NOT NULL,
`is_deleted` int(11) NOT NULL,
PRIMARY KEY (`review_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=5 ;
-- --------------------------------------------------------
--
-- Table structure for table `awesome_stores`
--
CREATE TABLE `awesome_stores` (
`store_id` int(11) NOT NULL auto_increment,
`store_name` varchar(100) NOT NULL,
`store_address` varchar(160) NOT NULL,
`store_desc` text NOT NULL,
`lat` varchar(20) NOT NULL,
`lon` varchar(20) NOT NULL,
`sms_no` varchar(30) NOT NULL,
`phone_no` varchar(30) NOT NULL,
`email` varchar(30) NOT NULL,
`website` varchar(100) NOT NULL,
`category_id` int(11) NOT NULL,
`created_at` int(11) NOT NULL,
`updated_at` int(11) NOT NULL,
`featured` int(11) NOT NULL,
`is_deleted` int(11) NOT NULL,
PRIMARY KEY (`store_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=2027 ;
-- --------------------------------------------------------
--
-- Table structure for table `awesome_users`
--
CREATE TABLE `awesome_users` (
`user_id` int(11) NOT NULL auto_increment,
`full_name` varchar(100) NOT NULL,
`username` varchar(40) NOT NULL,
`password` varchar(40) NOT NULL,
`login_hash` varchar(200) NOT NULL,
`facebook_id` text NOT NULL,
`twitter_id` text NOT NULL,
`email` varchar(100) NOT NULL,
`deny_access` int(11) NOT NULL,
`thumb_url` varchar(100) NOT NULL,
`photo_url` varchar(100) NOT NULL,
PRIMARY KEY (`user_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=19 ;
After spending a lot of time looking for answers, trying to research migration services and looking into writting custom scripts, I decided to try the easiest route first. And that worked!
Hopefully this will help others looking to move similar records from MySQL to Parse.
In order to get my 2,000+ stores records and 10,000+ photos out of the MySQL database, I went to phpMyAdmin and exported the awesome_stores and awesome_photos tables to two separate CSV files using the setting pictured below.
Once you have your CSV files, open your Parse Data Browser and go to the Core tab and look under the Data section pictured below and click on Import.
That will bring up the import dialog box. That looks like this. Name your new Custom Class and then add your .CSV. Make sure that phpMyAdmin does not add an extra line to head of your .csv. If it does, you will get an error when trying to do the import to Parse.
Related
I need to find an open date time in the future and allocate that time in the calendar for that employee based on his/her worktimes Thanks in advance
I have a calendar table, employee(recourse) table ,employee working times and jobs (with Duration)
CREATE TABLE `calendar` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`Subject` varchar(200) DEFAULT NULL,
`DateField` date DEFAULT NULL,
`EndDate` date DEFAULT NULL,
`TimeField` time DEFAULT NULL,
`EndTime` time DEFAULT NULL,
`job_id` int(11) DEFAULT NULL,
`recourse_employee_id` int(11) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1902 DEFAULT CHARSET=utf8;
CREATE TABLE `rc_resources_employee` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(255) DEFAULT NULL,
`categoryid` int(11) DEFAULT NULL,
`login_user_id` int(11) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8;
CREATE TABLE `jobs` (
`Job_ID` int(11) NOT NULL AUTO_INCREMENT,
`Job_Subject` varchar(150) DEFAULT NULL,
`Job_Description` mediumtext,
`Job_Start_Date` date DEFAULT NULL,
`Job_End_Date` date DEFAULT NULL,
`Job_Duration` float DEFAULT NULL,
`Job_Start_Time` time DEFAULT NULL,
`Job_End_Time` time DEFAULT NULL,
`Job_employee` int(11) DEFAULT NULL,
PRIMARY KEY (`Job_ID`)
) ENGINE=InnoDB AUTO_INCREMENT=1875 DEFAULT CHARSET=utf8;
CREATE TABLE `work_hours` (
`wh_id` int(11) NOT NULL AUTO_INCREMENT,
`recourse_id` int(11) unsigned NOT NULL,
`wh_day_of_week` int(11) unsigned NOT NULL,
`wh_start_time` time NOT NULL,
`wh_end_time` time NOT NULL,
PRIMARY KEY (`wh_id`)
) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8;
I have the following sql file to create Table:
CREATE TABLE `patient_namer` (
`id` int unsigned NOT NULL AUTO_INCREMENT,
`id_number` varchar(45) NOT NULL,
`first_name` varchar(45) NOT NULL,
`last_name` varchar(45) NOT NULL,
`father_name` varchar(45) NOT NULL,
`department` varchar(45) NOT NULL,
`case_number` varchar(45) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
INSERT INTO `patient_namer` (`id_number`,`first_name`,`last_name`,`father_name`,`department`,`case_number`) VALUES
('205436340','טל', 'גדכדגדככדג', 'גדכגדכג', 'wowDep', '43625');
However, when I inspect the data in workbench I get the following in first_name column for example: ����. Why is that? As far as I know utf8mb4_unicode_ci Collation should satisfy hebrew charset...
here is my table :
CREATE TABLE `pesanan` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`ref_number` varchar(50) NOT NULL DEFAULT '',
`id_produk` int(11) NOT NULL,
`id_user` int(11) NOT NULL,
`qty` int(11) NOT NULL,
`total` varchar(50) NOT NULL DEFAULT '',
`tanggal` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=10 DEFAULT CHARSET=latin1;
i want to create a relation of id_produk to table produk.id and id_user to user.id, here is the other table :
CREATE TABLE `produk` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`id_kategori` int(11) NOT NULL,
`status` varchar(10) NOT NULL DEFAULT '',
`slug` varchar(100) NOT NULL DEFAULT '',
`judul` varchar(100) NOT NULL DEFAULT '',
`harga` varchar(10) DEFAULT '',
`target` int(11) DEFAULT NULL,
`desc` text,
`cover` varchar(100) DEFAULT NULL,
`tanggal` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=29 DEFAULT CHARSET=latin1;
and user table
CREATE TABLE `user` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`suspended` int(11) DEFAULT NULL,
`level` varchar(11) DEFAULT NULL,
`nama` varchar(100) DEFAULT NULL,
`email` varchar(100) DEFAULT NULL,
`password` varchar(100) DEFAULT NULL,
`alamat` text,
PRIMARY KEY (`id`),
UNIQUE KEY `email` (`email`)
) ENGINE=InnoDB AUTO_INCREMENT=23 DEFAULT CHARSET=latin1;
when i try to relation it , it give me this error :
Error creating foreign key on id_produk (check data types)
The columns should have the exact same data type in both tables. In your case in the "produk" and "user" tables they are unsigned, which means they go from 0 to 4294967295 but in the "pesanan" table they are signed which means they go from -2147483648 to 2147483647. See more here.
If the server allowed you to create such foreign keys, it would possibly create situations where, for example, a user is added with and ID of 2147483648 that cannot ever be referenced in the "pesanan" table.
You should change the "id_produk" and "id_user" columns in the "pesanan" table to be unsigned.
I have following structure on mysql database:
sqlfiddle
What I want to do is:
To select DISTINCT industry from Company table
To insert into Industry table first and get auto incremented ID
With this ID to insert again into IndustryTranslation table and set "language"="en"
To insert Company's id and newly generated Industry's id into MapCompanyIndustry table
I know that it's not possible with one statement. But definitely it's possible with transaction. Can't figure out how to achieve this result with one transaction.
Any suggestions?
Schema
CREATE TABLE `Industry` (
`id` int(4) unsigned NOT NULL AUTO_INCREMENT,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `IndustryTranslation` (
`industryID` int(4) unsigned NOT NULL,
`language` varchar(5) NOT NULL,
`name` varchar(255) NOT NULL,
`confirmed` tinyint(1) DEFAULT '0',
PRIMARY KEY (`industryID`,`language`),
KEY `language` (`language`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `Company` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(255) DEFAULT NULL,
`imageUri` varchar(255) DEFAULT NULL,
`countryID` int(3) unsigned DEFAULT NULL,
`phone` varchar(255) DEFAULT NULL,
`email` varchar(255) DEFAULT NULL,
`verified` tinyint(1) DEFAULT NULL,
`industry` varchar(255) DEFAULT NULL,
`headquarters` varchar(255) DEFAULT NULL,
`uri` varchar(255) DEFAULT NULL,
`createdAt` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
`updatedAt` timestamp NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
KEY `countryID` (`countryID`)
) ENGINE=InnoDB AUTO_INCREMENT=4004 DEFAULT CHARSET=utf8;
CREATE TABLE `MapCompanyIndustry` (
`companyID` int(10) unsigned NOT NULL,
`industryID` int(4) unsigned NOT NULL,
PRIMARY KEY (`companyID`,`industryID`),
KEY `industryID` (`industryID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
I have spent the past week mulling over this single MySQL document with no luck as to figuring out what/where the error is that's stopping it from properly installing it's self so I can have the chat system it's for up and running. I would go to the developer but he's essentially been unresponsive for over a year now so I have given up on help from him. The error I am getting upon trying to install it is the following :
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server >version for the right syntax to use near '(14) NOT NULL, userid int(11) default NULL, >banneduserid int(11) default NULL, r' at line 1
The MySQL file reads as follows :
#--------------------------------------------------------------------------
# Table structure for table `bans`
#--------------------------------------------------------------------------
CREATE TABLE `bans` (
`created` timestamp(14) NOT NULL,
`userid` int(11) default NULL,
`banneduserid` int(11) default NULL,
`roomid` int(11) default NULL,
`ip` varchar(16) default NULL,
KEY `userid` (`userid`),
KEY `created` (`created`)
) ENGINE=MyISAM;
#--------------------------------------------------------------------------
# Table structure for table `connections`
#--------------------------------------------------------------------------
CREATE TABLE `connections` (
`id` varchar(32) NOT NULL default '',
`updated` timestamp(14) NOT NULL,
`created` timestamp(14) NOT NULL,
`userid` int(11) default NULL,
`roomid` int(11) default NULL,
`state` tinyint(4) NOT NULL default '1',
`color` int(11) default NULL,
`start` int(11) default NULL,
`lang` char(2) default NULL,
`ip` varchar(16) default NULL,
`tzoffset` int(11) default '0',
`chatid` int(11) NOT NULL default '1',
PRIMARY KEY (`id`),
KEY `userid` (`userid`),
KEY `roomid` (`roomid`),
KEY `updated` (`updated`)
) ENGINE=MyISAM;
#--------------------------------------------------------------------------
# Table structure for table `ignors`
#--------------------------------------------------------------------------
CREATE TABLE `ignors` (
`created` timestamp(14) NOT NULL,
`userid` int(11) default NULL,
`ignoreduserid` int(11) default NULL,
KEY `userid` (`userid`),
KEY `ignoreduserid` (`ignoreduserid`),
KEY `created` (`created`)
) ENGINE=MyISAM;
#--------------------------------------------------------------------------
# Table structure for table `messages`
#--------------------------------------------------------------------------
CREATE TABLE `messages` (
`id` int(11) NOT NULL auto_increment,
`created` timestamp(14) NOT NULL,
`toconnid` varchar(32) default NULL,
`touserid` int(11) default NULL,
`toroomid` int(11) default NULL,
`command` varchar(255) NOT NULL default '',
`userid` int(11) default NULL,
`roomid` int(11) default NULL,
`txt` text,
PRIMARY KEY (`id`),
KEY `touserid` (`touserid`),
KEY `toroomid` (`toroomid`),
KEY `toconnid` (`toconnid`),
KEY `created` (`created`)
) ENGINE=MyISAM AUTO_INCREMENT=14 ;
#--------------------------------------------------------------------------
# Table structure for table `rooms`
#--------------------------------------------------------------------------
CREATE TABLE `rooms` (
`id` int(11) NOT NULL auto_increment,
`updated` timestamp(14) NOT NULL,
`created` timestamp(14) NOT NULL,
`name` varchar(64) NOT NULL default '',
`password` varchar(32) NOT NULL default '',
`ispublic` char(1) default NULL,
`ispermanent` int(11) default NULL,
PRIMARY KEY (`id`),
KEY `name` (`name`),
KEY `ispublic` (`ispublic`),
KEY `ispermanent` (`ispermanent`),
KEY `updated` (`updated`)
) ENGINE=MyISAM AUTO_INCREMENT=5 ;
#--------------------------------------------------------------------------
# Table structure for table `users`
#--------------------------------------------------------------------------
CREATE TABLE `users` (
`id` int(11) NOT NULL auto_increment,
`login` varchar(32) NOT NULL default '',
`password` varchar(32) NOT NULL default '',
`roles` int(11) NOT NULL default '0',
`profile` text,
PRIMARY KEY (`id`),
KEY `login` (`login`)
) ENGINE=MyISAM AUTO_INCREMENT=2 ;
My guess is that there is an older call/request that is out dated and no longer used for the version of MySQL I have installed on my host ( Version : 5.5.19 ). I really appreciate any help I can get with this so I can finally stop running off of a flat file ( the other install option this thing has ) and integrate it into my CMS. Thank you for your time!
-Reiz
Remove the (14) from all your timestamp types like that
... column_name timestamp NOT NULL ...
In MySQL versions after 4.1 the timestamp datatype has no properties added in brackets.
MySQL Docu 4.1
MySQL Docu 5.1
So in your case just drop the (14) after all appearances of timestamp in the sql. So, e.g., change this
`created` timestamp(14) NOT NULL,
to this
`created` timestamp NOT NULL,