Jump to content

[SOLVED] database inplementation does it look correct please cheers.


redarrow

Recommended Posts

 

advance thank you

 

before i dive into programming my next project does the database inplementation make sence cheers.

 

A small databse for a shop does it make sence please cheers.

<?php

/*

database name                   DATABSE FIELD TYPES
shop                           *********************
****

users
******
account_id                  ** SMALL INT 5 NOT NULL ZERO AUTO_INCREMENT PRIMARY_KEY
account_name                ** VARCHAR 25 NOT NULL**
account_email               ** VARCHAR 40 NOT NULL**
account_surname             ** VARCHAR 40 NOT NULL**
account_address             ** VARCHAR 200  NOT_NULL**
account_post_code           ** VARCHAR 10 NOT NULL**
account_phone_number        ** INT  NOT NULL**
accoubt_activation          ** INT  NOT NULL DEFULT 0 **
account_join_date           ** INT NOT NULL**
account_last_login          ** INT NOT NULL**
account_ip                  ** INT NOT NULL**

products
*********
account_id                 ** SMALL INT 5 NOT NULL ZERO **
product_id                 ** INT NOT NULL AUTO INCREMENT **
account_name               ** VARCHAR 25 NOT NULL **
account_email              ** VARCHAR 40 NOT NULL **
product_item               ** VARCHAR 200 NOT NULL **
product_pic                ** VARCHAR 40 NOT NULL **
product_quinty             ** INT NOT NULL DEFULT 0 **
product_price              ** INT NOT NULL **
purcase_date               ** INT NOT NULL **
note                       ** MEDUIM TEXT NOT NULL **


products_pre_order
******************
account_id                ** SMALL INT 5 NOT NULL ZERO**
account_name              ** VARCHAR 25 NOT NULL **
account_email             ** VARCHAR 40 NOT NULL **
product_id                ** INT NOT NULL **
product_item              ** VARCHAR 200 NOT NULL **
product_price             ** INT NOT NULL **
note                      ** MEDIUM TEXT NOT NULL **

products_free
*************
account_id               ** SMALL INT 5 NOT NULL ZERO **             
account_email            ** VARCHAR 40 NOT NULL **
product_count            ** INT NOT NULL **
product_match            ** INT NOT NULL DEFULT 10 **


products_temp
************
temp_id                   ** SMALL INT 5 NOT NULL ZERO AUTO_INCREMENTB **
product_id                ** INT NOT NULL **
product_item              ** VARCHAR 200 NOT NULL **
product_price             ** INT NOT NULL **
purcase_date              ** INT NOT NULL **


*/

?>

Link to comment
Share on other sites

My $0.02 (I'm not a DB guru, just my opinion from what I've learned so far):

 

Some of your INT fields don't have lengths.

 

I would use WAY more than 40 for an e-mail address field. Depending on the domain, it could reach 30 just with the @domain.tld [i use 100]

 

Depending on how big this db will be, if any of those fields will ALWAYS have a certain number of characters [ex: in my db, user passwords are passed in with an md5 hash so all of them are 32 characters, so i use CHAR(32) instead of VARCHAR(32)] you might want to not let string length be variable. Might save space/time. Someone also once told me to use a power of 2 for length if possible because of how data is stored. Can someone comment on that?

 

Looks like a lot of data is repeated in multiple tables. Create an associative table.

Link to comment
Share on other sites

Ok. So that means you'll have to update it like 5 times if it ever changes. What if they type their address in wrong? That's way too much stuff to update. You'll never be able to remember every single place their email is listed.

 

So you create a table that associates their email with the other tables.

Kind of like this:

account_email

table1_id

table2_id

table3_id

 

You you have the email, then an id for say the user table, the product table, etc.

Link to comment
Share on other sites

associative table with mysql.

 

i understand that i dont really need all those email there in the database but you mention associative table with mysql or a database what your saying that you can set a entry to be the same entry on all mathching fields.

 

now i got all my books out and on a mission how associative table work.

 

 

i can not find any information on associative table in mysql how the hell do you do it i need to no lol.

 

please someone post a proper tutoral or a link going mad here lol.

Link to comment
Share on other sites

solved end result.

 

 

<?php

/*

database name                   DATABSE FIELD TYPES
shop                           *********************
****

users
******
account_id                  ** SMALL INT 5 NOT NULL ZERO AUTO_INCREMENT PRIMARY_KEY
account_name                ** VARCHAR 25 NOT NULL**
account_email               ** VARCHAR 100 NOT NULL**
account_surname             ** VARCHAR 40 NOT NULL**
account_address             ** VARCHAR 200  NOT_NULL**
account_post_code           ** VARCHAR 10 NOT NULL**
account_phone_number        ** INT  20 NOT NULL**
accoubt_activation          ** INT  3 NOT NULL DEFULT 0 **
account_join_date           ** INT 20 NOT NULL**
account_last_login          ** INT 20 NOT NULL**
account_ip                  ** INT 20 NOT NULL**

products
*********
account_id                 ** SMALL INT 5 NOT NULL ZERO **
product_id                 ** INT 5 NOT NULL AUTO INCREMENT **
account_name               ** VARCHAR 25 NOT NULL **
product_item               ** VARCHAR 200 NOT NULL **
product_pic                ** VARCHAR 40 NOT NULL **
product_quinty             ** INT 5 NOT NULL DEFULT 0 **
product_price              ** INT 10 NOT NULL **
purcase_date               ** INT 20 NOT NULL **
note                       ** MEDUIM TEXT NOT NULL **


products_pre_order
******************
account_id                ** SMALL INT 5 NOT NULL ZERO**
account_name              ** VARCHAR 25 NOT NULL **
product_id                ** INT 5 NOT NULL **
product_item              ** VARCHAR 200 NOT NULL **
product_price             ** INT 10 NOT NULL **
note                      ** MEDIUM TEXT NOT NULL **

products_free
*************
account_id               ** SMALL INT 5 NOT NULL ZERO **             
product_count            ** INT 5 NOT NULL **
product_match            ** INT 5 NOT NULL DEFULT 10 **


products_temp
************
temp_id                   ** SMALL INT 5 NOT NULL ZERO AUTO_INCREMENTB **
product_id                ** INT 5 NOT NULL **
product_item              ** VARCHAR 200 NOT NULL **
product_price             ** INT 10 NOT NULL **
purcase_date              ** INT 20 NOT NULL **

paypal
*******

CREATE TABLE paypal_table (
  id int(11) NOT NULL auto_increment,
  payer_id varchar(60) default NULL,
  payment_date varchar(50) default NULL,
  txn_id varchar(50) default NULL,
  first_name varchar(50) default NULL,
  last_name varchar(50) default NULL,
  payer_email varchar(75) default NULL,
  payer_status varchar(50) default NULL,
  payment_type varchar(50) default NULL,
  memo tinytext,
  item_name varchar(127) default NULL,
  item_number varchar(127) default NULL,
  quantity int(11) NOT NULL default '0',
  mc_gross decimal(9,2) default NULL,
  mc_currency char(3) default NULL,
  address_name varchar(255) NOT NULL default '',
  address_street varchar(255) NOT NULL default '',
  address_city varchar(255) NOT NULL default '',
  address_state varchar(255) NOT NULL default '',
  address_zip varchar(255) NOT NULL default '',
  address_country varchar(255) NOT NULL default '',
  address_status varchar(255) NOT NULL default '',
  payer_business_name varchar(255) NOT NULL default '',
  payment_status varchar(255) NOT NULL default '',
  pending_reason varchar(255) NOT NULL default '',
  reason_code varchar(255) NOT NULL default '',
  txn_type varchar(255) NOT NULL default '',
  PRIMARY KEY  (id),
  UNIQUE KEY txn_id (txn_id),
  KEY txn_id_2 (txn_id)
) TYPE=MyISAM;


*/


?>

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.