mirror of
https://github.com/groue/GRDB.swift
synced 2026-11-24 04:07:47 +00:00
Association documentation: avoid painful repetition
This commit is contained in:
1 parent
addfa45d3a
commit
06f0961b13
1 file changed
+3
-15
@@ -362,13 +362,9 @@ See [The Structure of a Joined Request] for more information.
|
||||
|
||||
## Convention for the BelongsTo Association
|
||||
|
||||
**[BelongsTo] associations should be supported by an SQLite foreign key.**
|
||||
|
||||
Foreign keys are the recommended way to declare relationships between database tables. Not only will SQLite guarantee the integrity of your data, but GRDB will be able to use those foreign keys to automatically configure your associations.
|
||||
|
||||

|
||||
|
||||
The matching [migration] could look like:
|
||||
Here is the recommended [migration] for the **[BelongsTo]** association:
|
||||
|
||||
```swift
|
||||
migrator.registerMigration("Books and Authors") { db in
|
||||
@@ -419,13 +415,9 @@ See [Foreign Keys] for more information.
|
||||
|
||||
## Convention for the HasOne Association
|
||||
|
||||
**[HasOne] associations should be supported by an SQLite foreign key.**
|
||||
|
||||
Foreign keys are the recommended way to declare relationships between database tables. Not only will SQLite guarantee the integrity of your data, but GRDB will be able to use those foreign keys to automatically configure your associations.
|
||||
|
||||

|
||||
|
||||
The matching [migration] could look like:
|
||||
Here is the recommended [migration] for the **[HasOne]** association:
|
||||
|
||||
```swift
|
||||
migrator.registerMigration("Countries") { db in
|
||||
@@ -477,13 +469,9 @@ See [Foreign Keys] for more information.
|
||||
|
||||
## Convention for the HasMany Association
|
||||
|
||||
**[HasMany] associations should be supported by an SQLite foreign key.**
|
||||
|
||||
Foreign keys are the recommended way to declare relationships between database tables. Not only will SQLite guarantee the integrity of your data, but GRDB will be able to use those foreign keys to automatically configure your associations.
|
||||
|
||||

|
||||
|
||||
The matching [migration] could look like:
|
||||
Here is the recommended [migration] for the **[HasMany]** association:
|
||||
|
||||
```swift
|
||||
migrator.registerMigration("Books and Authors") { db in
|
||||
|
||||
Reference in new issue
Block a user