Jump to content

Structuring tables for data


]{ronic

Recommended Posts

Hey,

 

I have am creating a web app to hold customer and job details.. I have the following table structures to hold the data:

 

CREATE TABLE Customers (
  customerID int(5) NOT NULL auto_increment,
  customer varchar(25) default NULL,
  contact varchar(25) default NULL,
  phone varchar(25) default NULL,
  email varchar(25) default NULL,
  address varchar(25) default NULL,
  PRIMARY KEY (customerid)
) ENGINE = INNODB;


CREATE TABLE Jobs (
  jobID int(5) NOT NULL auto_increment,
  customerID int(5) NOT NULL default '0',
  invoiceNumber varchar(25) default NULL,
  purchasOrder varchar(25) default NULL,
  orderDate datetime NOT NULL default '0000-00-00',
  dateRequired datetime NOT NULL default '0000-00-00',
  jobStatus varchar(25) default NULL,
  PRIMARY KEY (jobID)
) ENGINE = INNODB;


CREATE TABLE vinyl (
  vinylID int(5) NOT NULL auto_increment,
  jobID int(5) NOT NULL default '0',
  colour varchar(25) default NULL,
  font varchar(25) default NULL,
  size varchar(25) default NULL,
  fileLocation varchar(25) default NULL,
  PRIMARY KEY (vinylID)
) ENGINE = INNODB;


CREATE TABLE screenprint (
  screenprintID int(5) NOT NULL auto_increment,
  jobID int(5) NOT NULL default '0',
  colour varchar(25) default NULL,
  font varchar(25) default NULL,
  size varchar(25) default NULL,
  fileLocation varchar(25) default NULL,
  PRIMARY KEY (screenprintID)
) ENGINE = INNODB;


CREATE TABLE items (
  itemID int(5) NOT NULL auto_increment,
  jobID int(5) NOT NULL default '0',
  supplier varchar(25) default NULL,
  code varchar(25) default NULL,
  colour varchar(25) default NULL,
  style varchar(25) default NULL,
  total varchar(25) default NULL,
  dateOrdered varchar(25) default NULL,
  PRIMARY KEY (itemID)
) ENGINE = INNODB;


CREATE TABLE itemsqty (
  itemqtyID int(5) NOT NULL auto_increment,
  itemID int(5) NOT NULL default '0',
  jobID int(5) NOT NULL default '0',
  size varchar(25) default NULL,
  quanity int(5) NOT NULL default '0',
  PRIMARY KEY (itemqtyID)
) ENGINE = INNODB;


CREATE TABLE embroidery (
  embroideryID int(5) NOT NULL auto_increment,
  jobID int(5) NOT NULL default '0',
  code varchar(25) default NULL,
  stitchCount varchar(25) default NULL,
  quanity int(5) NOT NULL default '0',
  PRIMARY KEY (embroideryID)
) ENGINE = INNODB;

Are these tables set out correctly for the collection of data needed. Also.. am I best to use Foreign Keys? My understanding of using foreign keys is not in place for queries as such, more to keep the tables clean of miss matched records etc?

 

Thanks

Edited by ]{ronic
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.