Time for action - populate the database tables

Populate all the tables with some dummy data. Make sure that you maintain the proper relationships in all the tables by inserting correct foreign keys in their respective fields.

INSERT INTO `posts` (`id`, `title`, `content`, `author_id`, `publish_date`) VALUES
(1, 'Electronics For You', 'EFY- Electronics For You is a magazine for people with a passion for Electronics and Technology. Since the first issue in 1969, EFY has delivered the best in Product Reviews, Hardware and Software comparisons, Technical News, Analysis, Electronics news, about Products, Components, Computer Hardware,Power Supply, Industry Automation, Circuit Designing provided by electronicsforu.com.', 2, '2010-08-02 10:29:28'),
(1, 'Electronics For You', 'EFY- Electronics For You is a magazine for people with a passion for Electronics and Technology. Since the first issue in 1969, EFY has delivered the best in Product Reviews, Hardware and Software comparisons, Technical News, Analysis, Electronics news, about Products, Components, Computer Hardware,Power Supply, Industry Automation, Circuit Designing provided by electronicsforu.com.', 2, '2010-08-02 10:29:28'),
(2, 'What is PHP?', 'PHP Hypertext Preprocessor (the name is a recursive acronym) is a widely used, general-purpose scripting language that was originally designed for web development to produce dynamic web pages.', 3, '2010-03-09 10:31:01'),
(3, 'Nintendo', 'Games that are easy to play and fun for anyone. Nintendo are one of them major players in gaming world. They also develop computer games these days.', 4, '2010-01-05 10:39:21'),
(4, 'Sony PlayStation - Full of life', 'Sony Playstation is one of the leading gaming console of modern times. They are fun to play and people of all age groups enjoy it.', 1, '2010-08-17 10:48:23'),
(5, 'Namespaces in PHP 5.3', 'One of the most significant and welcome features added in PHP 5.3 was that of namespaces. While this has been around in other programming languages, namespaces have finally found their place starting with PHP 5.3.', 2, '2010-04-19 10:50:11'),
(6, 'Leadership Skills', 'Leadership skill is the key to success in any field, be it software industry, automobile industry or any other business.', 2, '2009-02-09 10:55:32'),
(7, 'Ruby on Rails', 'RoR is a rapid web application development framework. It was one of the first framework for developing web applications.', 4, '2010-08-13 13:44:32'),
(8, 'Sphinx search engine', 'Sphinx was created by Andrew Aksyonoff and it can be used along with any programming language.', 1, '2009-04-13 13:46:11'),
INSERT INTO `authors` (`id`, `name`) VALUES
database tablesdatabase tablespopulating(1, 'Amit Badkas'),
(2, 'Aditya Mooley'),
(3, 'Rita Chouhan'),
(4, 'Dr.Tarique Sani'),
INSERT INTO `categories` (`id`, `name`) VALUES
(1, 'Programming'),
(2, 'Games'),
(3, 'Electronics'),
(4, 'PHP'),
(5, 'Search'),
(6, 'Misc'),
INSERT INTO `posts_categories` (`post_id`, `category_id`) VALUES
(1, 1),
(1, 2),
(1, 3),
(2, 1),
(2, 4),
(3, 2),
(3, 3),
(4, 2),
(4, 3),
(5, 1),
(5, 4),
(6, 6),
(7, 1),
(8, 1),
(8, 5);

What just happened?

We populated the database tables with some data. Later on we will index this data and search it using Sphinx.

In the real world this would be an application with some web frontend to manage the blog posts. Here we won't be looking into how to build that frontend as we are just focusing on the search part for now.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset