constraints

How I can define this constraint?

℡╲_俬逩灬. 提交于 2020-03-23 14:32:53
问题 I am designing a database for a parking lot in Postgres. I need to define a constraint (or similar) to verify the Id_Lot in Ticket is empty in the table "Lot" . How I can do it? The relevant tables are: Ticket: "Id_Ticket" serial PRIMARY KEY, "Date_Entrance" date NOT NULL, "Time_Entrance" time without time zone NOT NULL, "License_plate" varchar(6) NOT NULL references "Vehicle"("L_Plate"), "Id_Lot" varchar(4) NOT NULL references "Lot"("Code") Lot: "Code" varchar(4) NOT NULL PRIMARY KEY, "Type"

Foreign Key Constraint in child table allows to insert values that doesn't exists in the parent table

房东的猫 提交于 2020-03-15 05:49:17
问题 I am using SQL Server 2012. I have defined a foreign key constraint on a table. The foreign key references composite primary key. The fk constraint does not work when one column has '00000' and other column is null. The parent table does not contain '00000'. Both of the fk columns have varchar data type. Below is the example: INSERT INTO XYZ ([BUSINESS_PARTNER_ID] ,[INDUSTRY_TYPE_CDE] ,[INDUSTRY_SUBTYPE_CDE]) VALUES (1, Null '00000') GO The industry type and industry sub type column is

A generic class with two non-equal (unique) types

雨燕双飞 提交于 2020-02-23 09:29:27
问题 Is it possible to implement a class constrained to two unique generic parameters? If it is not, is that because it is unimplemented or because it would be impossible given the language structure (inheritance)? I would like something of the form: class BidirectionalMap<T1,T2> where T1 != T2 { ... } I am implementing a Bidirectional dictionary. This is mostly a question of curiosity, not of need. Paraphrased from the comments: Dan: "What are the negative consequence if this constraint is not

Core Data Entity Unique Constraint Does Not Work

≡放荡痞女 提交于 2020-02-22 05:45:18
问题 I am trying to set a constraint in core data with the new Entity Constraints inspector (To make the name of the item unique). All that I've read says it's pretty simple - Set the constraint and handle the error. I don't get any errors and can add the same entry as many times as I want. The app does require IOS 9.0, Xcode tools requirement is set to 7.0 The constraint, category1Name, is a String. My addItem code is: func addNewRecord() { //check to be sure the entry is not empty if

How to put an interface constraint on a generic method in C# 3.5?

雨燕双飞 提交于 2020-02-21 12:37:30
问题 I want to achieve something like this in C# 3.5: public void Register<T>() : where T : interface {} I can do it with class or struct, but how to do it with an interface? 回答1: C# and the CLR don't support overall interface constraints, although you can constrain it to a particular interface (see other answers). The closest you can get is 'class' and check the type using reflection at runtime I'm afraid. Why would you want an interface constraint in the first place? 回答2: If you are asking about

R function to calculate nearest neighbor distance given [inconsistent] constraint?

给你一囗甜甜゛ 提交于 2020-02-21 05:57:42
问题 I have data consisting of tree growth measurements (diameter and height) for trees at known X & Y coordinates. I'd like to determine the distance to each tree's nearest neighbor of equal or greater size . I've seen other SE questions asking about nearest neighbor calculations (e.g., see here, here, here, here, etc.), but none specify constraints on the nearest neighbor to be searched. Is there a function (or other work around) that would allow me to determine the distance of a point's nearest

VB.Net - How can I check if a primary key exists in an Access DB

陌路散爱 提交于 2020-02-08 07:26:02
问题 I want to check in an Access Database if a primary key exists using VB.Net & OleDb: By primary key name By number of fields as primary keys 回答1: From here: Public Shared Function getKeyNames(tableName As [String], conn As DbConnection) As List(Of String) Dim returnList = New List(Of String)() Dim mySchema As DataTable = TryCast(conn, OleDbConnection).GetOleDbSchemaTable(OleDbSchemaGuid.Primary_Keys, New [Object]() {Nothing, Nothing, tableName}) ' following is a lengthy form of the number '3'

Table level constraint to prevent overlapping date ranges

你离开我真会死。 提交于 2020-02-06 04:11:37
问题 Below is the schema where I need to put a constraint such that a second new entry could be put in for a room number, even before the existing depDt for the same room number. Could any of you please help me with this?? CREATE TABLE Accomodation ( roomNo INTEGER NOT NULL, arrDt DATE NOT NULL, depDt DATE NOT NULL, PRIMARY KEY (roomNo, arrDt), CONSTRAINT date_chk CHECK (arrDt < depDt) ); INSERT INTO HotelStays(roomNo, arrDt, depDt) VALUES (123, to_date('20160202', 'YYYYMMDD'),to_date('20160206',

Constraint database

痞子三分冷 提交于 2020-02-03 04:15:31
问题 I know the intuition behind constraint programming, so to say I never really experienced programming using a constraint solver. Although I think it is a different situation to be able to achieve what we would define as consistent data. Context: We have a set of rules to implement on a ETL server. These rules are either: acting on one row. acting inter-rows, in one or different tables. acting the same way between two runs (It should maintain the same constraint on all data, or just the last n

How to change layout constraints programmatically on display rotation

余生颓废 提交于 2020-01-25 15:52:21
问题 For an app (iOS 7 compatible) I need to have the possibility for totally different layouts in landscape and portrait mode. I see the only way in setting the constraints programmatically and change them on rotation. So I set my interface using IB and then set the constraints programmatically. I saw somewhere the approach to remove first all constraints, then create and add new constraints and then set the update flag for constraints on the parent view. I want the elements just to be full width