How can I create the database table for shopping website - mysql

I am little bit confused that how I have to create the tables for simple shopping website because I am new in php and this is my first project of shopping website choosen by myself for practice but I am confused with the size of the products and color of the products and different types of the products like laptops, mobile, jeans, shirts etc,
I have created the table but I want to know that two things
for electronics products I have to create a different table and for
clothes like jeans and shirts etc, I have to create a different table
Please can anybody tell me the structure of the table.

You'll have many tables, for example:
Products:
ID
Name
Description
Etc...
Categories:
ID
Name
ProductCategories:
ProductID
CategoryID
Types:
ID
Name
ProductTypes:
ProductID
TypeID
This enables you to have products in multiple categories and of multiple types...
Added further examples as per the comment below. For sizes you have a Sizes table, and a mapping table to map products to sizes...
Sizes:
ID
Name
ProductSizes:
ProductID
SizeID
If you also need to consider colours, and need to make a choice whether you will store sizes that have a colour, or colours that have a size...
Colours:
ID
Name
ProductColours
ProductID
ColourID
Or, if you need colours and sizes, or any further complexity, i would abstract it right out and use a ProductAttributes way of doing it, maybe out of the scope of this question as the answer would be quite lengthy indeed.
But in the same style as above, you could have a table like so:
ProductSizesColours:
ProductID
SizeID
ColourID
Which enables you to store data for products such as:
A pair of jeans that are size 32 and colour brown.
A juice blenderthat is 3 litre size and colour white.
Etc...

I think you sould create a new table like "type_product" to add the type of each product and put all your product in the same table

Related

Shopping Cart rule to apply fixed discount on different product

I want to add a shopping cart rule which gives the discount of 21 when there are specific five products in my cart. Eg: Five products with SKU S01, S02, S03, S04, S05, all having different product price. When added into cart total is 81 and Discount should be 21. The user should get these products in 60. is this possible? Thanks in advance
Thanks in advance.
Yes, it is possible. If you want to create rule, which apply only when specific five products are in cart, you have to add Shopping Cart Price Rule. When creating this rule, navigate to Conditions tab and add conditions for your products (for SKU -> first add Product attribute combination, and then under this condition, select SKU as attribute and provide appropriate SKU. Add five conditions and that's all, discount will be applied only if all of your conditions are met.
It is possible when you add the condition like as on screen.
Discount on different products:

Volusion Category template generated dynamically

I am new to Volusion and want to be able to add unique id to each product div, table and image section while in the category page.
For more understanding please see this link: http://v2283470.kdqp7pdbwqns.demo48.volusion.com/category-s/101.htm
I would like to have each product div, paragraph and table have an id generated dynamically by concatenating a given id with the product code (product id).

Finding the best results using Tags

I want to create a site that uses tags to find a best matching result (a post). A user can like/dislike things and in turn builds a "profile" for himself that consists of tags he likes (and tags he dislikes) based on the things he likes/dislikes.
For example:
USER_1 likes: dog, mouse, blue, house
USER_1 dislikes: cat, pink
USER_2 likes: red, hat, blue
USER_2 dislikes: pink
...
Now for the posts I have similar tags in the database. For example:
POST_1 tags: dog, red, hat
POST_2 tags: blue, pink, cat
...
My question is:
How can I get the best matching result (based on likes alone | including dislikes)? Is there a system that has been established or how does one usually solve problems like these?
E.g. USER_2 first receives POST_2 because it matches his like "blue" and "hat", after that comes POST_1 because he likes "blue".
Thanks! I'm eager to learn how this works but I haven't found anything (and don't know where to start).

Matching /comparing a Database Field using a Key with different **combination** in Mysql 5.0

I have a table: db_details in MYSQL 5.0 with a Table field: Description having 10,0000 entries . I want an optimum method to search a key and get the result with different combination.For example:
Let the 4 entries of description [actually its 10000] field is as follows:
description 1 : I want to see my friend
description 2: My friend has a red pen and yellow box
description 3: This yellow box belongs to my friend
description 4: He is a doctor
I want to compare these with a key : pen box friend and should get result in the order: first description 2, then description 3 and then description 1 [Its because description 2 has the max hit ,then description 3 and so on]
please help me. I want to know how it should be done..Since it is a Huge database ,i want to get this without a delay whether by using page offset or not.
If you want to do this, i think Shpinx is more suitable for do this job.
Sphinx is much faster and you can set priority of results.
STEP 1 : create table description(descr TEXT,fulltext(descr));
STEP 2 : insert into description values('I want to see my friend'),('My friend has a red pen and yellow box'),('This yellow box belongs to my friend'),('He is a doctor');
STEP 3 : select * from description where match(descr) against('pen box friend');
Output is as follows : (as you required in order)
My friend has a red pen and yellow box
This yellow box belongs to my friend
I want to see my friend
Note: But it will be comparatively slow as compared to sphinx.

Handling Multiple Images with ColdFusion and MySQL

This is an architecture question, but its solution lies in ColdFusion and MySQL structure--or at least I believe so.
I have a products table in my database, and each product can have any number of screen-shots. My current method to display product screen-shots is the following:
I have a single folder where all screen-shots associated with all products are contained. All screen-shots are named exactly the same as their productID in the database, plus a prefix.
For example: Screen-shots of a product whose productID is 15 are found in the folder images, with the name 15_screen1.jpg, 15_screen2.jpg, etc...
In my ColdFusion page I have hard-coded the image path into the HTML (images/); the image name is broken into two parts; part one is dynamically generated using the productID from the query; and part two is a prefix, and is hard-coded. For example:
<img src"/images/#QueryName.productID#_screen1.jpg">
<img src"/images/#QueryName.productID#_screen2.jpg"> etc...
This method works, but it has several limitations the biggest listed bellow:
I have to hard-code the exact number of screen-shots in my HTML template. This means the number of screen shots I can display will always be the same. This does not work if one product has 10 screen shots, and another has 5.
I have to hard-code image prefixes into my HTML. For example, I can have up to five types of screen-shots associated with one product: productID=15 may have 15_screen1.jpg, 15_screen2.jpg, and 15_FrontCover.jpg, 15_BackCover.jpg, and 15_Backthumb.jpg, etc...
I thought about creating a paths column in my products table, but that meant creating several hundreds of folders for each product, something that also does not seem efficient.
Does anyone have any suggestions or ideas on the correct method to approach this problem?
Many thanks!
How about...
use an Image table, one product to many images (with optional sortOrder column?), and use imageID as the jpeg file name?
update:
Have a ImageClass table, many Image to one ImageClass.
Image
-----
ID
productID
imageClassID (FK to ImageClass)
Use back-end business logic to enforce the some classes can only have one image.
Or... if you really want to enforce some classes can only one image, then can go for a more complex design:
Product
------
ID
name
...
frontCoverImageID
backCoverImageID
frontThumbImageID
backThumbImageID
Image
-----
ID
productID
isScreenShot (bit) // optional, but easier to query later...
However, I like the first one better since you can have as many classes you see fit later, without refactoring the DB.
Keeping information on how many and what images in the database is definitely the way to go.
Barring that, if you want to use naming conventions to associate images with products, and the number of images is arbitrary, then it's probably a better idea to create one folder per product:
/images/products/{SKU1}/frontview.jpg
/images/products/{SKU1}/sideview.jpg
/images/products/{SKU2}/frontview.jpg
and so forth. Then use <cfdirectory> to collect the images for a given product. You might also want to name your images 00_frontview.jpg, 01_sideview.jpg and such so that you can sort and control what order they'll display on the page.
use the cfdirectory tags to inspect the filesystem:
<!--- get a query resultset of images in filesystem --->
<cfdirectory action="list" name="images" directory="images">
<!--- get images for specific product --->
<cfquery name="productImages" dbtype="query">
select *
from images
where name like '#productid#%'
</cfquery>
<cfoutput query="productImages">
<img src="#productimages.directory#/#productimages.name#" />
</cfoutput>
You could even try using the filter attribute to cfdirectory to try and omit the QoQ