constraints

How to create sql constraints in my table

一个人想着一个人 提交于 2019-12-11 09:35:32
问题 i have this table: id | product_group_id | percentage 1 | 1 | 0.2 2 | 1 | 0.3 3 | 1 | 0.5 4 | 2 | 0.4 5 | 2 | 0.6 I want to know if there is a way to create constraints that for each product_group_id the percentage will be equal to 1 ( if product_group_id = 1 so 0.2 + 0.3 + 0.5 = 1). For example if i will change the percentage where id = 2 to 0.8 or 0.1, the update (or insert) will fail because the sum is not 1. Thanks in advanced. 回答1: It would generally make more sense to enforce this sort

How can I create a query constraint

冷暖自知 提交于 2019-12-11 08:42:27
问题 I have a table Items, which has fields Inventory and ItemId (the primary key). And I have another table Allocations, which has fields Allocation and ItemId, which is a foreign key referencing Items.ItemId. Thus many Allocations can relate to one Item. I wonder how I can add a constraint to not allow SUM(Allocation) in the Allocations table for the same ItemId to accede Items.Inventory for that ItemId. I could find only very simple examples, so I am not sure how to approach this problem. 回答1:

Swift constraint autosize label width

断了今生、忘了曾经 提交于 2019-12-11 08:06:29
问题 This is my code to make UILabel autosize: gmatesLabel.topAnchor.constraint(equalTo: homeButton.bottomAnchor, constant: 5).isActive = true gmatesLabel.trailingAnchor.constraint(equalTo: gmatesUniversitySeparatorView.leadingAnchor, constant: -20).isActive = true gmatesLabel.heightAnchor.constraint(equalToConstant: 40).isActive = true // gmatesLabel.widthAnchor.constraint(equalTo: gmatesLabel.widthAnchor, multiplier: 0.5) gmatesLabel.setContentCompressionResistancePriority

postgresql: error duplicate key value violates unique constraint

时光怂恿深爱的人放手 提交于 2019-12-11 07:42:56
问题 This question have been asked by several people but my problem seems to be different. Actually I have to merge same structured tables from different databases in postgresql into a new DB. What I am doing is that I connect to remote db using dblink, reads that table in that db and insert it into the table in the current DB like below INSERT INTO t_types_of_dementia SELECT * FROM dblink('host=localhost port=5432 dbname=snap-cadence password=xxxxxx', 'SELECT dementia_type, snapid FROM t_types_of

Z3Py: Generating Abstract Formulas From A System Of Equations

喜欢而已 提交于 2019-12-11 07:32:40
问题 My Example: system of equations Pseudo-Code Constraint Base a = b+c ∧ e = a*c ∧ a = +2 ; some replaceable concrete values ∧ c = +18 Solution b = -16 ∧ e = -32 The Information I Want In a system of equations, I want to get the following knowledge: Abstract formulas which I can use to compute the variable values (the solution) from the given values (in the constraint base). (Like in high school where the teacher don't just wanted the see the result, but also such an transformated abstract

Change height constraint of table view outside of viewDidAppear in iOS 7

痞子三分冷 提交于 2019-12-11 07:17:37
问题 In my View Controller's .xib file I'm using a UITableView which has a dynamic number of rows. Because it's not the only element in the .xib file (there are other elements below and above it), I need to change it's height constraint after I know the number of rows. To achieve this, I'm using this solution that works fine. Therefore: @implementation MyViewController { __weak IBOutlet UITableView *_tableView; __weak IBOutlet NSLayoutConstraint *_tableViewHeightConstraint; } - (void)viewDidAppear

Table inheritance: Enforcing unique constraints across partitions?

☆樱花仙子☆ 提交于 2019-12-11 07:14:10
问题 I have a table that I would like to partition, but I don't know how to deal with the uniqueness constraints. Is it possible to create a unique constraint across multiple child tables? 回答1: No, this is not currently possible. The best you can do is to create a trigger that does the verification manually. 来源: https://stackoverflow.com/questions/936818/table-inheritance-enforcing-unique-constraints-across-partitions

CollectionView Cell changing size after scrolling - AutoLayout

非 Y 不嫁゛ 提交于 2019-12-11 07:01:07
问题 I have a Collection View nested in a Collection View. What I have done to try and have the cell size change dynamically based on content is create an outlet for the height of the child collection and change its constant after getting the content size. This is a screen show of my IB constraints, and I'm using the height one highlighted. So i have the child collection view (aqua's color box) constrained to the cell of the parent on 4 sides with height constant. In my custom cell class, which

how to change to before and after constraints when pressing button (swift code)?

纵饮孤独 提交于 2019-12-11 06:57:13
问题 This code has a button that when pressed the blue square above the button becomes smaller. But when pressing the button again the square does not revert back to its original size. This is because the buttons func only has one command. How can I command the button to go back and forth between its original size and smaller size by only pressing one button. This is swift code. // // ViewController.swift // ssfsfd // // Created by John Zalubski on 8/28/16. // Copyright © 2016 John Zalubski. All

Android studio doesn't draw button correctly

点点圈 提交于 2019-12-11 06:48:14
问题 In my Android studio project I have a fragment with constraint layout inside. Here is XML. <android.support.constraint.ConstraintLayout android:id="@+id/pinLayout" android:layout_width="match_parent" android:layout_height="250dp" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintHorizontal_bias="0.5" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@+id/topLayout"> <android.support.constraint.ConstraintLayout android:layout_width="0dp" android