entity-attribute-value

mysql if() with max()

丶灬走出姿态 提交于 2021-02-08 10:00:53
问题 I have a table named attproduct : there are three columns id, attribute, values . I have color and brand for each id in attribute column and corresponding values in value column SELECT id, MAX( IF( attribute = 'brand', value, NULL ) ) AS Brand, MAX( IF( attribute = 'color', value, NULL ) ) AS color FROM fy.attproduct GROUP BY id When I run this query i get output as desired in id, brand, color as columns. I need to know what is role of max in my query, when i remove max, i get null values 回答1

Read any JSON into list of key-value pairs (EAV format) in SQL Server

佐手、 提交于 2020-05-15 07:56:33
问题 Looking for a way to read any JSON without knowing the internals with SQL Server's JSON methods, I came up with an approach I'd like to share. Here is the question bringing up this issue. The question is: How can I transform an unknown JSON into a structured EAV format while keeping all the information about sort order and nest levels. The ideal output should carry the original row's id as the entity , the Json's key and value as the attribute and value together with the JsonPath for the

What is the best practice to save a quiz answers with different data types in MYSQL?

一曲冷凌霜 提交于 2020-03-28 06:41:04
问题 UPDATE: part 1- start: We want to get our customers data, but which kind of data? they are not specified! actually we want to have a dynamic application that the admin can define new questions (he can set the answer's data type, length, and other rules) and he also can deactivate old questions! (I don't want to use EAV schema design, but I can't find the alternative way) UPDATE: part 1 - end: so I decided to create a quiz application, admin can define questions which their answers data type

What is the best practice to save a quiz answers with different data types in MYSQL?

家住魔仙堡 提交于 2020-03-28 06:40:19
问题 UPDATE: part 1- start: We want to get our customers data, but which kind of data? they are not specified! actually we want to have a dynamic application that the admin can define new questions (he can set the answer's data type, length, and other rules) and he also can deactivate old questions! (I don't want to use EAV schema design, but I can't find the alternative way) UPDATE: part 1 - end: so I decided to create a quiz application, admin can define questions which their answers data type

How many database table columns are too many?

穿精又带淫゛_ 提交于 2020-02-01 05:10:06
问题 I've taken over development on a project that has a user table with over 30 columns. And the bad thing is that changes and additions to the columns keep happening. This isn't right. Should I push to have the extra fields moved into a second table as values and create a third table that stores those column names? user id email user_field id name user_value id user_field_id user_id value 回答1: Do not go the key / value route. SQL isn't designed to handle it and it'll make getting actual data out

Design of an 'EAV' or 'Class/Concrete Table Inheritance' database for stock control

匆匆过客 提交于 2020-01-13 05:09:13
问题 I am developing a stock control system for a construction project. The storeman is responsible for adding new stock and distributing/returning it to/from employees. The items (and hence their attributes) will be very varied; e.g. steelwork, clothing, plant/machinery, tools, etc. My question is whether to go for a Class/Concrete Table Inheritance or EAV based schema. I don't know what attributes items will have, so presumably a Class/Concrete Table Inheritance approach would require the end

Should I use EAV database design model or a lot of tables

末鹿安然 提交于 2020-01-12 10:14:11
问题 I started a new application and now I am looking at two paths and don't know which is good way to continue. I am building something like eCommerce site. I have a categories and subcategories . The problem is that there are different type of products on site and each has different properties . And site must be filterable by those product properties. This is my initial database design: Products{ProductId, Name, ProductCategoryId} ProductCategories{ProductCategoryId, Name, ParentId}

Should I use EAV database design model or a lot of tables

梦想与她 提交于 2020-01-12 10:08:26
问题 I started a new application and now I am looking at two paths and don't know which is good way to continue. I am building something like eCommerce site. I have a categories and subcategories . The problem is that there are different type of products on site and each has different properties . And site must be filterable by those product properties. This is my initial database design: Products{ProductId, Name, ProductCategoryId} ProductCategories{ProductCategoryId, Name, ParentId}

Stacking dataframe columns (Pandas)

本秂侑毒 提交于 2020-01-10 04:24:06
问题 I am looking for a way to pivot a dataframe in reverse direction. To the best of my knowledge, pandas provides a pivot or pivot_table method to transform an EAV df to a "normal" one. However, is there also a way to do the inverse? So given the dataframe: $df userid A B C 0 1 1 0 1 1 3 1 2 1 5 0 I would like to transform it to (a EAV model): $df E A V 0 A 1 0 B 1 0 C 0 1 A 1 1 B 3 1 C 1 2 A 1 2 B 5 2 C 0 What would be the most efficient way to do so? 回答1: Assuming userid is the index, df.stack