![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Hi I have a real headache of a problem and was wondering if anyone can help me. I'm writing a system that saves stock items. Each item can have none or an infinite number of options attached to it. For example you can have a cupboard door as one stock item or you can have a Polo Neck sweater with the options of size:small, medium, large and colour: red, green, blue. My problem is that I have no idea how to store this information in the database. My first thought was three tables STOCK_ITEMS, STOCK_OPTIONS, OPTION_VALUES The item name would be stored in STOCK_ITEMS with the option names in STOCK_OPTIONS and their values in OPTION_VALUES. This works all very well until you want to store something that doesn't have any options. Now I have one item in STOCK_ITEMS with one id and another item that DOES have options with a seperate id in OPTION_VALUES. I feel like I'm going around in circles with this and it feels like there should be such a simple solution but I'm just not seeing it. Is there anyone out there that can give me a pointer and show me the ligh?. Am I looking at the problem from completly the wrong angle? What I want is a common way to identify a stock item (even if it does or doesn't have an option) |
#3
| |||
| |||
|
|
On 12 May, 15:31, Nick S <nrsut... (AT) gmail (DOT) com> wrote: Hi I have a real headache of a problem and was wondering if anyone can help me. I'm writing a system that saves stock items. *Each item can have none or an infinite number of options attached to it. For example you can have a cupboard door as one stock item or you can have a Polo Neck sweater with the options of size:small, medium, large and colour: red, green, blue. My problem is that I have no idea how to store this information in the database. *My first thought was three tables STOCK_ITEMS, STOCK_OPTIONS, OPTION_VALUES *The item name would be stored in STOCK_ITEMS with the option names in STOCK_OPTIONS and their values in OPTION_VALUES. *This works all very well until you want to store something that doesn't have any options. *Now I have one item in STOCK_ITEMS with one id and another item that DOES have options with a seperate id in OPTION_VALUES. I feel like I'm going around in circles with this and it feels like there should be such a simple solution but I'm just not seeing it. Is there anyone out there that can give me a pointer and show me the ligh?. *Am I looking at the problem from completly the wrong angle? What I want is a common way to identify a stock item (even if it does or doesn't have an option) Hi Nick, first thing to do is to identify the relationships between Items, Options and Values. For a start, can an option have more than one value? If not, then options and values should appear in the same table. An example of each of the possible combinations would help.- Hide quoted text - - Show quoted text - |
#4
| |||
| |||
|
|
On 12 May, 16:18, Captain Paralytic <paul_laut... (AT) yahoo (DOT) com> wrote: On 12 May, 15:31, Nick S <nrsut... (AT) gmail (DOT) com> wrote: Hi I have a real headache of a problem and was wondering if anyone can help me. I'm writing a system that saves stock items. Each item can have none or an infinite number of options attached to it. For example you can have a cupboard door as one stock item or you can have a Polo Neck sweater with the options of size:small, medium, large and colour: red, green, blue. My problem is that I have no idea how to store this information in the database. My first thought was three tables STOCK_ITEMS, STOCK_OPTIONS, OPTION_VALUES The item name would be stored in STOCK_ITEMS with the option names in STOCK_OPTIONS and their values in OPTION_VALUES. This works all very well until you want to store something that doesn't have any options. Now I have one item in STOCK_ITEMS with one id and another item that DOES have options with a seperate id in OPTION_VALUES. I feel like I'm going around in circles with this and it feels like there should be such a simple solution but I'm just not seeing it. Is there anyone out there that can give me a pointer and show me the ligh?. Am I looking at the problem from completly the wrong angle? What I want is a common way to identify a stock item (even if it does or doesn't have an option) Hi Nick, first thing to do is to identify the relationships between Items, Options and Values. For a start, can an option have more than one value? If not, then options and values should appear in the same table. An example of each of the possible combinations would help.- Hide quoted text - - Show quoted text - Hi Captain. Thanks for the reply. I think I demonstrated that in my initial post. An item can have many or no options and an option can have 1 or more values. Thanks |
#5
| |||
| |||
|
|
Nick S wrote: On 12 May, 16:18, Captain Paralytic <paul_laut... (AT) yahoo (DOT) com> wrote: On 12 May, 15:31, Nick S <nrsut... (AT) gmail (DOT) com> wrote: Hi I have a real headache of a problem and was wondering if anyone can help me. I'm writing a system that saves stock items. Each item can have none or an infinite number of options attached to it. For example you can have a cupboard door as one stock item or you can have a Polo Neck sweater with the options of size:small, medium, large and colour: red, green, blue. My problem is that I have no idea how to store this information in the database. My first thought was three tables STOCK_ITEMS, STOCK_OPTIONS, OPTION_VALUES The item name would be stored in STOCK_ITEMS with the option names in STOCK_OPTIONS and their values in OPTION_VALUES. This works all very well until you want to store something that doesn't have any options. Now I have one item in STOCK_ITEMS with one id and another item that DOES have options with a seperate id in OPTION_VALUES. I feel like I'm going around in circles with this and it feels like there should be such a simple solution but I'm just not seeing it. Is there anyone out there that can give me a pointer and show me the ligh?. Am I looking at the problem from completly the wrong angle? What I want is a common way to identify a stock item (even if it does or doesn't have an option) Hi Nick, first thing to do is to identify the relationships between Items, Options and Values. For a start, can an option have more than one value? If not, then options and values should appear in the same table. An example of each of the possible combinations would help.- Hide quoted text - - Show quoted text - Hi Captain. Thanks for the reply. *I think I demonstrated that in my initial post. *An item can have many or no options and an option can have 1 or more values. Thanks Ahh, I think I am with you now. I had taken option values as being prices for the option. I see now that you mean that options are things like size or colour and your optio values are small,medium,large or red,green,blue respectively. OK, I'll have a think.- Hide quoted text - - Show quoted text - |
I was thinking maybe if I gave
#6
| |||
| |||
|
|
I have a real headache of a problem and was wondering if anyone can help me. I'm writing a system that saves stock items. Each item can have none or an infinite number of options attached to it. |
|
For example you can have a cupboard door as one stock item or you can have a Polo Neck sweater with the options of size:small, medium, large and colour: red, green, blue. My problem is that I have no idea how to store this information in the database. My first thought was three tables STOCK_ITEMS, STOCK_OPTIONS, OPTION_VALUES The item name would be stored in STOCK_ITEMS with the option names in STOCK_OPTIONS and their values in OPTION_VALUES. This works all very well until you want to store something that doesn't have any options. Now I have one item in STOCK_ITEMS with one id and another item that DOES have options with a seperate id in OPTION_VALUES. I feel like I'm going around in circles with this and it feels like there should be such a simple solution but I'm just not seeing it. Is there anyone out there that can give me a pointer and show me the ligh?. Am I looking at the problem from completly the wrong angle? What I want is a common way to identify a stock item (even if it does or doesn't have an option) |
#7
| |||||
| |||||
|
|
I'm writing a system that saves stock items. Each item can have none or an infinite number of options attached to it. |
|
For example you can have a cupboard door as one stock item or you can have a Polo Neck sweater with the options of size:small, medium, large and colour: red, green, blue. |
|
My problem is that I have no idea how to store this information in the database. My first thought was three tables STOCK_ITEMS, STOCK_OPTIONS, OPTION_VALUES The item name would be stored in STOCK_ITEMS with the option names in STOCK_OPTIONS and their values in OPTION_VALUES. This works all very well until you want to store something that doesn't have any options. Now I have one item in STOCK_ITEMS with one id and another item that DOES have options with a seperate id in OPTION_VALUES. I feel like I'm going around in circles with this and it feels like there should be such a simple solution but I'm just not seeing it. |
|
Is there anyone out there that can give me a pointer and show me the ligh?. Am I looking at the problem from completly the wrong angle? What I want is a common way to identify a stock item (even if it does or doesn't have an option) |
|
Hi Nick, first thing to do is to identify the relationships between Items, Options and Values. For a start, can an option have more than one value? If not, then options and values should appear in the same table. An example of each of the possible combinations would help.- Hide quoted text - If for example a polo neck shirt was given the code MLPOLO and the size option was SZ with values of S, M and L and the colour option was CL with values of RE, GR, BL A medium red polo neck would have a code of MLPOLO-SZ-S-CL-RE But you're adding around 6 characters per option, and with something that has a lot of options it may become very cumbersome. |
![]() |
| Thread Tools | |
| Display Modes | |
| |