constraints

View at the bottom in a UIScrollView, with AutoLayout

泪湿孤枕 提交于 2019-11-27 20:47:36
问题 I'm setting up content in a scroll view with autolayout. The objects in the scrollview are pinned top-to-bottom to the previous one, so that they are under one another. I have a footer view that is added at the end, below these objects. Here's the catch: when there's few content, the contentView will be smaller than the screen height, so the footer view will appear somewhere in the middle of the screen (which is the normal behavior). But I'd like to prevent that, and make the view stay

Controlling distance of shuffling

烂漫一生 提交于 2019-11-27 19:48:17
I have tried to ask this question before , but have never been able to word it correctly. I hope I have it right this time: I have a list of unique elements. I want to shuffle this list to produce a new list. However, I would like to constrain the shuffle, such that each element's new position is at most d away from its original position in the list. So for example: L = [1,2,3,4] d = 2 answer = magicFunction(L, d) Now, one possible outcome could be: >>> print(answer) [3,1,2,4] Notice that 3 has moved two indices, 1 and 2 have moved one index, and 4 has not moved at all. Thus, this is a valid

Why use generic constraints in C#

﹥>﹥吖頭↗ 提交于 2019-11-27 19:20:58
I've read an excellent article on MSDN regarding Generics in C#. The question that popped in my head was - why should i be using generic constraints? For example, if I use code like this: public class MyClass<T> where T : ISomething { } can't I switch ALL references of T in this class with ISomething ? What's the benefit of using this approach? You ask, "can't I switch ALL references of T in this class with ISomething ?" So I think you mean to compare: public class MyClass<T> where T : ISomething { public T MyProperty { get; set; } } With: public class MyClass { public ISomething MyProperty {

Prevent insert if condition is met

本秂侑毒 提交于 2019-11-27 18:38:59
问题 I have a table Content like this: id | text | date | idUser → User | contentType And another table Answer : idAnswer → Content | idQuestion → Content | isAccepted I want to ensure that the Answer 's date is bigger than the Question 's date. A question is a Content with contentType = 'QUESTION'. I tried to solve this with the following trigger, but when I try to insert an Answer there's an error: ERROR: record "new" has no field "idanswer" CONTEXT: SQL statement "SELECT (SELECT "Content".date

PostgreSQL - disabling constraints

 ̄綄美尐妖づ 提交于 2019-11-27 17:58:48
I have a table with approx 5 million rows which has a fk constraint referencing the primary key of another table (also approx 5 million rows). I need to delete about 75000 rows from both tables. I know that if I try doing this with the fk constraint enabled it's going to take an unacceptable amount of time. Coming from an Oracle background my first thought was to disable the constraint, do the delete & then reenable the constraint. PostGres appears to let me disable constraint triggers if I am a super user (I'm not, but I am logging in as the user that owns/created the objects) but that doesn

Deferrable, case-insensitive unique constraint

可紊 提交于 2019-11-27 17:34:32
问题 Is it possible in PostgreSQL to create a deferrable unique constraint on a character column, but case-insensitive? Let's assume the following basic table: CREATE TABLE sample_table ( my_column VARCHAR(100) ); If deferrable constraint is not needed, it is as simple as creating unique index with function, e.g.: CREATE UNIQUE INDEX my_unique_index ON sample_table(UPPER(my_column)); Deferred constraint check requires creating the constraint explicitly, e.g.: ALTER TABLE sample_table ADD

Unique constraint in XML Schema

心不动则不痛 提交于 2019-11-27 17:33:56
问题 Let's say I have following XML file: <authors> <author>a1</author> <author>a2</author> <lastmodified>2010</lastmodified> </authors> and an XML schema fragment: <xs:element name="authors" maxOccurs="1"> <xs:complexType> <xs:sequence> <xs:element name="author" maxOccurs="unbounded" type="xs:string"> </xs:element> <xs:element name="lastmodified" type="xs:date" minOccurs="0"/> </xs:sequence> </xs:complexType> <xs:unique name="uniqueAuthor"> <xs:selector xpath="."/> <xs:field xpath="author"/> </xs

Can there be constraints with the same name in a DB?

戏子无情 提交于 2019-11-27 17:05:05
问题 This is a follow-on question from the one I asked here. Can constraints in a DB have the same name? Say I have: CREATE TABLE Employer ( EmployerCode VARCHAR(20) PRIMARY KEY, Address VARCHAR(100) NULL ) CREATE TABLE Employee ( EmployeeID INT PRIMARY KEY, EmployerCode VARCHAR(20) NOT NULL, CONSTRAINT employer_code_fk FOREIGN KEY (EmployerCode) REFERENCES Employer ) CREATE TABLE BankAccount ( BankAccountID INT PRIMARY KEY, EmployerCode VARCHAR(20) NOT NULL, Amount MONEY NOT NULL, CONSTRAINT

How to remove constraints from my MySQL table?

心已入冬 提交于 2019-11-27 17:02:03
I want to remove constraints from my table. My query is: ALTER TABLE `tbl_magazine_issue` DROP CONSTRAINT `FK_tbl_magazine_issue_mst_users` But I got an error: #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'constraint FK_tbl_magazine_issue_mst_users ' at line 1 Mysql has a special syntax for dropping foreign key constraints: ALTER TABLE tbl_magazine_issue DROP FOREIGN KEY FK_tbl_magazine_issue_mst_users I had the same problem and I got to solve with this code: ALTER TABLE `table_name` DROP FOREIGN

What are database constraints? [closed]

自古美人都是妖i 提交于 2019-11-27 16:52:29
What is a clear definition of database constraint? Why are constraints important for a database? What are the types of constraints? Ziga Kranjec Constraints are part of a database schema definition. A constraint is usually associated with a table and is created with a CREATE CONSTRAINT or CREATE ASSERTION SQL statement. They define certain properties that data in a database must comply with. They can apply to a column, a whole table, more than one table or an entire schema. A reliable database system ensures that constraints hold at all times (except possibly inside a transaction, for so