constraints

Combine a PostgreSQL EXCLUDE range constraint with a UNIQUE constraint

﹥>﹥吖頭↗ 提交于 2019-12-09 16:38:13
问题 In PostgreSQL, how do you combine an exclusion constraint on a range column with a unique constraint on other, scalar columns. Or to put it another way, how do I ensure that the range overlap check is only done in combination with a unique check on some other columns? For example, say I have: CREATE TABLE reservation ( restaurant_id int, time_range tsrange ); I want to make sure that for each restaurant_id , there are no overlapping time_range s. I know that I can create an exclusive range

add constraints programmatically swift

三世轮回 提交于 2019-12-09 14:38:25
问题 I am trying to add constraints to a facebook sdk login button. I have the button inside a scroll view and I am trying to add a top constraint to a label that is also in the scroll view. I am able to successfully add the height constraint with no run time errors but the actual constraint does not seem to be applied to the button. @IBOutlet weak var orLbl: UILabel! @IBOutlet weak var scrollView: UIScrollView! override func viewDidLoad() { super.viewDidLoad() var loginFBButton = FBSDKLoginButton

How to alter length of varchar in composite primary key?

99封情书 提交于 2019-12-09 08:40:11
问题 In MSSQL I have a table created like this: CREATE TABLE [mytable] (fkid int NOT NULL, data varchar(255) CONSTRAINT DF_mytable_data DEFAULT '' NOT NULL); ALTER TABLE [mytable] ADD CONSTRAINT PK_mytable_data PRIMARY KEY (fkid, data); Now I want to increase the length of the 'data' column from 255 to 4000. If I just try: ALTER TABLE [mytable] ALTER COLUMN data varchar(4000); Then I get this error: The object 'PK_mytable_data' is dependent on the column 'data' If I try this: ALTER TABLE [mytable]

Algorithms for Updating Relational Data

女生的网名这么多〃 提交于 2019-12-09 07:14:09
问题 What algorithms are known to perform the task of updating a database by inserting, updating, and deleting rows in the presence of database constraints? More specifically, say that before images of rows to be deleted, after images of rows to be inserted, and both images of rows to be updated are in memory. The rows might be for several tables. An exact sequence of updates is either not known or has not been preserved -- only the before images and the after images that the database must

Difference between _sql_constraints and _constraints on OpenERP/Odoo?

非 Y 不嫁゛ 提交于 2019-12-09 04:52:07
问题 I noticed there are 2 kinds of constraints on Odoo ERP. But I want to know what is the difference between _sql_constraints vs _constraints? _sql_constraints = { ('email_uniq', 'unique(email)', ' Please enter Unique Email id.') } _constraints=[ (_check_qty_and_unitprice, u'Qty must be more than 0',['product_qty', 'cost_unit']), ] 回答1: _sql_constraints means it will set constraint on postgresql database side. _sql_constraints = [ ('email_uniq', 'unique(email)', ' Please enter Unique Email id.')

Sql Conditional Not Null Constraint

冷暖自知 提交于 2019-12-09 04:18:13
问题 I am curious to know is it possible to create a conditional not null constraint in sql? In otherwords is it possible to create a constraint such that a column B can be null as long column A contains lets say 'NEW' but if the contents of column A changes to something else then column B is no longer allowed to be null? And to extend on that, it is then possible to make it so that column B must be null or empty as long as column A says 'NEW'? Thanks All :D 回答1: This is perfectly fine for

Type parameter 'T' has the same name as the type parameter from outer type '…'

杀马特。学长 韩版系。学妹 提交于 2019-12-09 02:20:12
问题 public abstract class EntityBase { ... } public interface IFoobar { void Foo<T>(int x) where T : EntityBase, new(); } public interface IFoobar<T> where T : EntityBase, new() { void Foo(int x); } public class Foobar<T> : IFoobar, IFoobar<T> where T : EntityBase, new() { public void Foo(int x) { ... } void IFoobar.Foo<T>(int x) { Foo(x); } } I get a compiler warning: Type parameter 'T' has the same name as the type parameter from outer type '...' I tried doing: void IFoobar.Foo<U>(int x) { Foo

MySQL composite unique on FK's

六眼飞鱼酱① 提交于 2019-12-09 01:45:39
问题 I want to implement the following constraints in mysql: create table TypeMapping( ... constraint unique(server_id,type_id), constraint foreign key(server_id) references Server(id), constraint foreign key(type_id) references Type(id) ); This throws a 'ERROR 1062 (23000): Duplicate entry '3-4' for key 'server_id'' when I issue an insert/update that would break the constraint. Is this type of constraint even possible? If so how? Thank you. 回答1: Yes, that is perfectly valid. Make sure you

Constructor with optional parameter violates new() constraint

时间秒杀一切 提交于 2019-12-08 19:37:59
问题 I have a class with this constructor: public Currency(Guid? vcurrencyUI = null) : base(vcurrencyUI) { } and I want to use this class with a new() constraint but I get this error: 'Currency' must be a non-abstract type with a public parameterless constructor in order to use it as parameter 'T' in the generic type or method ... If I split the constructor everything works fine: public Currency(Guid? vcurrencyUI) : base(vcurrencyUI) { } public Currency() : base() { } why do I need to split the

Unique constraint within a group of records where some value is the same

。_饼干妹妹 提交于 2019-12-08 17:53:23
问题 DBMS: MS Sql Server 2005, Standard I'd like to make a table constraint to have only one record have a particular value within a subset of the table (where the rows share a value in a particular column). Is this possible? Example: I have records in myTable which have a non-unique foreign key (fk1), and a bit column called isPrimary to mark out that this particular one should be used by our app for special logic. in the abstract, it looks like this: myTable ------------- pk1 (int, not null)