DART, AngularDART and Zend Framework 2 [part 1: introduction & db]

By | 2014/05/07
This entry is part 1 of 4 in the series DART, AngularDART and Zend Framework 2

I am astonished by the DART language developed in Google. It makes my life so easy when I don’t have to remember about all the details the JavaScript developer need to remember. When I don’t have to think about what browser somebody will use, to not think what methods this particular variable has at this particular moment.. and why it is missing the one I want to use now. I will not even say how nice of Google is to deliver also debuger..

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);

Series NavigationDART, AngularDART and Zend Framework 2 [part 2: db connection] >>

Leave a Reply

Your email address will not be published. Required fields are marked *