Edgedb Exclusive Constraint

[tr] Türkçe Oku

2023-04-12

The term exclusive constraint in EdgeDB refers to a type of constraint that ensures a specific property is unique or within a certain range.

For example, you can create an exclusive constraint in a User object that ensures the email property is unique, thus ensuring that each user is only saved once.

In the following example, we are defining an exclusive constraint that ensures uniqueness in the email property:

type User {
  required property id -> uuid;
  required property name -> str;
  exclusive constraint unique_email on (.email);
  property email -> str;
}

In this example, we defined a “unique_email” exclusive constraint for the User object, which ensures uniqueness in the email property. The on keyword is used to specify which property should be unique. In this case, we specified the email property using .email.

Constraints can include multiple properties and enforce uniqueness on combinations of these properties. For example, if you want to enforce uniqueness on the combination of email and phone properties for a User object, you can define a unique constraint as shown in the following example:

type User {
  required property id -> uuid;
  required property name -> str;
  exclusive constraint unique_email_phone on (.email, .phone);
  property email -> str;
  property phone -> str;
}

In this example, we defined a “unique_email_phone” exclusive constraint for the User object. This constraint ensures uniqueness in the combination of the email and phone properties.



More posts like this

Edgedb Computed Links

2023-04-12 | #edgedb #edgedb-links

Computed Links is a structure used to define relationships between two objects. These links are created by using a defined query or function to calculate the relationship between associated objects. Computed Links is a structure used to define relationships between two objects. These connections are created by using a defined query or function to calculate the relationship between the associated objects. This structure is very useful for ensuring consistency of the data held in the database.

Continue reading 


Edgedb Constraints

2023-04-11 | #edgedb #edgedb-constraints

Edgedb is a relational database management system (RDBMS) that provides various constraint mechanisms to securely store and manage your data while preserving the integrity of the data recorded in your database. Constraints are a set of rules used to maintain the integrity of the data stored in your database. There are five different types of constraint: 1. Primary Key Constraints: Primary key constraints ensure that each row is uniquely identified. This constraint specifies that there can only be one primary key column in a table, and each value in this column can only be used once.

Continue reading 


Edgedb Object Type

2023-04-11 | #edgedb #edgedb-types

EdgeDB can be defined as an object-oriented database management system. Data is defined as object types, and these types are defined with attributes and methods. In this article, a detailed explanation will be provided about the object type in EdgeDB. The object type is one of the object types in EdgeDB. An EdgeDB object can be thought of as a class, and these objects have attributes and methods. The object type defines the characteristics of an object type by keeping these attributes and methods together.

Continue reading 