Database Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me



Go Back   Codewalkers ForumsOther TechnologiesDatabase Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
Old January 8th, 2013, 02:15 AM
VincentasG VincentasG is offline
Contributing User
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Nov 2012
Posts: 34 VincentasG User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 6 h 42 m 5 sec
Reputation Power: 1
SQL - How to set up database table for a php Inventory Application

Hi guys,

I'm working on creating a web application using php codeigniter. Essentially this application will have an unlimited amount of users who can add their own products to their own account to track an inventory of products for events.

I have a database with a table for users, events, and products.

My question is, how should I set up a table/ or tables for an unlimited amount of products, unlimited amount of users, and unlimited amount of events. And make it so there is a rolling tally for the inventory.

I'm looking at creating some way of entering how much of the products they bring in to an event and how much they leave with.

Any Ideas?

Reply With Quote
Old January 8th, 2013, 03:13 PM
IAmALlama IAmALlama is offline
Me
Click here for more information. Click here for more information
 
Join Date: Apr 2007
Location: San Diego, CA
Posts: 2,263 IAmALlama User rank is Lance Corporal (50 - 100 Reputation Level)IAmALlama User rank is Lance Corporal (50 - 100 Reputation Level)IAmALlama User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 2 Weeks 1 Day 5 h 51 m 8 sec
Reputation Power: 9
based on the tables you described, just users, events, and products tables, you would probably just want to add a user_id to the products table and then make a join table that has the product id and the event id. from there to get all products of a specific user, you can just do:
Code:
SELECT *
FROM Products
WHERE user_id=:user_id


and to get the products a specific user is bringing to a specific event:
Code:
SELECT *
FROM Products
    JOIN Products_Events
        ON Products.ID=Products_Events.Product_ID
    JOIN Events
        ON Events.ID=Products_Events.Event_ID
    JOIN Users
        ON Users.ID=Products.User_ID
WHERE
    Users.ID=:user_id
    AND Event.ID=:event_id

Reply With Quote
Old January 9th, 2013, 01:15 AM
VincentasG VincentasG is offline
Contributing User
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Nov 2012
Posts: 34 VincentasG User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 6 h 42 m 5 sec
Reputation Power: 1
Thanks for help

Reply With Quote
Reply

Viewing: Codewalkers ForumsOther TechnologiesDatabase Help > SQL - How to set up database table for a php Inventory Application


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap