Quantcast
Channel: Active questions tagged constraints - Stack Overflow
Browsing index pages (472 articles)

Need to return a value and its count as 0 when it does not exist with in a...

Below is my exact code as it sits. This query works excellent except for when the teamid does not exist inside the date range. If the teamid does not exist within the date range specified, I want SQL...

View Article


Postgres caseinsensitive unique key constraint: What is the fast option?

I want to have a case-insensitive unique key on a large table.I'm looking for the fastest approach.I found two options: my_table_a with a generated column and my_table_b with a unique indexCREATE TABLE...

View Article


Efficiently enumerating multinomials with constant sum - R

Let's say I have an N-side dice with non-uniform probabilities for each side and I throw it M times. Now instead of observing the individual outcomes, we only observe the sum.I have to code the...

View Article

Go generics: self-referring interface constraint

I have a couple custom types that I need to process in the same way. It seems like a perfect use for generics. In the process, I need to call methods on instances of the types, and those methods return...

View Article

Image may be NSFW.
Clik here to view.

Direct Collocation Oscillating Reconstructed State Trajectory

I am working with the DirectCollocation class and an often getting trajectory solutions with large oscillations (sometimes in the position, almost always in the velocity). These oscillations seem to...

View Article


Disabling foreign key constraint, still can't truncate table? (SQL Server 2005)

I have a table called PX_Child that has a foreign key on PX_Parent. I'd like to temporarily disable this FK constraint so that I can truncate PX_Parent. I'm not sure how this goes however. I've tried...

View Article

Postgres unique constraint vs index

As I can understand documentation the following definitions are equivalent:create table foo ( id serial primary key, code integer, label text, constraint foo_uq unique (code, label));create table foo (...

View Article

Oracle: Continuing Inserts with failing deferred constraints

Sorry for the long question, but I would prefer it to be complete.My goal is to create a process to populate an Oracle 11 Database with data created by (and from) an MS-SQL Server.I would like to load...

View Article


OptaPlanner Constraint Streams: Can complement() use a derived groupBy key

I’m using OptaPlanner Constraint Streams (Java) and want to penalize employees who work less than their minimum required minutes per week, including weeks with zero shifts.I currently have this...

View Article


Symfony 5 - Use Assert Expression in a form

I would like use Expression constraint from the form.Now, I've my Expression constraint in my entity, like this : /** * @ORM\Column(type="string", length=255) *...

View Article

MySQL: Add constraint if not exists

In my create script for my database create script looking something like this:CREATE TABLE IF NOT EXISTS `rabbits`( `id` INT UNSIGNED NOT NULL AUTO_INCREMENT, `name` VARCHAR(255) NOT NULL,...

View Article

Information schema and Primary Keys

How do I just print out a 'primary key' for the column with the primary key? I get 'primary key' for all the columns if the table has a primary key, instead of the one column with the primary key and...

View Article

Why doesn't C++ allow virtual function overrides to be constrained by a...

I tried to write the following code and it was rejected by the compiler:#include <type_traits>struct Base { virtual void f() {}};template <typename T>struct Derived : Base { virtual void...

View Article


C#: Enum.IsDefined on combined flags

I have this enum:[Flags]public enum ExportFormat{ None = 0, Csv = 1, Tsv = 2, Excel = 4, All = Excel | Csv | Tsv}I am trying to make a wrapper on this (or any, really) enum which notifies on change....

View Article

Is there any way to enforce a unique constraint on DB from now onwards,...

I'm working with PostgreSQL and I want to enforce a particular column to be unique.But this table has some legacy data in which duplicate of the column are there and they have to be retained...

View Article


PostgreSQL, unique on combination of two columns

In PostgreSQL, it is easy to set a uniqueness constraint for two columns using CONSTRAINT UNIQUE.For exampleCREATE TABLE someTable ( id serial PRIMARY KEY, col1 int NOT NULL, col2 int NOT NULL, UNIQUE...

View Article

Unique Key constraints for multiple columns in Entity Framework

I'm using Entity Framework 5.0 Code First;public class Entity { [Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)] public string EntityId { get; set;} public int FirstColumn { get; set;} public...

View Article


Image may be NSFW.
Clik here to view.

Complex constraints using OR Tools in Python for a scheduling problem

I'm trying to use the OR Tools library to solve a scheduling problem in Python, and it's really similar to the nurse scheduling solved in their blog. The only difference is that I can't model shifts...

View Article

Adding CHECK Constraint Without Error and Duplication [duplicate]

I have implemented this code to add a check constraint after creating the tableALTER TABLE recruitment_data.candidate_experiences ADD CONSTRAINT chk_experience_dates CHECK ( experience_end_date IS NULL...

View Article

INSERT query error: "Cannot add or update a child row: a foreign key...

I am getting this error while inserting in my table:A Database Error OccurredError Number: 1452Cannot add or update a child row: a foreign key constraint fails (`giftme`.`giftme_shop`, CONSTRAINT...

View Article
Browsing index pages (472 articles)


Latest Images