English 中文(简体)
处理本身具有属性的属性的标准办法?
原标题:Standard approach for dealing with attributes that themselves have attributes?

我正在建立一个数据库,并有一个表格,表格结构如下:

         Att1    Att2    Att3   ....
User1    
User2
User3
....

我希望每个属性( Att1, At2, Att3,...) 都附着一个布林变量。 类似 :

Att1    No
Att2    No
Att3    Yes
...     ...

每个属性都是来自用户的数值分数( 列表首选 ), 但我想要标记每个属性是否真正重要 。 是否有处理这种依赖性的标准方法? 谢谢!!

最佳回答

如果我们能在表格中嵌入记录,那将是件好事。 然而,标准SQL和大多数数据库并不支持这一点(尽管有例外 ) 。

我将使用一致的命名协议, 发明“ IsimentAtt1” 和“ IsimentAtt2” 等字段。 当我这样做时, 我还有这样的协议, 所有“ 是” 变量只使用“ Y” 或“ N” 的值。 如果我想在输出中看到“ 是” 和“ 否 ”, 那么我使用视图进行转换, 或者在应用层中进行转换 。

问题回答

在我看来,Attrimite 实际上是一个实体调用 ListingPregence ,它有 Id 键、2个属性、Score Is Insportant ,以及一个称为 User 的FK至 用户

user rentley 只有一个 > Id 密钥。


简言之,属性没有属性,这意味着你的模型是错误的。

如果属性本身不是重要的话, 属性评分是否重要? 如果没有, 您只需有一个协议, 即 NULL 评分意味着属性不重要 。

否则,您可以为每个属性列添加另一列(布尔) :

         Att1    Important1    Att2    Important2    Att3    Important3   ....
User1    
User2
User3
....

BTW 属性是固定的吗? I. e. 您是否“ 坚固” 总是 < / 坚固” 具有完全相同的属性? 如果不是, 您最好使用一个 < a href=" "http://en.wikipedia. org/wiki/Entity-atripte-value_model" rel= “ nofollow noreferrer” > EAV 模型 (尽管EAVs 传统上有一些下行模式):

""https://i.sstatic.net/Bi7Ax.png" alt="此处的内置图像描述"/ >

一个无关紧要的属性可能只是从USER_ATTRIBUTE表格中略去(假设“否”是顶部回答我的问题)。





相关问题
SQL SubQuery getting particular column

I noticed that there were some threads with similar questions, and I did look through them but did not really get a convincing answer. Here s my question: The subquery below returns a Table with 3 ...

难以执行 REGEXP_SUBSTR

I m 查询Oracle 10g。 我有两张表格(样本数据见下文)。 i m 试图提取一些领域

SQL Query Shortcuts

What are some cool SQL shorthands that you know of? For example, something I learned today is you can specify to group by an index: SELECT col1, col2 FROM table GROUP BY 2 This will group by col2

PHP array callback functions for cleaning output

I have an array of output from a database. I am wondering what the cleanest way to filter the values is example array Array ( [0] => Array ( [title] => title 1 ...

OracleParameter and DBNull.Value

we have a table in an Oracle Database which contains a column with the type Char(3 Byte). Now we use a parameterized sql to select some rows with a DBNull.Value and it doesn t work: OracleCommand ...

Running numbers in SQL

I have a SQL-statement like this: SELECT name FROM users WHERE deleted = 0; How can i create a result set with a running number in the first row? So the result would look like this: 1 Name_1 2 ...

How to get SQL queries for each user where env is production

I’m developing an application dedicated to generate statistical reports, I would like that user after saving their stat report they save sql queries too. To do that I wrote the following module: ...

热门标签