Questions tagged [constraints]
3181 questions
1
votes
3
answer
92
Views
How to enforce by constraint that a referenced row also has a given type
I have multiple tables B,C,D ... referencing one another table A.
Let's just look at A and B:
CREATE TABLE A (
ID int PRIMARY KEY
, TYPE enum_type
);
CREATE TABLE B (
A_ID int REFERENCES A(ID)
);
Is it possible to check that A has always one specific TYPE when referenced by table B?
every row in A r...
0
votes
1
answer
16
Views
Added an Autolayout to the UITableViewCell, but I see an unknown phenomenon
I have added an Autolayout to the items in the UITableViewCell, but I have an unknown error.
All items added with AutoLayout will be aligned to the top left corner.
If I add Auto Layout to General Label :
After Build Result: General label moves to the top left corner
This is true for other items as...
0
votes
0
answer
11
Views
Adding foreign key constraint data type error
I have a table A that has a field created_by it is a int(11) unsigned with NOT NULL and no default. I want to create a foreign key constraint in table A with the users table id field that is also a int(11) unsigned with NOT NULL and no default (auto incremented).
The constraint type will be ON DELET...
1
votes
1
answer
1.5k
Views
Swift changing constraints depending on device orientation
When the device is rotated from portrait to landscape, the width constraint of the view is updated but it does not update when the device is rotated from landscape to portrait
My code:
override func viewDidLoad() {
super.viewDidLoad()
theView.translatesAutoresizingMaskIntoConstraints = false
theView...
1
votes
1
answer
25
Views
Create Unique Check + Additional Check in MS SQL Constraint
I need to add a constraint to the following table:
Table(
CategoryId INT,
CustomerId INT,
IsActive BIT
....
)
I want to have only one combination of (CategoryId, CustomerId, IsActive = 1)
just have no idea how to put that in one constraint.
Only one combination of Category and Customer to be active...
1
votes
2
answer
46
Views
Is there any difference between inline and out-of-line constraint in sql?
Which one to use or which one is the better? There's any difference?
searchtype_id bigint NOT NULL
or
CONSTRAINT searchtype_id_nn CHECK ((searchtype_id IS NOT NULL))
1
votes
1
answer
36
Views
Type-variable-dependent default method implementation in Haskell
I am trying to define default method implementations, but only if the class's type variables derive certain other classes.
I have tried creating type-dependent instances using => (am I even using it correctly?), but I get a 'duplicate instance declaration error': (https://repl.it/@solly_ucko/Distrib...
1
votes
1
answer
16
Views
How to distribute 4 components in UITableViewCell with autolayout?
I have a view with an UITableViewCell. In this custom cell like this:
I have added the textFields into UIViews, and all uiviews have this constraints with autolayout:
but then, when is running on device, all views are distributed with bad forms:
The first uiview is deformed
How could I add the const...
1
votes
0
answer
50
Views
Determine cause of SQLConstraintViolationException
I am currently writing some code that works on updating values in a database. I have a table with three constrains: a primary key (composite), a foreign key (not composite), and a unique key (composite).
My table (the output of show create table ItemAttributeMaster):
CREATE TABLE `ItemAttributeMast...
1
votes
0
answer
403
Views
Symfony3 - Validation of an embedded form
I have an embedded form like this:
-> Parent (class)
|---> Attribute 1 (collection) : children (class) : required
.......|-----> Attribute 1 : child_name (string) : required
.......|-----> Attribute 2 : child_description (string) : required
I want, when I send the form:
There is at least one parent...
1
votes
0
answer
351
Views
Constraints ignored when using xib/nib in xcode 9
Just to preface, this issue is similar to the problem of constraints being ignored in prototype cells, but I have tried all of the recommendations on this site and none have worked. I've tried:
Autolayout is ignored in Custom UITableViewCell
iOS TableView Constraints doesn’t work
autolayout issue...
1
votes
1
answer
67
Views
R expand.grid but with prohibitions
I have a list of items v1, v2, etc. Important: its length is NOT known in advance!!
Each item (v1, v2, etc.) shows possible levels: 1:2, 1:3 etc. I need to create a data frame with all possible combinations of levels for items v1, v2, etc. I could do it quite effectively using 'expand.grid':
mylist
1
votes
3
answer
31
Views
Field correlation with date constraint
We're stuck in a huge challenge here. Let's assume the tables of one db were not properly planned in first hand. That's what it is and I need a solution for that.
There's a table A with 2 fields. Let's think that I have an assistant that supports my job every day, but i just registered when he/she s...
1
votes
1
answer
108
Views
different clock contraints on the same clock
How can I have different clock constraints on signals in the same clock domain ?
In my design, I have a PLL which is configurable through APB registers.
I am also working with 2 modes (mode1 and mode2).
Depending on the mode (selectable by the user), the clock output is either 100 MHz or 70 MHz.
Bec...
1
votes
1
answer
229
Views
UIBarButtonItem Selector Function Not Being Called
All I did create a simple UIBarButtonItem but my action function won't be called for some reason no idea why (i.e. my breakpoint won't even get hit).
Here is a screenshot of the code.
1
votes
0
answer
45
Views
Defining constraints in Lagrangian (SageMath)
I am trying to maximize the function P, with constraints of x >= 75,000 and y >= 200,000. However, I do not think I am defining them correctly. I attempt to define them as arguments of the solve() function.
var('x','y', 'lam')
P = (0.05*x*(1-(x/150000) - 0.0000008*x*y)) + (0.08*y*(1-(y/200000) -
0....
1
votes
0
answer
26
Views
My image is laying on top of my text
I am trying to style my image and my text. I was able to center the image on the top. But I can't get the text to go under the image. I have included my code. I am trying to do the constraints programatically.
class LadyDetailViewController: UIViewController {
var webView: WKWebView!
var detailItem...
1
votes
1
answer
3.7k
Views
Position buttons to bottom on constraint layout
I am trying to position two buttons to the bottom of a constraint layout. In the Design view in Android Studio, everything looks OK, but when I run the app in debug, the buttons look like they are aligned with the last fields at the top of the screen. I have tried Guidelines and Barriers, but could...
1
votes
1
answer
116
Views
iOS Update Interface Builder view frame based on constraints
I am building my views in Interface Builder and I am using AutoLayout constraints. Whenever I create a Table View Cell I use Automatic Dimension so cell's heights are calculated properly.
The problem is that cell frame in interface builder is not updating on its own (I mean the whole view's cell)
T...
1
votes
1
answer
21
Views
sql integrity constraint parent key not found
I am trying to do something so simple creating and insert 4 tables with their data. I have spent hours on the web researching integrity constraints and tried several IDE's in case there's a bug but nothing seems to work. Code is shows below (excuted in order).
I can insert the data for the first two...
1
votes
0
answer
86
Views
Constraint for total specialization of overlapping classes SQL
If I have a table FOOD (for instance TOMATO) that has overlapping total specialization classes FOOD GROUP (for instance VEGETABLE and FRUIT), how can I force the element TOMATO to be contained included in at least one of the specialization classes? My current implementation looks like this:
CREATE T...
1
votes
1
answer
277
Views
SQLSTATE[23000]: Integrity constraint violation: 1052 Column : 'quantite' in field list is ambiguous
I have referenced other questions like mine, but I cannot figure out why I am getting the error in my example.
I have a method that looks like this :
$select = $this->select()->setIntegrityCheck(false)
->from(array('dmas' => $this->_name), array(
'id',
'is_new',
'id_demande',
'id_ds',
'id_station',...
1
votes
2
answer
96
Views
Java Validation Constraint : How to send validation error to client
Assume i have the following API :
@Path('/api')
public Response api(@Valid @NotNull(message = 'In cannot be null') String in) {
return Response.ok().build();
}
When the client sends an Null String the only response he gets its :'Bad Request (400)'
How do I send the Response with the above message...
1
votes
0
answer
262
Views
Multivariate multiple regression with constraints on dependent variables in R
I have several dependent variables (exactly 5) and independent variables. I would like to generate a linear regression model with several dependent variables in R. I saw how to do it with lm:
rm
1
votes
0
answer
9
Views
Part of UIButton stops responding to touch after having its height increased
I have a view, embedded into a container that it itself inside a UIScrollView.
This view contains a text aligned to its edges as well as a button, again aligned to edges.
When launching the controller view, inside viewDidLayoutSubviews, I get the actual real height of the screen, then I call the vie...
1
votes
1
answer
412
Views
Admob Banner at the top of the screen
I want to have the Admob banner at the top of the screen instead of the bottom. This is what i copied from the Admob Documentations.
func addBannerViewToView(_ bannerView: GADBannerView) {
bannerView.translatesAutoresizingMaskIntoConstraints = false
view.addSubview(bannerView)
view.addConstraints(...
1
votes
1
answer
378
Views
constraint violation exception PL/SQL
I am currently working on an assignment where I need to create an anonymous block to handle a constraint violation (the violation is that the updated credit card is too few numbers). I created the following block that throws no errors, it just returns the constraint violation. Any idea why it isnt r...
1
votes
1
answer
65
Views
Python constraint inverse
I am looking for a solution to use the numbers 2,3,4,5 for 10 times to get an exact sum of 40; so I have written the following code
from constraint import Problem, InSetConstraint, ExactSumConstraint
problem = Problem()
problem.addVariables(range(10), range(10))
problem.addConstraint(InSetConstraint...
1
votes
0
answer
31
Views
JPA / OpenJPA ADD CONSTRAINT
I am new in JPA and have a question how to tell JPA to ADD a CONSTRAINT to a TABLE in DB2. I have the following Entity:
@Entity
public class Test {
@Id
private long id;
private String a;
private String b;
...
JPA generates the following DDL:
CREATE TABLE
TEST
(
ID BIGINT NOT NULL,
A VARCHAR(254),
B...
1
votes
2
answer
68
Views
Accessing memory with various types through a void pointer
I know that using a union eliminates the worry of undefined behavior issues when accessing the same block of memory with different types, one at a time.
I was wondering if the same is true for memory allocated with malloc() and a void pointer; does the following code exhibit any form of undefined be...
1
votes
1
answer
203
Views
Animate autolayout constraints on keyboard show and hide
So as to make this short and sweet, I am trying to replicate the layout and animation of the Facebook login screen. Here it is:
I'm trying to start simple with the logo. Here is how I have setup my logoContainerView:
// Logo Container View
logoContainerView = UIImageView(image: #imageLiteral(resour...
1
votes
0
answer
62
Views
segmented control in navigation bar broke with latest Xcode 9.2
I have an app with a segmented control in the navigation bar as a navigation item that when I build with Xcode 9.2 is broken. Doesn't respond to touches in two of the segments and it is not positioned correctly anymore (should appear centered in the nav bar) Nothing has changed in the project. I....
1
votes
0
answer
59
Views
Update constraints on changing the window size of application in Split Mode Screen
I have an application which works fine in iPhone and iPad. But when the app is running in split mode I want to update the constraints for the view whenever we change the split mode window size from 1/3,2/3 and so on. How we can know that the app is working on these screens and update constraints acc...
1
votes
1
answer
456
Views
NSGenericException reason: Unable to install constraint on view
I know there are many threads with the same title and yes I read most of them. And they didn't help to atleast help me figure out what in the world is happening! I received the crashes reported in Crashlytics:
Unable to install constraint on view. Does the constraint reference something from outside...
1
votes
0
answer
46
Views
Contraint layout confusion about parent in android
Below are two textviews with different constraint the first textview is 'Home' and it contains app:layout_constraintRight_toLeftOf='parent' constraint and another is 'World' and contains the app:layout_constraintRight_toRightOf='parent'. So both are gives the same result. I mean both textviews are p...
1
votes
0
answer
58
Views
Portfolio optimization on R with constraints
I'm trying to solve this problem where I've to find the minimum variance portfolio composed on the asset in the Dataset, given that each weight should be larger than 0 and the sum equal to 1. Using this code I get a weights vector which respect only the second constraint (sum=1) while in the solutio...
1
votes
1
answer
50
Views
Using CONSTRAINT alogn with FOREIGN KEY
I'm trying to understand the difference between creating a FOREIGN KEY this way:
CREATE TABLE child(
id_child INT NOT NULL,
id_parent INT
FOREIGN KEY(id_parent) REFERENCES parent(id_parent));
rather than this one:
CREATE TABLE child(
id_child INT NOT NULL,
id_parent INT
CONSTRAINT FK_id_pare...
1
votes
1
answer
168
Views
Matlab CPLEX: add multiple SOCP constraints in cplexmiqcp
I have written my problem in MATLAB, using CPLEX as the solver. Due issues that are beyond my control (it is feasible), the CPLEX class API screws up when solving my problem. So, based on post found elsewhere on the internet, I am trying to solve using the toolbox API.
To solve my problem I need to...
1
votes
0
answer
148
Views
Swift Scenekit Camera: In Direction of Character
I am trying to create my own game using Swift and I want to know how to use the camera in SceneKit to make it fixed to the back of the characters head and also move and rotate with the camera.
My first idea was to make the direction of the character be equal to the direction of the camera but that d...
1
votes
0
answer
176
Views
Multiple constraint issues after updating to Xcode 9
I've been working on an app for quite some time now and after switching to Xcode 9, I got a lot of constraint warnings. I managed to fix them but now I keep getting the following 3 warnings on a regular basis:
Fixed width constraints may cause clipping.
Fixed leading / trailing constraints with a ce...