- DART, AngularDART and Zend Framework 2 [part 1: introduction & db]
- DART, AngularDART and Zend Framework 2 [part 2: db connection]
- DART, AngularDART and Zend Framework 2 [part 3: Application module]
- DART, AngularDART and Zend Framework 2 [part 4: Recipes module]
Let’s do something with that.. maybe some recipe book?
I’ve chosen: MySQL as data storage, PHP Zend Framework 2 to get data from storage and create web services with those, and DART as UI.
creation of DB:
CREATE TABLE IF NOT EXISTS `recipe` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` text NOT NULL, `author` varchar(50) NOT NULL, `added` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `updated` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin2 AUTO_INCREMENT=1 ;
First table created.. it will be like a metadata storage for each of our recipes.
CREATE TABLE IF NOT EXISTS `recipe_part` ( `recipe_id` int(11) NOT NULL, `part_num` int(11) NOT NULL, `title` text NOT NULL, `body` text NOT NULL, PRIMARY KEY (`recipe_id`,`part_num`) ) ENGINE=InnoDB DEFAULT CHARSET=latin2;
Second table created with actual body of recipe.
ALTER TABLE `recipe_part` ADD CONSTRAINT `recipe_part_ibfk_1` FOREIGN KEY (`recipe_id`) REFERENCES `recipe` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;
Relation between both of the tables has been established. Now we know that each recipe can consist of multiple parts (kind of obvious one).
some sample data (just for testing later on):
INSERT INTO `14303379_recipes`.`recipe` (`id`, `name`, `author`, `added`, `updated`) VALUES (NULL, 'RECIPE1', 'me', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP);