Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/go/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Postgresql唯一索引uuid+;带条件问题的枚举_Sql_Postgresql_Indexing_Entity Relationship - Fatal编程技术网

Postgresql唯一索引uuid+;带条件问题的枚举

Postgresql唯一索引uuid+;带条件问题的枚举,sql,postgresql,indexing,entity-relationship,Sql,Postgresql,Indexing,Entity Relationship,您好,我有一个关于带条件和枚举的唯一索引的问题, 我需要做到以下几点: 员工属于一个部门(并且只有一个部门)。 一个部门只能有一名经理和一名主管,其他职能可以由多名员工执行 我通过在字段的employee表中创建一个唯一索引来实现这一点: 部门id和职位: "create unique index employeeTest on employees(positions, departament_id) where positions <> 'tecnico'"

您好,我有一个关于带条件和枚举的唯一索引的问题, 我需要做到以下几点: 员工属于一个部门(并且只有一个部门)。 一个部门只能有一名经理和一名主管,其他职能可以由多名员工执行 我通过在字段的employee表中创建一个唯一索引来实现这一点: 部门id和职位:

"create unique index employeeTest on employees(positions, departament_id) where positions <> 'tecnico'"
“对职位‘tecnico’的员工(职位、部门id)创建唯一索引employeeTest”

我不能向部门id添加多个经理/主管,但我想知道以这种方式使用索引是否有任何问题?我的解决方案失败了吗?我能用另一种方法做得更好吗