External mapping file to match string texts - sql

I have a table of customer feedback (verbatim) that I would like to to 're-map' to the corrected Themes and Sub-Themes based on the keywords in the verbatim.
I would like to maintain an external mapping file that can be updated at any time with the updated mapping. As an example, my external file looks like this, using food data ;)
The keywords have logical OR/AND conditions, as well as wild card * for words like work* to map to working, worked, works etc.
I would like to map a table like above to my customer feedback table based on the Category column.
As an example, if the verbatim is in Category = Fruit, and contains the words (orange OR lemon), then I'd like to update the Themes column to Citrus.
If the theme is Citrus, and verbatim also contains the words (orange OR yellow) AND colour*, then the Sub-Theme would be Colour.
Can someone please advice what the best way to achieve this? And where would be the best place to put the logic for the themes and sub-themes such that there would be minimal changes required for future updates? (if not in this external file).
Would really appreciate your help and feedback!
Thank you in advance.

Related

How to create inheritance in SQLite

I have to create an SQLite DB that models a survey with some ordered content; this content can be a question, an image or a simple text field (just like Google Forms). Each content doesn't have anything to do with the other, except questions which can have a list of attached images to them.
What would be the best way to model this situation? I thought about creating a "Survey" table and a "Content" table that has only an integer ID, and that same ID is then "duplicated" into each table ("Question", "Image" or "TextField"), but then I think I would have to insert both values for the Content and values for a specific content (Question, Image or TextField) every time I need to insert a new content. I don't think it would be a big problem, but if there is an way to model this better, I would like some advice.
Your approach is an example of 'table per type' as defined in this answer.
Conceptually, you're saying "there are 3 kinds of content, and the one thing they share is their relationship with a survey, as captured in the content table". You might include in that table an explicit type indicator along the ID - this will make your code a little more explicit. You may also find you need to capture meta data like "status", "date_entered" etc. which is common across subtypes.
By including a type indicator column, you make it easy to find out what the type of a content item is. So, if you want to show the summary of a question, you could do something like
select content_type, count(*)
from content
where question_id = ?
group by content_type
to show the number and type of responses.

How to re-rank documents based on their attributes rather than just their field relevance?

I'm trying to use Solr to re-rank document results based relevance to the user searching. For example, if I search joann*this could return documents where the Name field is anything from joanna to joanne. What I'm trying to do is to return documents that match on certain attributes that I have as well-- this could be something like us both having the field Location = "NYC".
So my question is two fold- is there a way to grab and handle a users information when they are making a query and also is there a way to re-rank based on these additional field values? Would this look more like writing some code or just an expanded query?
it looks to me like you are talking about functionality that Query Reranking exactly provides. Did you check that out?

SQL Change from Decimal to Text

I am using OpenCart for a pizza restaurant and I need to add more than one price to the catalog page. I am looking now for someone to create all the mods I need for it but in the meantime I want to simply be able to add a line of text in lieu of adding a dollar amount for the price. In the database the settings under column>price are as follows:
Type: DECIMAL,
Length/Values: 15,2,
Default: as Defined, 0.00
When I try to add the following (which is what I would like until I can get the mods built): $7.95 / $10.95 it defaults to the decimal. I changed the settings to Text and tried some settings but I really don't know what I am doing. Can anyone tell me how I can make this happen? Perhaps if I could even add another field in the admin area and call that field in lieu of the text field? They will not offer online ordering for a couple weeks so I need a quick fix until the mods are done. Thanks.
From the comments i understood that you need two prices for a small and large pizza for example, if that is the case options are your solution, as they are used exactly for that to have the same product in different sizes and prices in your case, users just have to specify the option they need.
Also here is a tutorial that will guide you: http://www.opencarttutorial.com/how-to-setup-your-opencart-catalog/product-options/

Database Design: Line Items & Additional Items

I am looking for a solution or to be told it simply is not possible/good practice.
I currently have a database whereby I can create new orders and select from a lookup table of products that I offer. This works great for the most part but i would also like to be able to add random miscellaneous items to the order. For instance one invoice may read "End of Tenancy Clean" and the listed product but then have also an entry for "2x Lightbulb" or something to that effect.
I have tried creating another lookup table for these items but the problem is i don't want to have to pre-define every conceivable item before I can make orders. I would much prefer to be able to simply type in the Item and price when it is needed.
Is there any database design or workaround that can achieve this? Any help is greatly appreciated. FYI I am using Lightswitch 2012 if that helps.
One option I've seen in the past is a record in your normal items table labeled something like "Additional Service", and the application code will recognize this item and also require you to enter or edit a description to print with the invoice.
In the ERP system which we have at work, there is a flag in the parts table which allows one to change the description of the part in orders; in other words, one lists the part number in the order and then changes the description. This one off description is stored in a special table (called NONSTANDARD) which basically has two fields - an id field and the description. There is a field in the 'orderlines' table which stores the id of the record in the special table. Normally the value of this field will be 0, which means that the normal description of the part be displayed, but if it's greater than 0, then the description is taken from the appropriate row in the nonstandard table.
You mean something like this?
(only key attributes included, for brevity)

Where to find product name in Prestashop Database structure

i'm developing a very simple (for newbie user) back end for prestashop, and i would like to know where to find the product’s images name uploaded..
I know they are into “img/p” directory. But i don’t know:
1. In which database table they are .. linked
2. Why they are called (for example): 1-18-small.jpg … why “1-18” instead “1” (his productid) ? what that number means ?
Thanks
Since image names are language dependents, you will find them in image_lang table.
About filenames, the pattern is : productId-imageId-size.jpg
Full table structure you can see here:
http://doc.prestashop.com/display/PS15/Fundamentals
Names of the files:
In my case viwth ver. 1.5 is: img/p/3/0/3/1/3031-home_default_1.jpg
So its very easy to understand name is repeating folder structure.
img/ - image
p/ - product
3/0/3/1/ i think is so many because in case you have may images for one product.
3031 folder structure and then home_default_1.jpg or another sizes with different names in same folder, you can see just browse this folder.