Access relationship looping example - ms-access

I am struggling with some basics of MS Access 2010/2013. I am not sure if I did hit the limit of it or if I am just using the wrong procedure. I will explain what i need.
Take for example 5 items in a shop, where 3 are items and 2 are a combination of items.
They need to be presented in the same matter, i.e. the combinations of products (bundles), needs to have a number in the same series as those it contains. See figure below:
So far, I created 2 tables. 1 for stand alone products and 1 for bundles. Bundles should be able to include other bundles (This is where i get the problems).
If someone orders, lets say, 10 times Items 5, I need Access to count how many Motherboards (Item 1), how many CPU (item 2) etc. I need a full list of those items, so i hopefully should get a list that says:
10 x Motherboard
10 x CPU
10 x Cabinet
So i don't have to dig into each bundle. Hence, as i see it, the relationsship runs in sort of a loop.
I identify the items to be either a combination or product by a column with "yes/no".
If you have any suggestions, let me know, or if you think i hit the limit.
An alternative method is welcome, as well as a sample of a simple Access database.
For the record, the system is gonna be used for huge machines, creating lists of bolts, nuts, electrical equipment etc. The above is only to explain my thoughts.
Best Regards, Emil.

Related

Individual ranking system causing Database crashes => Revert to Individual Tables?

I ask a similar question (1 table 150,000,000,000 rows) now I will add some details.
500,000 Items
Unlimited # Categories
15 Sections
The site allows users to create their own categories and place as many items into that category. Before they can add anything they must choose what section the category is best represented.
Each of the above will have: id, title, description, imageURL
I have two issues:
Each CATEGORY/ITEM will beable to re-arrange items/categories greatest to worst. COLUMN: rank
Users will be acknowledged for contributing most to category. COLUMN: king
This feature of the site is pretty simple but the ranking process is throwing me for a loop. I have tried multiple test runs cramming as much data into one table as possible but the results are crashing my spirits. The division of data to tables is not easy because of the individual ranking for each category.
The original design was to Have the above 3 and individual tables of each category/item to allow individual ranking(boost speed/performance) then:
User contributor: sectionID, categoryID, itemID, userID
Individual Rank: categoryID/itemID, rank
The outcome would be 150,000,000,000 tabled labyrinth. Has anyone dealt with this concept before? What is the best plan of action? Am I on the right track?
I just got High Performance MySQL, 3rd Edition
Optimization, Backups, and Replication and Beginning PHP and MySQL: From Novice to Professional 4th (fourth) EditionI am not promoting or endorsing these books...
These are the first of many steps I will be taking to tackle this design problem I face. Any comments and assistance will be appreciated. Thoughts; Concerns??

massive iteration

I am looking for a suggestion for the best way to achieve a solution to this problem. I have a table with 135 unique outcomes (prices), each price will effect the outcome of three seperate derivatives, as the price changes, so does the value of each of the three derivatives. Each derivative can have any 1 of up to 21 different quanities attached to it, of which the quanity of the derivative is multipied by the price outcome to get a result for a specific derivative quanity and price.
I have crossjoined the derivative to get all of the unique combonations (90,000+), but when I try to cross join the possible combonations with the prices, the system is too slow and often stops responding. I have also tried to insert each possible combonation using a while loop, extract the statistics needed and then run the next senerio, but to no avail.
In short, what is the best way to form a realitively massive crossjoin or iteration.
Matt

Database structure - most common queries span 3-4 tables. Should I reduce tables?

I am creating a new DB in MySQL for an application and wondered if anyone could provide some advice on the following set up. I'll try and simplify things as best as I can.
This DB is designed to store alerts which are related to specific items created by a user. In turn there is the need to store notes related to the items and/or alerts. At first I considered the following structure...
USERS table - to store basic app user info (e.g. user_id. name, email) - this is the only bit I'm fairly certain does not need to be changed
ITEMS table: contains info on particular item (4 fields or so). Contains user_id to indicate which user created/owns this item
ALERTS table: contains info on the alert, item_id to indicate which item the alert is related to, contains user_id to indicate which user created alert
NOTES table: contains note info, user_id of note owner, item_id if associated with an item, alert_id if associated with alert
Relationships:
An item does not always have an an alert associated with it
An item or alert does not always have a note associated with it
An alert is always associated with an item. More than one alert can be associated with the same item.
A note is always associated with an item or alert. More than one note can be associated with the same item or alert.
Once first created item info is unlikely to be updated by a user.
For arguments sake let's say that each user will create an average of 10 items, each item will have an average of 2 alerts associated with it. There will be an average of 2 notes per item/alert.
Very common queries that will be run:
1) Return all items created by a particular user with any associated alerts and notes. Given a user_id this query would span 3 tables
2) Checking each day for alerts that need to be sent to a user's email address. WHERE alert date==today, return user's email address, item name and any associated notes. This would require a query spanning 4 tables which is why I'm wondering if I need to take a different approach...
Option 1) one table to cover items, alerts and notes. user_id owner for each row. Every time you add a note to an item or alert you are repeating the alert and/or item info. Seems a bit wasteful but item and alert info won't be large.
Option 2) I don't foresee the need to query notes (famous last words?) so how about serializing note data so multiple notes are stored in one row in either the item or alert table (or just a combined alert/item table)
Option 3) Anything else you can think of? I'm asking this question as each option I've considered doesn't feel quite right.
I appreciate this is currently a small project and so performance shouldn't be of great concern and I should just go with the 4 tables. It's more that my common queries will end up being relatively complex that makes me think I need to re-evaluate the structure.
I would say that the common wisdom is to normalize to start and denormalize only when performance data suggest that it's necessary.
Make sure that your tables are indexed properly, with foreign key relationships for JOINs.
If you think you'll end up with a lot of data, this might be a good time to think about a partitioning strategy. Partitioning your fast-growing tables by time would be a good first step.
Four tables is not complex. I commonly write report queries that hit 15 or more tables in a database structure that has hundreds of tables (most with millions of records) and I wouldn't even say our dbs are anything more than medium sized (a typical db in our system might have around 200 gigs of data, so not large at all as databases go). Because they are properly indexed, they still run fast unless I am doing very complex calculations. Normalize, don't even consider denormalizing until you are an experienced database designer who knows better than to worry about the number of tables.

Get all possible configurable product SKU's and option SKU's from Magento Database

I'm not a coder (just a script fiddler) and I've got a particular problem with Magento that I cannot explain in terms of code or data, so I need to explain the situation.
I sell configurable products that come in an array of options. These are furniture products that use various codes that describe the final SKU of the product. I've never fully written or listed every possible SKU outside of any e-commerce product I've used, but always used the in-app options, in Magento's case, custom options, to create an SKU as the customer orders the product.
Now I'm facing a nightmare as I'm finally getting a QuickBooks solution mapped out for our company, but I need to get a file with every possible SKU# to import into QB, so that we can use a download routine (ecc) to grab all the orders from Magento and pop them into QB without having to create each new product on the fly. Each one of my products has the following choices:
BaseSKU#
FinishColorSKU#
FabricComboSKU#
FabricColorSKU#
So, for instance, I sell a chair. The chair's base SKU# is 708. The chair comes in 7 finishes, each with it's own code, so now I have 7 SKU's. Each chair+finish comes in 5 fabric combination styles. Not actual fabric, just the way it's applied to the chair. So 7*5=35 is no problem. Now it starts to get tricky. 2 of those fabric combo styles use only 1 fabric. We have 60 fabrics. 35*60=2100. At this point, this is not impossible to create in excel, a bunch of copying and pasting, but it can be done. Now the other three fabric combo styles use 2 fabrics. I need to create a SKU for every possible combination of fabric. So 60*60=3600 possible combinations of the fabrics alone. Now combine that with 35 different chair+finish combo, that's 126,000 possible SKU's for one product. Multiply that times 300 products, there is no way I could do this by hand in Excel. The final SKU looks like these:
One color chair:
708-117-SC-5708
Chair708+Frame117+SingleColor+Color5708
Two color chair:
708-117-DC-5708-5709
Chair708+Frame117+DualColor+Color5708+Color5709
Now, since these possible combinations exist in the Magento Database, just not combined, is there any way to programmatically create all possible combinations and lump them into an Excel file, or csv, or ANYTHING? Is this possible in Excel? Maybe I just need to download the database, export the right table to Excel and do it there.
Any help would be really appreciated.
EDIT: Was thinking about this, and maybe the simplest way to ask this question would be:
How to make Magento output a list of all possible products and options?
You can use the export functionnality: System -> export/import -> dataflow - profiles -> Export All Products. It's pretty straight-forward to use, but feel free to ask if you need more help.

Interesting Database Architecture Scenario

I am currently in the process of rolling a custom order-processing system. My current structure is pretty standard, invoices, purchase orders, and items are all kept in separate tables. Items know which form(s) they are on by keeping track of the form's id, but forms don't know what items are in them (in the database). This was all well and good until I had a new requirement added to the mix: stocking orders.
The way a stocking order works is that sometimes a customer places an order for more units than what is in stock, so we want to place an order with our supplier for enough units to fulfill the order and replenish our stock. However, we often have to build these orders up as the minimums are pretty high, so one stocking order is usually comprised of several customer orders (sometimes for the same item) PLUS a few line items that are NOT connected to an order and are just for stocking purposes.
This presents a problem with my current architecture because I now need to keep track of what comes in from the stocking orders as often suppliers ship partial orders, where items have been allocated, and which incoming items are for stock.
My initial idea was to create a new database table that mostly mimics the items table, but is kind of like an aggregate (but not calculated) table that only keeps track of the items and their corresponding metadata (how many units received, how many for stock, etc) for only the stocking orders. I would have to keep the two tables in synch if something changed from one of them (like a quantity).
Is this overkill, and maybe there's a better way to do it? Database architecture is definitely not my forte, so I was hoping that someone could either tell me that this is an ok way to do things or that there is a better, more correct way to do it.
Thanks so much!
For what it's worth, what I'm using: VB, .NET 4.0, MySQL 5.0
Also, if you want clarification on anything, please ask! I will be closely monitoring this question.
Visit databaseanswers.com. Navigate to "free data models", and look for "Inventory Management". You should find some good examples.
you didnt mention them but you will need tables for:
SUPPLIERS, ORDERS, and INVENTORY
also, the base tables you mention 'knowing about' - these probably need associative style many to many tables which tell you things like which items are on which order, and which suppliers supply which items, lead times, costs etc.
it would be helpful to see your actual schema.
I use a single Documents table, with a DocType field. Client documents (Order, Invoice, ProForma, Delivery, Credit Notes) are mixed with Suppliers documents (PO, Reception).
This makes it quite easy to calculate Client backorders, Supplier backorders, etc...
I am just a bit unhappy because I have different tables for SUPPLIERS and CLIENTS, and therefore the DOCUMENTS table has both a SupplierId field and a ClientId field, which is a bit bad. If I had to redo it I might consider a single Companies table containing both Clients and Suppliers.
I use a PK (DocId) that's autoincrement, and a unique key (DocNum) that's like XYY00000, with
x= doc type
YY= year
00000 = increment.
This is because a doc can be saved but is only at validation time it receives a DocNum.
To track backorders (Supplier or Client), you will need to have a Grouping field in the DocDetails table, so that if you have an Order line 12345, you copy that Link field to every Detail line related to it (invoice, Delivery).
Hope I am not to confusing. The thing works well, after 3 years and over 50,000 docs.
This approach also implies that you will have a stock holding which is allocated for orders - without individual item tracking its a bit tricky to manage this. Consider, customer A orders
3 pink widgets
1 blue widget
But you only have 1 pink widget in stock - you order 3 pink widgets, and 1 blue.
Customer B orders
2 pink widgets
But you've still only got 1 in stock - you order another pink widget
3 pink widgets arrive from the first supplier order. What are you going to do? You can either reserve all of them for customer A's order and wait for the blue and red widget to arrive, or you can fulfill customer B's order.
What if the lead time on a pink widget is 3 days and for a blue widget it's 3 weeks? Do you ship partial orders to your customers? Do you have a limit on the amount of stock you will hold?
Just keeping a new table of backorders is not going to suffice.
This stuff gets scary complicated really quickly. You certainly need to spend a lot more time analysing the problem.