Jump to content

where to start with SQL


danielkraus

Recommended Posts

I have a home test server set up with WAMP. Do I need to learn the basics of php before I start with SQL and MySQL. I am building my first site and have a ton of content that can be categorized in many different ways, and is in most cases. I first looked at XML but I was advised that MySQL would be better suited to my needs. Any help would be greatly appreciated.

Link to comment
Share on other sites

Thanx! I looked for the phpAdmin in hte server files but could not locate it. Am I missing something?
You are running WAMPSERVER I presume.Then you can go to localhost and link from the index page of your www folder.Ore click on the icon on the right bottom of your screen (next to the clock) and it will be listed there.
Link to comment
Share on other sites

although learning php to use mySQL in a website isn't required, you are going to need some way to put/retrieve info from the SQL database, and php would definitely not be a bad choice for that
Depends, maby he wants to use it fo home use only to make a adressbook form example. Btw. if MySQL is installed you should also have access to the console.
Link to comment
Share on other sites

Thanx everyone. I got it now. I am now trying to figure the best or most efficient way of handling my data. I have about 300 companies that will be categorized. But each company can and will be in multiple categories. each comapny will have a URL, name, location(as in physical), a blog address if applicable, and 2 descriptions, one long and one short.My thoughts were to set up relational tables via a key. The first table would contain all of the data but the category. Then uasing the key, have a second table containing all of the possible categories for each company, leaving category fields empty if the category does not apply. Then use JOIN to get the data I need to be presented on the XHTML page.This seems like the most logical way of doing this, at least to me. Any suggestions would be greatly appreciated.

Link to comment
Share on other sites

One table for companies.One table for Categories.And, since there are many companies which could be in multiple categories, one table for company/categories would be recommended as a "connection" between the various possible combinations. Use the primary keys of the first two tables as foreign keys in the co/cat table.

Link to comment
Share on other sites

Are you saying I should put the companies and their respective info into one Table and the categories in another? Basically, should I put all of the other data, the blog, and descriptions etc, into the "company" table and only the categories in another? I will need to study a bit more on "foreign keys" and how to connect the tables. Thanx.

Link to comment
Share on other sites

-- phpMyAdmin SQL Dump-- version 2.11.4-- http://www.phpmyadmin.net---- Host: localhost-- Generation Time: Sep 27, 2008 at 02:47 PM-- Server version: 5.0.51-- PHP Version: 5.2.5SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";---- Database: `content`---- ------------------------------------------------------------ Table structure for table `urls`--DROP TABLE IF EXISTS `urls`;CREATE TABLE IF NOT EXISTS `urls` (  `url_id` smallint(4) unsigned NOT NULL auto_increment,  `url` varchar(60) NOT NULL,  `title` varchar(60) NOT NULL,  `description` tinytext NOT NULL,  PRIMARY KEY  (`url_id`),  UNIQUE KEY `url` (`url`),  FULLTEXT KEY `description` (`description`)) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=5;---- Dumping data for table `urls`--INSERT INTO `urls` (`url_id`, `url`, `title`, `description`) VALUES(1, 'www.php.net', 'PHP: Hypertext Preprocessor', 'The home page of PHP...'),(2, 'www.mysql.com', 'MySQL: The World''s Most Popular Open Source Database', 'The home page of MySQL...'),(3, 'www.w3.org', 'World Wide Web Consortium', 'The home page of the W3C...'),(4, 'www.Zend.com', 'Zend', 'The home page of Zend...');-- ------------------------------------------------------------ Table structure for table `url_associations`--DROP TABLE IF EXISTS `url_associations`;CREATE TABLE IF NOT EXISTS `url_associations` (  `ua_id` smallint(4) unsigned NOT NULL auto_increment,  `url_id` smallint(4) unsigned NOT NULL,  `url_category_id` tinyint(3) unsigned NOT NULL,  `date_submitted` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,  `approved` char(1) NOT NULL default 'N',  PRIMARY KEY  (`ua_id`),  KEY `url_id` (`url_id`),  KEY `url_category_id` (`url_category_id`),  KEY `date_submitted` (`date_submitted`)) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=9;---- Dumping data for table `url_associations`--INSERT INTO `url_associations` (`ua_id`, `url_id`, `url_category_id`, `date_submitted`, `approved`) VALUES(1, 1, 1, '2008-09-27 14:42:32', 'Y'),(2, 1, 4, '2008-09-27 14:42:32', 'Y'),(3, 1, 2, '2008-09-27 14:42:32', 'Y'),(4, 2, 5, '2008-09-27 14:42:32', 'Y'),(5, 2, 2, '2008-09-27 14:42:32', 'Y'),(6, 3, 2, '2008-09-27 14:42:32', 'Y'),(7, 4, 1, '2008-09-27 14:42:32', 'Y'),(8, 4, 3, '2008-09-27 14:42:32', 'Y');-- ------------------------------------------------------------ Table structure for table `url_categories`--DROP TABLE IF EXISTS `url_categories`;CREATE TABLE IF NOT EXISTS `url_categories` (  `url_category_id` tinyint(3) unsigned NOT NULL auto_increment,  `category` varchar(20) NOT NULL,  PRIMARY KEY  (`url_category_id`),  UNIQUE KEY `category` (`category`)) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=7;---- Dumping data for table `url_categories`--INSERT INTO `url_categories` (`url_category_id`, `category`) VALUES(1, 'General PHP'),(2, 'Web Development'),(3, 'Code Libraries'),(4, 'Programming'),(5, 'General MySQL'),(6, 'General Database');

this may help.Notice how the url-associations table is a collection of keys from the other two tables (and the date_submitted for use as a search index).

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...