Answered step by step
Verified Expert Solution
Question
1 Approved Answer
I need help with writing this final SQL statment. Thank you! Using data mining techniques and fuzzy logic, we are able to identify products that
I need help with writing this final SQL statment. Thank you!
Using data mining techniques and fuzzy logic, we are able to identify products that customers are most likely to purchase based on their purchase history or viewing habits. The upSells table stores the customer ID along with several products and a percentage ranking of how lkely they are to purchase those products. The upsells infomation will be displayed on the Home page and Shopping Cart page to try and increase sales. We use the following query to select the products to be displayed. SELECT Top 3 uprodD, percentage, pprodName, prPrice, p.sPrice FROM upsellsu, product p u prodID pprodIT and ucustID 3215 ORDER BY u percentage desc; We want to select the product information and percentage value from our upSells and product tables. An inner join is used to connect these two tables We filter the results based on the custID so that the customer only sees their upSells recommendations. Finally, the results are ordered by percentage in descending order so that the highest percentage results are displayed first. When applying this query to our actual eCommerce site, we would use a variable in the place of our tlD value (ie ucurtID (acutID). The value for this variable would be passed to our query from the programming code calling our query. Using (and introducing the "Top function in MiGMT 329: Database Management our SELECT statement, we will only display the top three results from the query. For customer 215. our query would produce the following results. ITPrice SPrice rodID Perc rodName 313234 0.82 Toshiba Canvio Connect ITB Portable Estemal HardDnive 63.96 424462 0.81 Jensen JENSEN CD-750 Portable AM FM Stereo CDP 508339 0.76 Bat GrillKettle Charcoal Grill We could also run a similar query for crossSells. The crossSells table would recommend products on the product page based on all customer purchasing habits of that product. The prodlD would be used to filter the results based on which product was viewed. and S Address When the user adds items to their shopping cart and decides to checkout, we need to display their billing and payment options that we have stored in the database. To do this, we should select information from the customer, shippingAddress and paymen thyo tables. If we join these three tables together then we will end up with both the shippingAddress and paymentInfo information. stored in a single record and also have duplicate ouput if multiple shipping addresses or payment methods exist. To solve this problem we will introduce the UNION command A UNION will combine the results of two or more queries into a single output. For a union to work properly, there must be an even number of attributes in both quenes that we are trying to combine Below is the query to ourputshipping and biling information following by a detailed description of the query SELECT Billing Address: pbillAddress. Null, p.city, pstate, p zip. ccType, ccNum, FROM customer c paymentInfop WHERE c custID pcustID and ccustID 243 SELECT Shipping Address. 2. s.city, s state, s-zip. Null, Null Null, FROM customer c. shippingAddress s THERE c.custID custID and c custD 243. The first query will output the Billing Address records stored in the database. We use the Billing at the beginning to ouput this test on each record to identify it as billing information. The second query will output shipping infomation and use the string Shipping Address: string at the beginning to identif these records as shipping address records in the output Notice the use of Null in the attributes list of the SELECT statement. The shipping Address table has an address2 attribute but the paymemthuto table does not. Therefore, Using data mining techniques and fuzzy logic, we are able to identify products that customers are most likely to purchase based on their purchase history or viewing habits. The upSells table stores the customer ID along with several products and a percentage ranking of how lkely they are to purchase those products. The upsells infomation will be displayed on the Home page and Shopping Cart page to try and increase sales. We use the following query to select the products to be displayed. SELECT Top 3 uprodD, percentage, pprodName, prPrice, p.sPrice FROM upsellsu, product p u prodID pprodIT and ucustID 3215 ORDER BY u percentage desc; We want to select the product information and percentage value from our upSells and product tables. An inner join is used to connect these two tables We filter the results based on the custID so that the customer only sees their upSells recommendations. Finally, the results are ordered by percentage in descending order so that the highest percentage results are displayed first. When applying this query to our actual eCommerce site, we would use a variable in the place of our tlD value (ie ucurtID (acutID). The value for this variable would be passed to our query from the programming code calling our query. Using (and introducing the "Top function in MiGMT 329: Database Management our SELECT statement, we will only display the top three results from the query. For customer 215. our query would produce the following results. ITPrice SPrice rodID Perc rodName 313234 0.82 Toshiba Canvio Connect ITB Portable Estemal HardDnive 63.96 424462 0.81 Jensen JENSEN CD-750 Portable AM FM Stereo CDP 508339 0.76 Bat GrillKettle Charcoal Grill We could also run a similar query for crossSells. The crossSells table would recommend products on the product page based on all customer purchasing habits of that product. The prodlD would be used to filter the results based on which product was viewed. and S Address When the user adds items to their shopping cart and decides to checkout, we need to display their billing and payment options that we have stored in the database. To do this, we should select information from the customer, shippingAddress and paymen thyo tables. If we join these three tables together then we will end up with both the shippingAddress and paymentInfo information. stored in a single record and also have duplicate ouput if multiple shipping addresses or payment methods exist. To solve this problem we will introduce the UNION command A UNION will combine the results of two or more queries into a single output. For a union to work properly, there must be an even number of attributes in both quenes that we are trying to combine Below is the query to ourputshipping and biling information following by a detailed description of the query SELECT Billing Address: pbillAddress. Null, p.city, pstate, p zip. ccType, ccNum, FROM customer c paymentInfop WHERE c custID pcustID and ccustID 243 SELECT Shipping Address. 2. s.city, s state, s-zip. Null, Null Null, FROM customer c. shippingAddress s THERE c.custID custID and c custD 243. The first query will output the Billing Address records stored in the database. We use the Billing at the beginning to ouput this test on each record to identify it as billing information. The second query will output shipping infomation and use the string Shipping Address: string at the beginning to identif these records as shipping address records in the output Notice the use of Null in the attributes list of the SELECT statement. The shipping Address table has an address2 attribute but the paymemthuto table does not. ThereforeStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started