Skip to content

Conversation

sploiselle
Copy link
Contributor

@sploiselle sploiselle commented Nov 29, 2016

Converted constraints.md as a branch page to individual pages for each constraint:

  • check.md
  • default-value.md
  • foreign-key.md
  • not-null.md
  • primary-key.md
  • unique.md

Also updated all links and changed sidebar structure to surface Constraints as third-level items.


This change is Reviewable

Copy link
Contributor

@jseldess jseldess left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks, @sploiselle.

beta-20160519.md Outdated
- [`EXPLAIN DELETE`](explain.html) no longer executes the `DELETE` statement. [#6622](https://github.com/cockroachdb/cockroach/pull/6622)
- [`CHECK`](constraints.html#check) constraints are now enforced during [`UPDATE`](update.html) statments. [#6753](https://github.com/cockroachdb/cockroach/pull/6753)
- [`CHECK`](constraints.html#check) constraints now work correctly when columns have been dropped. [#6730](https://github.com/cockroachdb/cockroach/pull/6730)
- [`CHECK`](check.html) constraints are now enforced during [`UPDATE`](update.html) statments. [#6753](https://github.com/cockroachdb/cockroach/pull/6753)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spelling error in the original: statments

check.md Outdated

- Check constraints requires that the column values satisfy a Boolean expression within the constraint. The expression must evaluate to `TRUE` (or *NULL*) for every row affected by an `INSERT` or `UPDATE` statement. The DML statement will fail if the condition evaluates to `FALSE` for any row.
- Check constraints may be specified at the column or table level and can reference other columns within the table. Internally, all column level Check constrints are converted to table level constraints so they can be handled in a consistent fashion.
- You can have multiple Check constraints on a single column but ideally these should be combined using the logical operators. So, for example,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this recommendation, but is there a technical reason behind it? Or is this just best practice in terms of legibility?

Copy link
Contributor Author

@sploiselle sploiselle Nov 30, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested this and it's actually getting converted to two inequalities. So, not sure. @bdarnell Any suggestions as to why we make this recommendation?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, that makes sense. Whenever a "should"-type recommendation is used, as a reader, I prefer a little of the reasoning. How about:

... but ideally, for computational efficiency, they should be combined using the logical operators.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it'll be slightly cheaper to evaluate fewer expressions, and we can potentially optimize things away, etc so yeah, when it doesn't make it harder to understand/maintain, folding multiple CHECK expressions into one is good, but the savings aren't usually going to be a big deal.

check.md Outdated
warranty_period INT CHECK (warranty_period BETWEEN 0 AND 24)
~~~

- Check constraints that refer to multiple columns should be specified at the [table level](#multiple-column-table-level).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems reasonable, but is there a technical reason behind this recommendation?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was in the existing doc, but I'm not sure about the technical reasoning. @bdarnell can you provide a rationale for this recommendation apart from legibility in the CREATE TABLE statement?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, sorry to loop that edit in here. We could handle that in a separate PR, if you like.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All CHECK constraints get moved to the table level anyway, so it doesn't really matter.

constraints.md Outdated
Constraints offer additional data integrity by enforcing conditions on the data within a column or row. They are checked during DML operations and restrict the data values within a column to those specified within the constraint.

If a constraint refers to only one column (column-level constraint) it can be defined against the column as part of its definition. If a constraint refers to more than one column (table-level constraint) it needs to be defined as a separate entry in the tables definition.
If a constraint refers to only one column (column-level constraint) it can be defined against the column as part of its definition. If a constraint refers to more than one column (table-level constraint) it needs to be defined as a separate entry in the tables definition.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: In both sentences, add a comma after the closing parenthesis to separate the clauses.

@sploiselle sploiselle merged commit d350023 into gh-pages Dec 5, 2016
@sploiselle sploiselle deleted the constraint-pages branch December 5, 2016 22:12
Simran-B added a commit to Simran-B/docs that referenced this pull request Aug 21, 2025
* removed javadoc from Spring Data documentation

* Remove deleted files from navigation

* Fix a few typos, remove useless description frontmatter

Co-authored-by: Simran Spiller <simran@arangodb.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants