constraints

SQL constraint to check whether value doesn't exist in another table

最后都变了- 提交于 2019-12-06 02:34:51
In my PostgreSQL 9.4 database, I have a table fields with a column name with unique values. I'm creating a new table fields_new with a similar structure (not important here) and a column name as well. I need a way to constraint name values to be inserted to the fields_new not to be present in fields.name . For example, if fields.name contains the values 'color' and 'length' , I need to prevent fields_new.name from containing 'color' or 'length' values. So, in other words I need to provide that the name columns in both tables do not have any duplicate values between them. And the constraint

Matching with constraints

一世执手 提交于 2019-12-06 02:08:32
For fun, I'm creating a program that generates partners for a Secret Santa gift exchange. However, in this setup, instead of randomly generating pairs, constraints are allowed. Example: Person A and Person B hate each other, so neither A nor B should be assigned to buy a gift for the other. Second Example: Person C bought a gift for Person D last year. Person C should not be assigned to buy a gift for Person D, but person D should still be allowed to buy C a gift. In general, I want to generate a bijective function from a set to itself, but that function needs to be sensitive to constraints.

Projection of solutions

偶尔善良 提交于 2019-12-06 01:59:44
Is there a possibility to tell MiniZinc to project solutions on a subset of the set of variables? Or is there any other way to enumerate all solutions that are unique wrt to evaluation of some subset of variables? I have tried to use FlatZinc annotations directly in MiniZinc, but it does not work, since the flattening process adds more defines_var annotations and my annotations are ignored. I tried the following model in MiniZinc 2.0 ( https://www.minizinc.org/2.0/index.html ) and this seems to work as you expect, i.e. that just x1 and x2 are projected (printed) in the result. int: n = 3; var

How to have a primary key combination that may have null values?

我是研究僧i 提交于 2019-12-06 01:32:43
问题 I have two tables A and B as defined bellow. create table A ( A_1 varchar2(10) NOT NULL, A_2 varchar2(10), A_3 varchar2(10), constraint A_PK primary key (A_1,A_2) ) TABLE A DATA A_1 |A_2 |A_3 1111 abc some_text1 1111 null some_text1 1112 abc some_text2 1113 def some_text3 create table B ( B_1 varchar2(10) NOT NULL, B_2 varchar2(10), B_3 varchar2(10), constraint B_PK primary key (B_1,B_2,B_3), constraint B_FK foreign key (B_1,B2) references A(A_1,A_2) ) TABLE B DATA B_1 | B_2 |B_3 1111 abc

How to deal with error applying BeanValidation relational constraints?

瘦欲@ 提交于 2019-12-06 01:18:09
问题 I've got some problems with making oneToMany relation in Spring + Hibernate 4.1 application This is my entities classes. Every USER_ROLE record has FK to USER record. I can't find anything useful on the Internet. @Entity @Table( name = "USERS" ) public class User { long id; String login; String password; String name; String surname; GregorianCalendar birthDate; String email; GregorianCalendar joinDate; String randomKey; List<UserRole> userRoles = new ArrayList<UserRole>(); public User(){ } /

“Fixed leading and trailing constraints may cause clipping” bug?

社会主义新天地 提交于 2019-12-05 23:31:37
问题 There's this other question here that addresses a similar issue, but in that case Xcode's behavior is correct, just annoying. In my case, however, I think it's actually a bug: That label can have an unlimited number of lines, so it'll never be clipped, the text will just break. It works fine with every localization: I want the label to be centered and I want the text to be at least 20 pixels away from the margins, so I set fixed constraints for the leading and trailing. Xcode wants me to

print constraints Gurobi Python

為{幸葍}努か 提交于 2019-12-05 21:56:01
I'm using Gurobi in Python and for a given set S I'm adding the constraint as follows: for i in S: m.addConstr(quicksum(x[i,j] for j in (set(V) - set(S))) >= 2) I want to print these constraints for each value of the sets S and V on the screen. For an example, if S={1,3,4} and V= {1,2,3,4,5,6} , then, my constraint will be x[1,2]+x[1,5]+x[1,6]+x[3,2]+x[3,5]+x[3,6]+x[4,2]+x[4,5]+x[4,6]>=2 I want this constraint to be preinted on the screen. Can someone please help me to do it? There is no built-in function to do this. Your best option is to call Model.write() to export the model as an LP file.

iOS Auto Layout Constraint's Jumping After View Has Loaded

ε祈祈猫儿з 提交于 2019-12-05 21:42:27
Made a quick video demonstrating the issue here: https://vid.me/9kB5 When I remove the constraints the text does not jump upon loading the view. But then it defeats the purpose. When I setup the constraints I used "Reset to Suggested Constraints" Any ideas? This is not a constraint issue. Your view is going under the navigation bar. You can fix it in storyboard by unchecking "Extend Edges - Under Top Bar" in Page View Controller scene. In code - (void)viewDidLoad { [super viewDidLoad]; self.edgesForExtendedLayout = UIRectEdgeNone; } Hari Kunwar's answer didn't work for me, though. What worked

Custom cell in UITableView shifts right after swipe to edit

有些话、适合烂在心里 提交于 2019-12-05 21:16:32
I just want a simple UITableView with the ability to slide left to delete. Everything works okay except the right constraint on the textview in my prototype cell seems to get shifted after swiping to delete. Here's my code for the table: func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { //Uses prototype cell from Interface Builder called "CommentTableCell" let tableCell = tableView.dequeueReusableCellWithIdentifier("CommentTableCell", forIndexPath: indexPath) as! CommentTableCell tableCell.userInteractionEnabled = true tableCell

Resize view with Auto Layout between 3.5 and 4 inch form factor

只愿长相守 提交于 2019-12-05 21:14:46
I have a prototype tableview cell, with a custom view inside of the tableview cell. The view controller that contains the tableview will only be displayed in landscape mode. The goal is for the UIView that is inside of the tableview cell to resize it's width based on the form factor. So for example there might be a 20pt spacing on the left and right and then the uiview resizes it's width to fill the rest of the space. I'm hoping to do this with storyboard and autolayout. In 3.5 inch form factor it looks like this (this is what it should look like in 4 inch mode as well) In 4 inch form factor