PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Wed Nov 20, 2019 11:40 pm

All times are UTC - 5 hours




Post new topic Reply to topic  [ 5 posts ] 
Author Message
PostPosted: Wed Jan 28, 2015 3:52 pm 
Offline
Forum Newbie

Joined: Wed Jan 28, 2015 10:49 am
Posts: 3
Hello, for a long time I've been wanting to learn PHP and MySQL and I've finally begun to do so. After following a 15 hour course on Lynda.com, I think I know the basics to be able to construct a small website. Now, I've got a project that I want to try out. My sister works for a company which sells different kinds of products, from makeup to soap. She has requested a small application where she can keep track of her inventory. When she recieves a new order for her inventory, she'll apply it to the application and it will update the database. I somewhat know how to do this, but I'm not sure how I want to build my database. My initial thought was to have individual tables for userdata, products, and then one for each users' inventory list? Is that a bad way to do this? In future, we would really like to be able to offer this to her colleagues as well for them to use. Is there a better way to build my database and how would I go about relating the users to their inventory data? Essentially, I think I'd be able to relate a users' data to another table for their inventory list. I don't see any other apparent way. I'd really like another set of eyes on this :D Please be kind enough to explain it somewhat thoroughly aswell, since I am relatively new to this :wink:

Some notes: I want the website containing an overview over all products in their inventory, making them able to add and remove, alter prices and such using for example forms. Now, I'll be partially able to code it myself, if you can help me decide how to build my database :) Thank you very much in advance, I look forward to interact with the people of this forum :D :D


Top
 Profile  
 
PostPosted: Wed Jan 28, 2015 4:03 pm 
Offline
Moderator
User avatar

Joined: Tue Nov 09, 2010 3:39 pm
Posts: 6425
Location: Montreal, Canada
Multiple users, each with a separate inventory? Is that correct? If so, I'd create a users table for user information, a products table for general info about products (SKU, price, etc), and an inventory table that references user and product IDs and a column for quantity.

_________________


Top
 Profile  
 
PostPosted: Wed Jan 28, 2015 4:11 pm 
Offline
Forum Newbie

Joined: Wed Jan 28, 2015 10:49 am
Posts: 3


Top
 Profile  
 
PostPosted: Wed Jan 28, 2015 4:29 pm 
Offline
Moderator
User avatar

Joined: Tue Nov 09, 2010 3:39 pm
Posts: 6425
Location: Montreal, Canada
That latter sounds closer to right. I was thinking something like this.

Syntax: [ Download ] [ Hide ]
CREATE TABLE `inventory` (
  `id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT,
  `user_id` int(11) UNSIGNED NOT NULL,
  `product_id` int(11) UNSIGNED NOT NULL,
  `quantity` int(11) UNSIGNED NOT NULL,
  PRIMARY KEY (`id`),
  KEY `user` (`user_id`),
  KEY `product` (`product_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

_________________


Top
 Profile  
 
PostPosted: Wed Jan 28, 2015 4:38 pm 
Offline
Forum Newbie

Joined: Wed Jan 28, 2015 10:49 am
Posts: 3


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group