问题标签 [surrogate-key]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
apache-pig - 使用自定义等级在 PIG 中生成代理键
我将每天进行 PIG 转换(每天都有新数据)。而且我需要为每天提取的数据生成唯一键。什么是最好的方法?如果我执行 tomarow 的排名会覆盖今天的排名吗?
mysql - 如何使用 GUID 键为表分页数据
我有一个类似于下面的表,它以 GUID 作为键。 我正在尝试使用以 GUID 作为键的分页来显示 tis 的内容,但遇到了我该怎么做的问题?
如果它是一个 Int 键,我的存储过程看起来像这样,通过 desc 给我下 10 个订单。但是使用 GUID 不确定如何进行这种类型的分页。
jpa - JPA - 多对多表中的复合键与生成的 id
我正在创建一种社交网络,并且我的用户可以关注其他用户。所以我有一个像这样的实体:
我不能有 ManyToMany 关系,因为我的 FollowedUser 实体中有更多字段。现在,我的问题是:
sql - Security of SQL sequences/auto-increment integer values
A colleague once mentioned to me that when developing web applications, explicitly using a sequence/auto-increment integer (typically a primary key) to uniquely identify values within a database is a security risk, and that since such keys are often used as "surrogate keys" (e.g., for internally identifying records and relationships between records) the safest way of identify resources is use to domain primary key.
Take the following example.
To access category, the url is /category/(\d+)
using the category_key
primary key. How is this less secure than a url /category/([^/]+)
using the name
unique key?
The only thing I can think of is that a particular category_key
is much easier to guess (e.g., add one), and if you haven't coded your access control properly, this could allow someone to arbitarily view any category within the database.
data-warehouse - 数据仓库中的代理键
我了解 DWH 环境中代理键的一般概念。但是有两个方面我不明白,也找不到相关信息:
- 代理键在整个 DWH中是唯一的还是在一维中是唯一的,这是常见的做法吗?
- 如果我有一个带有层次结构的维度,该层次结构会影响代理键的生成吗?
many-to-many - 代理键的正确使用?
假设一个特定的国家有很多景点(纪念碑、公园、博物馆),当然一个特定的景点可以存在于许多州。
就逻辑 ERD 模型而言,M:N 关系之间应使用联结表。
但是,简单地使用两个相邻表的 PK 作为连接表的 PK 就足够了吗?
也就是说,您有一个 COUNTRY、SIGHTS 和 SIGHT_TYPE 表,其中 SIGHTS 是联结表。假设一个特定的国家可以有多个博物馆(即 MUSEUM 是一个 SIGHT_TYPE),这意味着 SIGHTS 表中的每条记录都不能唯一标识,不是吗?
即假设 MUSEUM 的 SIGHT_TYPE_ID 为 2,GERMANY 的 country_id 为 22。对于多个博物馆,如果上述情况属实,您不会发生这种情况吗?22 2 - 博物馆 A 22 2 - 博物馆 B
因此,在这种情况下,使用代理键(例如 SIGHT_ID)作为唯一标识符是绝对必要的吗?
换句话说,通常使用两个相邻表的 PK 作为连接或组合表的 PK,但是这些情况是否例外?
谢谢
java - 连接两个多对多表
我在为基于 java 的 Web 应用程序定义适当的数据库设计时遇到了一些麻烦。我有 3 个表(标签、DT 和属性),我的场景如下。每个 Tag 可以包含多个 Dts,每个 DT 可以分配给不同的 Tag,每个 DT 有多个 Properties,每个 Property 可以在多个 DT 中使用。将 DT 分配给 Tag 时,用户可以为其所有属性设置值。
我的问题是,我如何定义一个关系,以便每个标签都可以根据分配给它的 DT 具有其属性值。我的设计中缺少什么表格和关系。然后我必须基于这个数据库创建相对实体。
这是db图。并提前感谢您的帮助。
这是一些示例数据
sql - LEFT OUTER JOIN 导致违反唯一键约束
我有两个公司的两个数据库在同一个软件上运行,因此数据库结构是相同的。
Windows 服务器 2003,MS SQL 服务器 2005。
我正在尝试将项目列表和关联表从 SOURCE 复制到 DESTINATION。
总共有 11 个表,我使用相同的脚本格式来完成所有 11 个表的工作。其中三个失败了。
下面的例子是三个之一:
表 PK 是 ITEM_MEASURE_ID,分别在 SOURCE 或 DESTINATION 中没有重复项,据我了解,“WHERE d.ITEM_MEASURE_ID IS NULL”语句阻止它尝试将数据复制到已经存在的 DESTINATION 中。
为什么我会收到此错误?
更新 - 无法发布图像,但这里是约束和索引的一个看看。:
https ://photos-6.dropbox.com/t/1/AAD2EzrJTZFy_BMqcL5i2dWmZn1bAp5C7Y6LAHwJZ1btYQ/12/1501690/png/1024x768/3/1415138400/ 0/2/constraint.png/vvHTaOuDXOO72MN7IYeDnbLzAjQ65deom5zF9GV3jgw
UPDATE - Properties on IN_ITEM_MEASURE_UQ_ITEM_TYPE_MEASURE: https://photos-3.dropbox.com/t/1/AAC8eurM2o8SfHfvLNOsvwt8h_2P_qGpvRBmhovIp3cJzg/12/1501690/png/1024x768/3/1415142000/0/2/properties.PNG/Lf4Q_hE1QTsHgEI1BAxR9WoyL2R71MPFxDZJ5R9kXN0
php - Surrogate key part of business object?
I have a database table (mysql) representing the entity Employee in an enterprise like application. Surrogate keys are used throughout the database, so every Employee record has an auto incremented ID column identifying the Employee. I have modelled the Employee as a Business Object (BO) in php like this:
I am wondering if the $id
property should be part of that class? Actually it represents the surrogate key from database and is thus storage-related. But I want the BOs to know nothing about the way they are stored/loaded (seperation of logic from persistence). The BOs hold the business logic for me and I want to work with them WITHOUT any coupling to type of storage (database etc.). With my above class layout I could never instantiate an Employee without giving an $id
, so I guess this is not the correct way to implement a BO.
I want to work with DAO pattern to store/load Employee. Should I use the $id
only within DAO concerns?
Further I am concerned about identifying an Employee object in my application later, which would work well with the surrogate $id
. The $user
property is also unique for every Employee in the database. So maybe I should use this property instead?
primary-key - 在表(由两个字段组成)中添加现有索引作为主索引?斧头 2012
我的表中有一个索引 TestIndex,其中包含两个字段:Code1 和 Code2。
索引属性:允许重复:否,AlternateKey:是
字段属性:强制:是允许编辑:否
当我到达表属性 PrimaryIndex:SurrogateKey。我想将此 PrimaryIndex 更改为 TestIndex。但是当我点击 DropDown 它没有显示 TestIndex 值。当我手动输入 TestIndex 并单击输入其显示的 TestIndex。但是当我点击下拉列表时,我看不到 testIndex。
为什么?我所做的手动操作是错误的还是正确的?
如何在primaryIndex的下拉列表中获取TestIndex?