是否可以在postgreSQL中将表A ID索引为表B userId
Is it possible to index table A ID to table B userId in postgreSQL?
是否可以在postgreSQL中将表A ID索引到表B userId?所以我会通过id或类似的东西加入两个表。
为了更好地解释我的问题,这里有一个mongoDB和mongoose的例子:
const Billing = new Schema({
account:Number,
user: {
type: Schema.Types.ObjectId,
ref: 'user',
required: true
}
});
// later in the code i can do something like
Billing.findOne().populate('user');
这将在向用户计费之间创建虚拟关系。
能用postgreSQL 做这样的事情吗
我正在使用sequelize ORM。
听起来像是在谈论外键http://www.postgresql.org/docs/8.3/static/tutorial-fk.html
在你的情况下,它应该是这样的:
create table B (
userid varchar(80) primary key,
<other fields>
);
create table A (
id varchar(80) references B(userid),
<other fields>
);
类型可以不同,因为您需要
相关文章:
- 基于类似索引的queryString的Id选择器
- 哪个更快?按 ID 选择,或按索引选择
- 是否可以在postgreSQL中将表A ID索引为表B userId
- Javascript原型通用Enquries和通过数组索引分配Id
- document.getElementById('id').selectedIndex 不读取索引,而是
- 使用名称 jQuery 按索引获取 ID 值
- 如何重新索引 HTML 元素名称和 ID
- 如何在ActiveAdmin中使用Javascript检索索引页面上所选ID的列表
- 在给定行索引和表 ID 的情况下隐藏/取消隐藏表行
- IE 10,document.links无法使用链接的ID访问,而只能使用索引访问
- YDN 数据库 按 ID 删除记录 (索引数据库)
- 使用json中的id查找对象索引
- 根据引导程序在活动索引中查找面板的id
- 使用索引元素id时出现意外错误
- 从具有多个ID's是索引'd
- 将各种ID与循环中的索引进行匹配
- 按ID快速查找索引
- Angularjs指令elem.id=$index不是其实际索引
- jQuery-如何在另一个容器DIV中找到ID的索引
- Vue.js在我的对象数组中使用唯一 id 来获取我的对象的索引