entity-attribute-value

How to store a data whose type can be numeric, date or string in mysql

感情迁移 提交于 2019-12-12 18:13:36
问题 We're developing a monitoring system. In our system values are reported by agents running on different servers. This observations reported can be values like: A numeric value. e.g. "CPU USAGE" = 55. Meaning 55% of the CPU is in use). Certain event was fired. e.g. "Backup completed". Status: e.g. SQL Server is offline. We want to store this observations (which are not know in advance and will be added dynamically to the system without recompiling). We are considering adding different columns

How to select data from a key value pair table

只谈情不闲聊 提交于 2019-12-12 18:03:43
问题 Table A id,parentID, key, value 1, 2, name, name1 2, 2, age, 20 3, 2, place, place1 50, 7, name, namex 51, 7, age, 20 52, 7, place, place1 ........ 101, 5, name, namez 102, 5, age, 23 103, 5, place, place2 I need to get all the date having plave = place1 and age = 20 in the bellow format parentid, name, age, place 2, name1, 20, place1 7, namex, 20, place1 How to write the Mysql SQL query please help me 回答1: You can use conditional aggregation to get all the info for a parentid on to one row

Implementing EAV pattern with Hibernate for User -> Settings relationship

强颜欢笑 提交于 2019-12-12 08:06:03
问题 I'm trying to setup a simple EAV pattern in my web app using Java/Spring MVC and Hibernate. I can't seem to figure out the magic behind the hibernate XML setup for this scenario. My database table "SETUP" has three columns: user_id (FK) setup_item setup_value The database composite key is made up of user_id | setup_item Here's the Setup.java class: public class Setup implements CommonFormElements, Serializable { private Map data = new HashMap(); private String saveAction; private Integer

Database design: EAV options?

人走茶凉 提交于 2019-12-12 07:38:23
问题 This is just a database concept question: what are the pros and cons of the following model for EAV? Model 1: TABLE: attribute_value ====================================== | id | fk_id | attribute | value | ====================================== | 1 | 10 | FName | John | | 2 | 10 | Lname | Doe | | 3 | 55 | FName | Bob | | 4 | 55 | Lname | Smith | -------------------------------------- Model 2: TABLE: attribute ================== | id | attribute | ================== | 1 | FName | | 2 | Lname

Dynamic Columns in SQL Select statement

醉酒当歌 提交于 2019-12-12 06:36:28
问题 This Question was marked as beeing a "duplicate" of the question mySQL - Create a New Table Using Data and Columns from Three Tables I think the question is different, because there are three tables in action, in my question are two. There the question is how to create a new table, here the question is to create an output. But thanks for pointing, maybe it's closer to my problem than I expecting. I tried to use the solutions from the "Duplicate"-Question, but the Ansers and the problems are

Getting products with desired attributes

蓝咒 提交于 2019-12-12 05:48:15
问题 I have a category with products and a set of attributes. Those attributes are "Shape" and "Diameter". When I open a category without applying filters I get products with following query: "SELECT * FROM `products` WHERE `category_id` IN ('6', '7', '29', '8', '9', '36')" Then I click on attribute "Diameter"(id = 2) with value "8mm"(id = 4) I generate the following query: "SELECT * FROM `products` JOIN `products_attributes_values` ON (`products_attributes_values`.`product_id` = `products`.`id`)

MySQL Query INNER JOIN with aliases

核能气质少年 提交于 2019-12-12 05:38:49
问题 I have two tables: users and users_info users looks like this: +----+----------+-------+ | id | slug | name | +----+----------+-------+ | 1 | theploki | Kris | +----+----------+-------+ and users_info looks like this: +----+--------+----------+---------------+ | id | parent | info_key | info_val | +----+--------+----------+---------------+ | 1 | 1 | email | kris@kris.com | +----+--------+----------+---------------+ | 2 | 1 | age | 28 | +----+--------+----------+---------------+ I want to

Querying on EAV SQL Design

空扰寡人 提交于 2019-12-12 04:06:57
问题 I have 3 tables like this. Entity_Table |e_id|e_name|e_type |e_tenant| |1 | Bob | bird | owner_1| |2 | Joe | cat | owner_1| |3 | Joe | cat | owner_2| AttributeValue_Table |av_id|prop_name |prop_value| |1 | color | black | |2 | color | white | |3 | wing size| 7" | |4 | whiskers | long | |5 | whiskers | short | |6 | random | anything | Entity_AttrVal |e_id|av_id| | 1 | 1 | | 1 | 3 | | 2 | 2 | | 2 | 5 | | 3 | 1 | | 3 | 4 | | 3 | 6 | What I want to be able to do is something like 'find entity

Many-to-many relationship with different data types

半腔热情 提交于 2019-12-12 03:46:21
问题 Our app has been customized to handle many different types of customers, with certain settings that will only apply to a few or one customer. Rather than continuously adding nullable columns to the customers table, I decided to add a [Settings] table to allow each setting to be a row. [dbo].[Settings] [SettingID] [int] [SettingCode] [nchar](4) [SettingDescription] [nvarchar](255) Which is then linked to the [Customers] table through a many-to-many table [dbo].[Customer_Settings] [Customer

Similar to rows-to-col(EAV to relational) - SQL query please

落爺英雄遲暮 提交于 2019-12-12 03:04:08
问题 My dataset is not exactly like EAV format, but it's somewhat similar; here's the data: In the format I need is as follows: For every EN_NO group I need the data in above format. If group on EN_NO > 1 then respestive product key should go to respestive product column otherwise not (for e.g. EN_NO 4 and 5). I hope I am clear. Data is in a Qracle table, please suggest a query to get the data in the format I need. Thanks, Prakash 回答1: I would highly recommend altering your table structure. At