Skip to content

Commit 4b1add3

Browse files
authored
Merge pull request MicrosoftDocs#5278 from pricardo03/patch-7
new example using constraint
2 parents f2b0a25 + 6673435 commit 4b1add3

1 file changed

Lines changed: 16 additions & 2 deletions

File tree

docs/t-sql/statements/create-table-sql-graph.md

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,15 +111,19 @@ This document lists only arguments pertaining to SQL graph. For a full list and
111111
Creates an edge table.
112112

113113
*table_constraint*
114-
Specifies the properties of a PRIMARY KEY, UNIQUE, FOREIGN KEY, CONNECTION constraint, a CHECK constraint, or a DEFAULT definition added to a table
114+
Specifies the properties of a PRIMARY KEY, UNIQUE, FOREIGN KEY, CONNECTION constraint, a CHECK constraint, or a DEFAULT definition added to a table.
115+
116+
> [!NOTE]
117+
> CONNECTION constraint applies only to an edge table type.
115118
116119
ON { partition_scheme | filegroup | "default" }
117120
Specifies the partition scheme or filegroup on which the table is stored. If partition_scheme is specified, the table is to be a partitioned table whose partitions are stored on a set of one or more filegroups specified in partition_scheme. If filegroup is specified, the table is stored in the named filegroup. The filegroup must exist within the database. If "default" is specified, or if ON is not specified at all, the table is stored on the default filegroup. The storage mechanism of a table as specified in CREATE TABLE cannot be subsequently altered.
118121

119122
ON {partition_scheme | filegroup | "default"}
120123
Can also be specified in a PRIMARY KEY or UNIQUE constraint. These constraints create indexes. If filegroup is specified, the index is stored in the named filegroup. If "default" is specified, or if ON is not specified at all, the index is stored in the same filegroup as the table. If the PRIMARY KEY or UNIQUE constraint creates a clustered index, the data pages for the table are stored in the same filegroup as the index. If CLUSTERED is specified or the constraint otherwise creates a clustered index, and a partition_scheme is specified that differs from the partition_scheme or filegroup of the table definition, or vice-versa, only the constraint definition will be honored, and the other will be ignored.
121124

122-
## Remarks
125+
## Remarks
126+
123127
Creating a temporary table as node or edge table is not supported.
124128

125129
Creating a node or edge table as a temporal table is not supported.
@@ -159,6 +163,16 @@ The following examples show how to create `EDGE` tables
159163
CREATE TABLE likes AS EDGE;
160164
```
161165

166+
The next example models a rule that **only** people can be friends with other people, which means this edge does not allow reference to any node other than Person.
167+
168+
```
169+
/* Create friend edge table with CONSTRAINT, restricts for nodes and it direction */
170+
CREATE TABLE dbo.FriendOf(
171+
CONSTRAINT cnt_Person_FriendOf_Person
172+
CONNECTION (dbo.Person TO dbo.Person)
173+
)AS EDGE;
174+
```
175+
162176

163177
## See Also
164178
[ALTER TABLE table_constraint](../../t-sql/statements/alter-table-table-constraint-transact-sql.md)

0 commit comments

Comments
 (0)