I am doing this project, which is basically few modules from an ERP using PHP/MySQL (codeigniter framework).
I'm not sure how should I integrate the Order Placing mechanism (and other multi table dependent) features. Eg. Customer's Order is managed by two MySQL tables, (Order and Order-Detail). Order tables sto开发者_运维技巧res general order information, while Order-Detail stores ordered product information (quantity etc.), since an order can have more than one product ordered.
So, my questions are:
How is this thing basically implemented (the logic behind it)?
How it is called in the industry jargon (so I can google for ready JavaScript/AJAX or PHP libraries or snipets)?
The term for this is relational databases
You can achieve building a relational database using either mysql itself using 'innoDB' driven tables.
The logic behind it is the following (in your case)
You have 3 tables: - Users (with userid, username, userpassword, etc.) - PlacedOrders (with orderid, userid, productid) - OrdersDetails (with orderid, productid, orderdate, ammount, etc.) - Products (with productid, productname, productweith, etc.)
Here all the '...id' names are primary keys
For users the primary id is userid For placedorders the primary id is orderid etc.
But some tables also have another '..id' that is the primary id from another table. like userid in the table placedorders is the primary id from users These id's are called foreignID's
These foreignID's are linked to eachother.
The logic behind it is that for the table placedorders you won't have to include the user name or password, stuff like that.
This prevents redundancy and can improve database efficiency when you have a lot of data.
Just one more hint about how this would be used in a website: A user first logs in using data from the table users. Then he goes to the product page and selects the product and the ammount he wants to order.
Now when placing the order an order will be made inside orderdetails And a all the variables (orderid, productid and userid) will be combined in placedorders
Now for the user this isn't an improvement.
But for you (or the shop) it is. This way to see who has ordered what using data from just the placedorders table
This way you can make a (search) page where you are just one click away from seeing the users' data, product detail and order detail.
Now with some handy scripting you can easily grab the appropriate data from the product, user and order and put these on one page while you don't have everything inside one big messy database
精彩评论