Home arrow MySQL arrow Page 3 - Data Management Made Easy Using Nennius: Creating a Web Application

Creating SQL Tables - MySQL

Previously, we took a look at the Nennius engine and discussed several out-of-the-box features available to PHP developers. Now we are ready to create our own Nennius web application, and so we will discuss all of the steps necessary to do that.

TABLE OF CONTENTS:
  1. Data Management Made Easy Using Nennius: Creating a Web Application
  2. Configuring a Web Application and Defining Its Menu
  3. Creating SQL Tables
  4. Creating a Nennius Component, Defining the Entry-Point, and the Descriptor File
  5. The Component File
By: Brian Vaughn
Rating: starstarstarstarstar / 10
July 27, 2005

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement

Creating SQL Tables

In many cases, Nennius will be configured to manage p-existing data. However, this is not the case for our sample application. We will need to create three basic SQL tables: one to hold Nennius users, one to hold the news releases we will be creating, and another to act as a Threshold lookup table. The queries for doing this are shown below:

-- create basic news table to contain date, title, and body of release
CREATE TABLE `news` (
  `id` int(3) unsigned zerofill NOT NULL auto_increment,
  `datetime` datetime NOT NULL default '0000-00-00 00:00:00',
  `title` varchar(100) NOT NULL default '',
  `body` text NOT NULL,
  PRIMARY KEY  (`id`)
);

-- create nennius user table holding basic information about user record(s)

CREATE TABLE `users` (
  `id` int(2) unsigned zerofill NOT NULL auto_increment,
  `username` varchar(35) NOT NULL default '',
  `password` varchar(35) NOT NULL default '',
  `name` varchar(35) NOT NULL default '',
  `email` varchar(35) NOT NULL default '',
  `threshold_id` int(2) unsigned zerofill NOT NULL default '00',
  PRIMARY KEY  (`id`),
  KEY `threshold_id` (`threshold_id`)
);

-- insert default user (for demo purposes) of 'admin' w/ password 'admin'
INSERT INTO `users` VALUES (01, 'admin', 'admin', 0, 'admin@corporatewebsite.com', 06);

-- create threshold lookup table
CREATE TABLE `thresholds` (
  `id` int(2) unsigned zerofill NOT NULL auto_increment,
  `name` varchar(25) NOT NULL default '',
  `value` int(3) unsigned NOT NULL default '0',
  PRIMARY KEY  (`id`)
);

-- insert all Nennius-supported threshold types into lookup table
INSERT INTO `thresholds` VALUES (01, 'PUBLIC', 0);
INSERT INTO `thresholds` VALUES (02, 'CLIENT', 10);
INSERT INTO `thresholds` VALUES (03, 'USER', 30);
INSERT INTO `thresholds` VALUES (04, 'REVIEWER', 50);
INSERT INTO `thresholds` VALUES (05, 'MANAGER', 70);
INSERT INTO `thresholds` VALUES (06, 'ADMIN', 90);

As you can see, the structures for our news releases and users tables are fairly basic. The threshold table may not be as intuitive, but we will take a closer at this in Part 3. For now we will continue on to setup our application.



 
 
>>> More MySQL Articles          >>> More By Brian Vaughn
 

blog comments powered by Disqus
   

MYSQL ARTICLES

- Cloudera Named Enterprise Hadoop Leader
- Xeround Releases Free Version of MySQL Cloud...
- Oracle Announces New MySQL Specialization
- Constant Contact Chooses SkySQL for MySQL Su...
- Revoke Statement in MySQL
- The Grant Statement in MySQL
- SuccessBricks Announces ClearDB Availability...
- Building a PHP ORM: Deploying a Blog
- TROSYS Launches Free MySQL Manager and Admin...
- Building an ORM in PHP: Domain Modeling
- Building an ORM in PHP
- MySQL Leads Open Source Market, Gets Cluster...
- Oracle Announces Milestone Release for MySQL
- How to Stop SQL Injection Attacks
- New Defragmentation Solution for SQL Server


© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 5 - Follow our Sitemap

Dev Shed Tutorial Topics: