Page 1 of 1

Database Software

Posted: Mon May 17, 2004 7:47 am
by TonyT
OK, the time has come for me to move my paper file system onto a computer. I have about 20 yrs worth of customer files in manilla folders in filing cabinets. (approx 2500 folders) This is for my flooring & tile installation business. My daughter will be doing all of the data entry.

What I want to do is have this info:
Customer Name Street City St Zip Phone(H) Phone(W) Phone(C) Room (bath, kitchen etc) Product Installed (ceramic, hardwood, sheet vinyl, etc) and possibly other fields.

I want a relational database so I can do a search for say "all sheet vinyl work in Annandale, VA" and get the results.

My questions are:

1. What is best way gto do a project like this?
2. Best software (MS Office or OpenOffice.
3. Ideally, I would like to be able to conduct a search of the database using the web browser. Thus I believe this could be done w/ mysql & php. If so, what is best sequence to start this project? e.g. if I create a spreadsheet with all the data can it be used by mysql or another program? (local server only so security not a big issue)

I would prefer to NOT have to install ms office suite because I already have a linux box up and running w/ apache and open office.

I am new to database stuff but could easily make the web pages and forms needed for searches and data entry.

Posted: Mon May 17, 2004 4:27 pm
by cyberskye
I would suggest apache/php/mysql - Especially is the choice is that or msAccess.

I would create the "forms" that will be used for entry/queries first - then your basic tables (real world objects) - then meta tables (or extra columns in existing tables). Think about what types of reports you would like to see - this will drive the meta table structure.

Use atomic values - I'd create a table for Product Installed and then use that row ID# in other tables that reference Product.

Keep the city and state as separate columns so you can index them more easily. (Using Addr1 and Addr2 columns for addresses can make searching for the state expensive) you can use the columns in WHERE clauses.

You can then build a webform for your search Have that generate a master-detail list, a simple count, whatever you like. Dynamic queries are easy to build assign variables to some form fields to generate the column to filter on, then use submitted form values to filter criteria:
[indent]SELECT * from orders
WHERE $searchVar1='<form value1>' AND $searchVar2='<form value2>'

[/indent]As far as starting from a spread sheet, I am not certain how xls files are read. Maybe export your xls to a tab-delim text file (one row per record) then use LOAD to insert into the database (downsode is this must be done per table; which may not be how your data is currently organized):

mysql> LOAD DATA LOCAL INFILE 'tonysTextFile.txt' INTO TABLE tonysTable
-> LINES TERMINATED BY '\r\n'; (only need this if created on windows)


TonyT wrote:OK, the time has come for me to move my paper file system onto a computer. I have about 20 yrs worth of customer files in manilla folders in filing cabinets. (approx 2500 folders) This is for my flooring & tile installation business. My daughter will be doing all of the data entry.

What I want to do is have this info:
Customer Name Street City St Zip Phone(H) Phone(W) Phone(C) Room (bath, kitchen etc) Product Installed (ceramic, hardwood, sheet vinyl, etc) and possibly other fields.

I want a relational database so I can do a search for say "all sheet vinyl work in Annandale, VA" and get the results.

My questions are:

1. What is best way gto do a project like this?
2. Best software (MS Office or OpenOffice.
3. Ideally, I would like to be able to conduct a search of the database using the web browser. Thus I believe this could be done w/ mysql & php. If so, what is best sequence to start this project? e.g. if I create a spreadsheet with all the data can it be used by mysql or another program? (local server only so security not a big issue)

I would prefer to NOT have to install ms office suite because I already have a linux box up and running w/ apache and open office.

I am new to database stuff but could easily make the web pages and forms needed for searches and data entry.

Posted: Mon May 17, 2004 5:50 pm
by YARDofSTUF
2500 folders, damn, I feel sorry for your daughter!

Posted: Mon May 17, 2004 8:20 pm
by TonyT
Thank.
I already have apache and php4 running and use some simple php scripts here & there, such as a secured application d/l page etc.

I have installed mysql-server and set it to load at boot.

Really all I am in need of is a simple script that would allow data entry via a web page form. I can easily create the forms and add the field names later. What I do not know how to do yet is create the database. My current knowledge is of html, css, and a little scripting.

Know of any ready made php scripts that can do what I want? Simpler the better. What I envision is being able to enter customer info using forms on a web page and also being able to view my customer list in a webpage, as well as sort the list by the various headings. And I'd like to be able to have this list split up into say 50 names/per page. Search for a specific name can be added later on if I really need it.

Posted: Tue May 18, 2004 2:58 am
by cyberskye
Hi Tony - how familiar are you with SQL in general?

to administer the database from windows, mysqlcc comes highly recommended - http://dev.mysql.com/downloads/ - scroll to "Mysql Control Center". You can still use the built-in script editor if you're a purist :)

Very cool wysiwyg database admin. Create databases, tables, users, whatever.

This works well for creating the initial table structure. I can help with the form>mysql stuff (updates and selects) - basically you set the form action to the script name (rel path) that will handle the database insert/query. You can post/pm me a list of form fields with a short desc of fields and I can suggest a possible design (table structure) - I am in the middle of a somewhat-related project so this stuff is still fresh to me....php and mysql both have great online docs that have a task-based focus.

I'm building an app for my folks right now. A combination photo gallery, float plan (they live on a boat), guest book, and threaded journal. apache/php/mysql on OpenBSD. This is a lot easier than it looks :)

EDIT: btw - my folks were living in Burke Center before they set to sail :thumb:
TonyT wrote:Thank.
I already have apache and php4 running and use some simple php scripts here & there, such as a secured application d/l page etc.

I have installed mysql-server and set it to load at boot.

Really all I am in need of is a simple script that would allow data entry via a web page form. I can easily create the forms and add the field names later. What I do not know how to do yet is create the database. My current knowledge is of html, css, and a little scripting.

Know of any ready made php scripts that can do what I want? Simpler the better. What I envision is being able to enter customer info using forms on a web page and also being able to view my customer list in a webpage, as well as sort the list by the various headings. And I'd like to be able to have this list split up into say 50 names/per page. Search for a specific name can be added later on if I really need it.

Posted: Tue May 18, 2004 6:34 am
by TonyT
cyberskye

I have no experience at all using mysql, just experience at html.forms etc. I am familiar with some of the terminology cause we use php\mysql for http://www.downloadfast.com.

This is all running on a Debian (stable) box w/ Fluxbox. Can I use mysql control center to setup & config it from my windows system? (off to read about it now)

Burke Center? Very close to where I live. I'm in Fairfax, just a stone's throw from Merrifield off of Prosperity. Sounds like parents are living the good life now.

Posted: Tue May 18, 2004 9:05 am
by TonyT
Could'nt find an apt source for mysql control center for debian woody so I ended up installing phpMyadmin.
http://www.phpmyadmin.net/phpMyAdmin/index.php

This looks like it will work well as I can do all that seems to be necessary via a web browser. Besides, I don't have networking installed on the debian box so the windows port of the mysql control center will not work for me.

cyberskye - I WILL be asking you for assistance with this project! I have been wanting to learn this stuff for a couple of years now. There's a lot of opportunity for using this stuff. I already have clients that I could earn big money from by implementing similar simple databases for their businesses.

I will be reading up on this a bit and then I'll contact you.

Posted: Tue May 18, 2004 11:42 am
by cyberskye
Sounds good -

phpmyadmin is cool. mysqlcc only runs under windows - you'd use it for remote admin. They each do the same thing. phpmyadmin is probably more popular (google on webmin when you get a chance)

Cool thing about SQL - you don't need to tell it *how* to provide the data, you just tell it *what* you want. In that respect, it's much easier to learn than jscript/php, etc.

meanwhile, I'll be working on a reasonable fee schedule ;) Seriously - I've seen you help a lot of people here. It'll be nice to return the favor.

Interesting that your strengths are areas that I am now starting to learn (css, html,jscript). I started my career as a Solaris/Oracle Administrator - intranet datadriven apps on apache. Sadly, my job is no longer terribly technical...still get the itch tho, hence my project for my parents ;)

Have fun,

Skye
TonyT wrote:Could'nt find an apt source for mysql control center for debian woody so I ended up installing phpMyadmin.
http://www.phpmyadmin.net/phpMyAdmin/index.php

This looks like it will work well as I can do all that seems to be necessary via a web browser. Besides, I don't have networking installed on the debian box so the windows port of the mysql control center will not work for me.

cyberskye - I WILL be asking you for assistance with this project! I have been wanting to learn this stuff for a couple of years now. There's a lot of opportunity for using this stuff. I already have clients that I could earn big money from by implementing similar simple databases for their businesses.

I will be reading up on this a bit and then I'll contact you.

Posted: Tue May 18, 2004 8:17 pm
by TonyT
mysqlcc only runs under windows

Actually now there are packages for Debian in Testing & Unstable:
http://packages.debian.org/testing/misc/
I had hoped to find a backport to Debian Stable. (I run a few apps that are 'unstable' releases that have been backported to stable so as to avoid lib conflicts)

Thanks for the offer of help. I definitely will be pursuing this. If you ever need assistance w/ css or html let me know.

This is one of my experiments in css & grayscale color:
http://members.cox.net/aturrisi

Posted: Wed May 19, 2004 11:00 am
by cyberskye
Nice page - as I make some progress I shall definitely be hitting you up for advice :)

Interesting about mycc on X. I don't run X on my openbsd server (which is in a physical DMZ) so I manage mysql from a windows workstation on the internal LAN.
TonyT wrote:Actually now there are packages for Debian in Testing & Unstable:
http://packages.debian.org/testing/misc/
I had hoped to find a backport to Debian Stable. (I run a few apps that are 'unstable' releases that have been backported to stable so as to avoid lib conflicts)

Thanks for the offer of help. I definitely will be pursuing this. If you ever need assistance w/ css or html let me know.

This is one of my experiments in css & grayscale color:
http://members.cox.net/aturrisi

Posted: Wed May 19, 2004 2:15 pm
by TonyT
WOW!
MYSQL and PHPMyAdmin work very well together.
In 15 minutes (after 10 minutes of reading) I was able to create a new database called "E-Mail". I set up a 17 column table in the database and then imported a txt file of my address book. Now I have my entire address book in a database on the server. Can't really "do anything" with it yet except read it, but it's still cool!

My mail client (Courier) exports the address book as a txt file separated by commas with the text already within quotes. So I had to open the txt file in Exel and add a new column at the end and fill it with this: '\n\r
Then I could import it directly and automatically replace the existing table with it.

This is all I really will need to do to create my Customer database. OK daughter, start typing...

cyberskye -
Where's a good online read re sane structuring of the database? Also, simple explanations of how to index the table.

I guess I should first layout what types of searches I will need to perform. (this is called query?) How about a simple read on databases period? The man pages all assume that one knows the basics already, which I do not know already.

Posted: Wed May 19, 2004 2:48 pm
by cyberskye
Ok - now we are into optimization and tuning.

Tables: You can create just a single table for your business if you want - this has significant performance impact on high volume systems, less so if few users/hits. Identify real world objects first - customer, product, project, service, etc - I would have a table for each of those real world objects. Make the first column a simple counter ( customerID - if customers table) by adding the auto_increment statement (see below)

Columns: Use the smallest possible data type and value possible for optimal performance - stay away from varchar, blob, text, etc - use char(40) for example instead of varchar. indexing a variable-sized field really hurts performance. If you want to generate reports on what you have you might also want to create metatables or audit tables (that just track changes)

I have an example of indexing posted below. Have a look at this snippet (i excluded the GRANT statement at the end for security reasons - I can post an example of how to do that too) and ask specific questions about it if you have any:



[indent]

Code: Select all

drop table if exists _trips;

 
 
create table _trips (
 
tripID tinyint(3) unsigned auto_increment NOT NULL,
 
tripName char(40) NOT NULL,
 
tripDescription tinytext default null,
 
tripStartDate date NOT NULL,
 
tripEndDate date NOT NULL,
 
tripStartLoc tinyint(3) unsigned NOT NULL,
 
tripEndLoc tinyint(3) unsigned NOT NULL,
 
tripNotes tinytext default null,
 
tripContactInfo tinytext default null,
 
tripCreated datetime,
 
tripModified timestamp,
 
tripIsLeg tinyint(1) unsigned default 0,
 
extTripID tinyint(3) unsigned NOT NULL,
 
tripLegPosition tinyint(2) unsigned default null,
 
 
 
PRIMARY KEY (id, tripName),
 
INDEX (id, tripName, tripEndLoc, tripStartDate)
 
);

[/size]

[/indent]EDIT:

In the above, you can see a column called extTripID - this is a foreign key (tho mysql doesn't enforce FK constraints yet) to the _extTrips table (exTripID) - this means I don't have to keep the name of the extTrip in every column, I can just it's corresponding ID a 2 digit integer (an auto_increment value in the other table) - this GREATLY speeds up queries as the comparing integers is much faster than comparing ASCII strings.

Skye

Posted: Wed May 19, 2004 3:57 pm
by TonyT
OK, this is over my head. (need handholding here!) I did it all using the gui web aplication. Below are the basic tables or fields I want to have. What's best way to lay it out?

Code: Select all

"Last Name","First Name","Street","State","Zip","Home Phone","Work Phone","Cell Phone","Email Address","Estimate Date","Estimate Price","Job Start Date","Completion Date","Work Description","Referred By",'\n\r


Later on, if wanted, I can add additional items like "Gross Income","Materials List","Materials Cost", etc.

I will probably only need to search the database using Last Name, City & Work Description. If I realize that I need to do other types of searches I guess it can be modified down the line, correct?

I am also concerned with naming of objects. I am used to lower case when using html, esp form names and field names. Obviously the html forms I will be using will have matching field names as the fields in the db tables. I would think this makes is simpler and aligns more with Object Oriented principles, thus future mods will be easier to do without breaking existing code.

BTW, in no hurry here. In the meantime I can have my kid start entering data and saving as a csv file. (am going to use OpenOffice Calc cause it saves a csv file with names wrapped in quotes whilst Exel butchers up txt files.)

Posted: Wed May 19, 2004 4:42 pm
by cyberskye
I would try and get the initial table structure down before she starts entering. Elsewise you may have to do some mapping to have part of the spreadsheet go into one table and other columns into another table...

I would create one table for customers and one for 'work' or however you want to refer it - and other tables per real-world object. If you plan on keeping everyting in one table, you don't gain much benefit from using a database vs. and xls "Find" function.


[indent]_customers (custID tinyint(2) unsigned auto_increment [means you will never insert a value as mysql will do it for you] NOT NULL, fName char(30) NOT NULL default " ", lName char(30) NOT NULL defaulkt " ", street char(48) NOT NULL default " ", state char(2) NOT NULL default " ", zip tinyint(5 or 9) unsigned NOT NULL default 0, hPhone char(10 or 13 if parens and dash), wPhone [same as hPhone], email char(48)


_jobs table (jobID [tinyint auto_increment], custID [this will reference the customers table], estDate date, estPrice int unsigned, jobDesc tinytext (or char(x) if it;s short), refdBy (custID from _customers table)

[/indent]Make sense? NOT NULL and assigning a default value will greatly speed up queries.

I use the convention _(tablename) for tables, databasename_db for databases, and lead of lowercase with column names, capitalizing first letters of words (userName) - this allows me to quickly understand what type of object I am working with.

This way if you have repeat business, you won't have to re-enter personal info. It will also make queries like the one you described in your orig post much faster/easier.

It does make it easier to map form fields ot column names, but you can do the association in your php script so it's not a rule. I use separate php scripts to handle db connectivity parameters and then *include* it in my main script.

Does phpmyadmin allow you to export the sql used to create the tables? This is a good idea as you may need to modify later on or to build your queries. Compare that to what I posted above.

As for adding things later - you can do this, but it may not be as easy as it seems - will it be ok for those new columns to be NULL (another thing that greatly slows queries) - I have found it's best to create complete structures per object, then add new object tables if needed (_materials table, etc). It keeps it much cleaner that way.
TonyT wrote:OK, this is over my head. (need handholding here!) I did it all using the gui web aplication. Below are the basic tables or fields I want to have. What's best way to lay it out?

Code: Select all

"Last Name","First Name","Street","State","Zip","Home Phone","Work Phone","Cell Phone","Email Address","Estimate Date","Estimate Price","Job Start Date","Completion Date","Work Description","Referred By",'\n\r


Later on, if wanted, I can add additional items like "Gross Income","Materials List","Materials Cost", etc.

I will probably only need to search the database using Last Name, City & Work Description. If I realize that I need to do other types of searches I guess it can be modified down the line, correct?

I am also concerned with naming of objects. I am used to lower case when using html, esp form names and field names. Obviously the html forms I will be using will have matching field names as the fields in the db tables. I would think this makes is simpler and aligns more with Object Oriented principles, thus future mods will be easier to do without breaking existing code.

BTW, in no hurry here. In the meantime I can have my kid start entering data and saving as a csv file. (am going to use OpenOffice Calc cause it saves a csv file with names wrapped in quotes whilst Exel butchers up txt files.)

Posted: Wed May 19, 2004 5:13 pm
by TonyT
I agree on the naming convention you use, I will implement that.
I would create one table for customers and one for 'work'

Makes sense to me.
and other tables per real-world object

OK. I belive you mean that if ever I want to add additional stuff like money related, I should create a table just for that, e.g. _income with fields like grossInc, netInc, etc.

And a separate table for _materials w/ fields like storeName, storeLoc, matName, matCost, orderDate, delivDate, etc.

tinyint(2) Where are these things defined? (as in actualy word definitions and how & why to use them) Couldn't find in the manual.

I understand re not letting her start to enter data just yet, makes sense to have the structure determined first. Once that done, I guess I could have her use 1 csv file per table and then just import them into my structure.
Does phpmyadmin allow you to export the sql used to create the tables?

Yes. As zip or gzip or csv.
Below is exported email database, my first run at it.

Code: Select all

# phpMyAdmin MySQL-Dump
# version 2.2.3
# [url]http://phpwizard.net/phpMyAdmin/[/url]
# [url]http://phpmyadmin.sourceforge.net/[/url] (download page)
#
# Host: localhost
# Generation Time: May 19, 2004 at 10:01 AM
# Server version: 3.23.49
# PHP Version: 4.1.2
# Database : `email`
# --------------------------------------------------------

#
# Table structure for table `addresses`
#

CREATE TABLE addresses (
  Last Name text NOT NULL,
  E-Mail Address text NOT NULL,
  Full Name text NOT NULL,
  Company text NOT NULL,
  Address1 text NOT NULL,
  Address2 text NOT NULL,
  Address3 text NOT NULL,
  City text NOT NULL,
  State text NOT NULL,
  Zip Code text NOT NULL,
  Country text NOT NULL,
  Phone Number text NOT NULL,
  Fax Number text NOT NULL,
  Comments text NOT NULL,
  Cellular Numbar text NOT NULL,
  Other Number text NOT NULL,
  FULLTEXT KEY Alias (Last Name),
  FULLTEXT KEY E-Mail Address (E-Mail Address),
  FULLTEXT KEY Name (Full Name),
  FULLTEXT KEY Company (Company),
  FULLTEXT KEY Address1 (Address1),
  FULLTEXT KEY Address2 (Address2),
  FULLTEXT KEY Address3 (Address3),
  FULLTEXT KEY City (City),
  FULLTEXT KEY State (State),
  FULLTEXT KEY Zip Code (Zip Code),
  FULLTEXT KEY Country (Country),
  FULLTEXT KEY Phone Number (Phone Number),
  FULLTEXT KEY Country_2 (Country),
  FULLTEXT KEY Phone Number_2 (Phone Number),
  FULLTEXT KEY Fax Number (Fax Number),
  FULLTEXT KEY Comments (Comments),
  FULLTEXT KEY Cellular Numbar (Cellular Numbar),
  FULLTEXT KEY Cellular Numbar_2 (Cellular Numbar),
  FULLTEXT KEY Other Number (Other Number)
) TYPE=MyISAM;

[/size]

LOL, I just noticed that the time is way off on my linux box! See time above code generated.

Posted: Wed May 19, 2004 5:39 pm
by cyberskye
Seems it made every column a key - which means the value must be unique...for example, you won't be able to have more than one customer from VA (or the USA for taht matter (country))

Those are the worst datatypes - it will take much longer to query 'text' as the whole of the filed is converted to ASCII, sorted, then compared. So if you want to know which has a lower row #, it will convert teh integers to ASCII then compare - versus doing simple math...Since they are variable length, that will also slow things down.

Compare this to the script I posted:

[indent]PRIMARY KEY (id, tripName),

INDEX (id, tripName, tripEndLoc, tripStartDate)
[/indent]Two keys, indexing on four columns. I wouldn't really need to sort based on any other columns for what I am trying to accomplish. If you index everything you gain very little.

Posted: Wed May 19, 2004 6:15 pm
by cyberskye

Posted: Wed May 19, 2004 6:21 pm
by TonyT
cyberskye-
thanks, I grabbed the pdf file.

as for the sql I posted, yeah, that was a test. I pressed the "index" button in phpMyAdmin and voila! I am reading the pdf and soon will comprehend this stuff.

This is adventurous and fun so far! Sort of like when I first began html. All sorts of ideas are popping up, such as how my brothers who are podiatrists are still uising an antiquated patient software (early early dos). They complain to me all the time about it cause newer patient & billing products will cost them upwards to 30k. I'm thinking I will be able to simplify this for them someday. I have several friends with small businesss who lack computer skills and any type of customer database too. I am tasting more future work.

And I also realize that it will cost little to set one up for them. A used pentium system w/ linux and a router. And my database as a template.

Posted: Wed May 19, 2004 7:57 pm
by cyberskye
Once it's in a dbms, it's easy to manipulate or migrate to whatever format you like. A painful first step, but very forward-thinking.

Have fun,

Skye

Posted: Thu May 20, 2004 8:24 am
by TonyT
_customers (custID tinyint(2) unsigned auto_increment [means you will never insert a value as mysql will do it for you] NOT NULL,


What is purpose of this field? Is it a numerical Id? If so, is it then limited to 99 Ids because of length values of 2?

Posted: Thu May 20, 2004 11:37 am
by TonyT
Structure so far for atco database (Anthomy Turrisi Co.)
suggestions?


CREATE TABLE customers (
custID tinyint(2) unsigned NOT NULL auto_increment,
nameF char(30) NOT NULL default '" "',
nameL char(30) NOT NULL default '" "',
street char(48) NOT NULL default '" "',
city char(30) NOT NULL default '" "',
state char(2) NOT NULL default '"',
zip char(10) NOT NULL default '" "',
phoneH char(13) NOT NULL default '" "',
phoneW char(13) NOT NULL default '" "',
phoneC char(13) NOT NULL default '" "',
fax char(13) NOT NULL default '" "',
eMail char(48) NOT NULL default '" "',
PRIMARY KEY (custID)
) TYPE=MyISAM;
(for some reason it shows state default as " instead of " " even though I enter " " for that setting)

CREATE TABLE jobs (
jobID tinyint(2) NOT NULL auto_increment,
custID tinyint(2) NOT NULL default '0',
dateEst date NOT NULL default '0000-00-00',
dateStart date NOT NULL default '0000-00-00',
dateComp date NOT NULL default '0000-00-00',
refBy char(30) NOT NULL default '" "',
jobDescript char(100) NOT NULL default '" "',
PRIMARY KEY (jobID)
) TYPE=MyISAM;

Next step is to create structures for tables that relate customers & jobs with labor & materials. This will keep it simple and aligns w/ my paper records, which will make data entry faster & easier. My paper records look like this example:

Marcia Xxxxxxx
2219 N. Sommerset St.
Arlington, VA 12345
703-533-2813
xxxxxxx@aol.com

Labor: $2,320.00
remove & reinstall commode
remove & dispose vamity
remove & dispose shower doors
remove & dispose existing wall tile
install new shower fixture
install Durock cement backer board
install tile at tub-surround w/ decorative inlays
recessed shelf at right tub wall
install tile at bathroom floor on diagonal pattern
install new medicine cabinet - recessed
install new vanity, sink and sink fixture

Materials: $540.43
7 cartons 6x6 white wall tile
10 linear feet liners (2x8) 16 pcs
52 pcs 2x6 bullnose
9 pcs 3x12 cove base
30 sqft 8x8 floor tile - 2 cartons
3x24 marble threshold
50 lb bag white Full Flex mortar
grout for floor (sanded)
grout for wall (unsanded)
4 Durock backer boards
1 bucket mastic #101
plumbing materials - wax ring, copper fittings and pipe


In all likelyhood, I will never have to query for breakdowns on different types of materials used, I will just want to be able to see which materials were used on what job. I will want to be able to query for labor totals, materials totals, gross income & net income as per custID.

Thus 3 additional tables will be needed:

labor
laborID, custID, labDescript, labTotal

materials
matID, custID, matDescript, matTotal

income
incID, custID, grossInc, netInc

Also, I realized that I can setup one large file in the spreadsheet app for data entry and export specific columns as separate csv files. This will make data entry easiest for my kid.

Posted: Thu May 20, 2004 4:19 pm
by cyberskye
Tony - for my project, 99 entries is more than anticipated. For yours, I'd go with tinyint(3) or (4) for your ID's - it is just a simple counter that makes it much easier to reference/relate one table to another. I would highly recommend you do this for each table.


The new ideas for tables look good. Income will make it very easy to report on. Example:

[indent]SELECT SUM(grossINC) as 'Gross Income', SUM(netINC) as 'Net Income' from _income
WHERE custID=joeBlow
GROUP BY serviceType (or whatever other grouping you'd like)
[/indent]You can have php create a dynamic table for (another topic for reading - "Master-Detail lists" will be useful for report generation)
[indent]
[/indent]

Posted: Thu May 20, 2004 5:18 pm
by TonyT
Thanks.
OK, here's what I have so far and can't think of any other needed tables or fields.

Code: Select all

# phpMyAdmin MySQL-Dump
# version 2.2.3
# [url]http://phpwizard.net/phpMyAdmin/[/url]
# [url]http://phpmyadmin.sourceforge.net/[/url] (download page)
#
# Host: localhost
# Generation Time: May 20, 2004 at 10:06 AM
# Server version: 3.23.49
# PHP Version: 4.1.2
# Database : `atco`
# --------------------------------------------------------

#
# Table structure for table `customers`
#

CREATE TABLE customers (
  custID tinyint(4) unsigned NOT NULL auto_increment,
  nameF char(30) NOT NULL default '" "',
  nameL char(30) NOT NULL default '" "',
  street char(48) NOT NULL default '" "',
  city char(30) NOT NULL default '" "',
  state char(2) NOT NULL default '"',
  zip char(10) NOT NULL default '" "',
  phoneH char(13) NOT NULL default '" "',
  phoneW char(13) NOT NULL default '" "',
  phoneC char(13) NOT NULL default '" "',
  fax char(13) NOT NULL default '" "',
  eMail char(48) NOT NULL default '" "',
  PRIMARY KEY  (custID)
) TYPE=MyISAM;
# --------------------------------------------------------

#
# Table structure for table `income`
#

CREATE TABLE income (
  incID tinyint(4) NOT NULL auto_increment,
  custID tinyint(4) NOT NULL default '0',
  jobID tinyint(4) NOT NULL default '0',
  labID tinyint(4) NOT NULL default '0',
  matID tinyint(4) NOT NULL default '0',
  grossInc decimal(9,0) NOT NULL default '0',
  netInc decimal(9,0) NOT NULL default '0',
  PRIMARY KEY  (incID)
) TYPE=MyISAM;
# --------------------------------------------------------

#
# Table structure for table `jobs`
#

CREATE TABLE jobs (
  jobID tinyint(4) NOT NULL auto_increment,
  custID tinyint(4) NOT NULL default '0',
  dateEst date NOT NULL default '0000-00-00',
  dateStart date NOT NULL default '0000-00-00',
  dateComp date NOT NULL default '0000-00-00',
  refBy char(30) NOT NULL default '" "',
  jobDescript char(100) NOT NULL default '" "',
  PRIMARY KEY  (jobID)
) TYPE=MyISAM;
# --------------------------------------------------------

#
# Table structure for table `labor`
#

CREATE TABLE labor (
  labID tinyint(4) NOT NULL auto_increment,
  custID tinyint(4) NOT NULL default '0',
  jobID tinyint(4) NOT NULL default '0',
  labDescript char(100) NOT NULL default '" "',
  labTotal decimal(8,0) NOT NULL default '0',
  PRIMARY KEY  (labID)
) TYPE=MyISAM;
# --------------------------------------------------------

#
# Table structure for table `materials`
#

CREATE TABLE materials (
  matID tinyint(4) NOT NULL auto_increment,
  custID tinyint(4) NOT NULL default '0',
  jobID tinyint(4) NOT NULL default '0',
  labID tinyint(4) NOT NULL default '0',
  matDescript char(100) NOT NULL default '" "',
  matTotal decimal(8,0) NOT NULL default '0',
  PRIMARY KEY  (matID)
) TYPE=MyISAM;


Posted: Thu May 20, 2004 5:28 pm
by cyberskye
Looks good!


You can add a "GRANT" statement to the end to enable permissions, or you can do this manually and separately. I like to include it in the SQL scripts for future reference (I do NOT keep the sql scripts on the server for security reasons)

Tuning permissions - don't be too selective as to the 'unit of measure' - i.e. grant table permission rather than per-column. If you set a single permission at the column level, each query must analyze the permissions for EACH column that is part of the query - that is way more than you need anyway.

GRANT select, insert, update (delete if you want) on tony_db.*
to dbuser@localhost identified by 'put-your-password-here'

Posted: Thu May 20, 2004 9:49 pm
by TonyT
Thanks.
I figure I'll worry about security after all is set up. Right now, the server is running only locally and no need to open it up to the wan. Once all is completed and running smooth, then I'll figure out how to make a complete backup of the database and store it on my windows box and on cd. Then secure the server box. (right now I have only the root account on the server, don't yell!)