| | | |
Offset 16, 15 lines modified | Offset 16, 15 lines modified |
16 | 1.3·Database·schema·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·. | 16 | 1.3·Database·schema·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·. |
17 | 1.4·The·gnatcoll_db2ada·tool·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·. | 17 | 1.4·The·gnatcoll_db2ada·tool·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·. |
18 | 1.4.1 | 18 | 1.4.1 |
19 | Default·output·of·gnatcoll_db2ada·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·. | 19 | Default·output·of·gnatcoll_db2ada·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·. |
20 | 1.4.2 | 20 | 1.4.2 |
21 | database·introspection·in·Ada·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·. | 21 | database·introspection·in·Ada·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·. |
22 | 1.4.3 | 22 | 1.4.3 |
23 | Back·to·the·library·example...·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·. | 23 | Back·to·the·library·example.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·. |
24 | 1.5·Connecting·to·the·database·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·. | 24 | 1.5·Connecting·to·the·database·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·. |
25 | 1.6·Loading·initial·data·in·the·database·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·. | 25 | 1.6·Loading·initial·data·in·the·database·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·. |
26 | 1.7·Writing·queries·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·. | 26 | 1.7·Writing·queries·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·. |
27 | 1.8·Executing·queries·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·. | 27 | 1.8·Executing·queries·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·. |
28 | 1.9·Prepared·queries·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·. | 28 | 1.9·Prepared·queries·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·. |
29 | 1.10·Getting·results·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·. | 29 | 1.10·Getting·results·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·. |
30 | 1.11·Creating·your·own·SQL·types·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·. | 30 | 1.11·Creating·your·own·SQL·types·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·.·. |
Offset 102, 25 lines modified | Offset 102, 25 lines modified |
102 | two·systems.·For·instance,·development·could·be·done·using·a·local·sqlite·DBMS,·and·then·deployed·(after | 102 | two·systems.·For·instance,·development·could·be·done·using·a·local·sqlite·DBMS,·and·then·deployed·(after |
103 | testing,·of·course!)·on·a·PostgreSQL·system. | 103 | testing,·of·course!)·on·a·PostgreSQL·system. |
104 | The·code·in·GNATColl·is·such·that·adding·support·for·a·new·DBMS·should·be·relatively·easy. | 104 | The·code·in·GNATColl·is·such·that·adding·support·for·a·new·DBMS·should·be·relatively·easy. |
105 | •·A·place·where·an·application·stores·its·data.·The·term·database·in·this·document·refers·to·this·meaning.·In·a | 105 | •·A·place·where·an·application·stores·its·data.·The·term·database·in·this·document·refers·to·this·meaning.·In·a |
106 | relational·database,·this·place·is·organized·into·tables,·each·of·which·contains·a·number·of·fields.·A·row·in·a | 106 | relational·database,·this·place·is·organized·into·tables,·each·of·which·contains·a·number·of·fields.·A·row·in·a |
107 | table·represents·one·object.·The·set·of·tables·and·their·fields·is·called·the·schema·of·the·database. | 107 | table·represents·one·object.·The·set·of·tables·and·their·fields·is·called·the·schema·of·the·database. |
108 | Traditionally,·writing·the·SQL·queries·is·done·inline:·special·markers·are·inserted·into·your·code·to·delimit·sections | 108 | Traditionally,·writing·the·SQL·queries·is·done·inline:·special·markers·are·inserted·into·your·code·to·delimit·sections |
109 | that·contain·SQL·code·(as·opposed·to·Ada·code),·and·these·are·then·preprocessed·to·generate·actual·code.·This·isn't | 109 | that·contain·SQL·code·(as·opposed·to·Ada·code),·and·these·are·then·preprocessed·to·generate·actual·code.·This·isn’t |
110 | the·approach·chosen·in·GNATColl:·there·are·several·drawbacks,·in·particular·your·code·is·no·longer·Ada·and·various | 110 | the·approach·chosen·in·GNATColl:·there·are·several·drawbacks,·in·particular·your·code·is·no·longer·Ada·and·various |
111 | tools·will·choke·on·it. | 111 | tools·will·choke·on·it. |
112 | The·other·usual·approach·is·to·write·the·queries·as·strings,·which·are·passed,·via·a·DBMS-specific·API,·to·the·DBMS | 112 | The·other·usual·approach·is·to·write·the·queries·as·strings,·which·are·passed,·via·a·DBMS-specific·API,·to·the·DBMS |
113 | server.·This·approach·is·very·fragile: | 113 | server.·This·approach·is·very·fragile: |
114 | •·The·string·might·not·contain·well-formed·SQL.·This·will·unfortunately·only·be·detected·at·run·time·when·the | 114 | •·The·string·might·not·contain·well-formed·SQL.·This·will·unfortunately·only·be·detected·at·run·time·when·the |
115 | DBMS·complains. | 115 | DBMS·complains. |
116 | •·This·is·not·type·safe.·You·might·be·comparing·a·text·field·with·an·integer,·for·instance.·In·some·cases,·the·DBMS | 116 | •·This·is·not·type·safe.·You·might·be·comparing·a·text·field·with·an·integer,·for·instance.·In·some·cases,·the·DBMS |
117 | will·accept·that·(sqlite·for·instance),·but·in·some·other·cases·it·won't·(PostgreSQL).·The·result·might·then·either | 117 | will·accept·that·(sqlite·for·instance),·but·in·some·other·cases·it·won’t·(PostgreSQL).·The·result·might·then·either |
118 | raise·an·error,·or·return·an·empty·list. | 118 | raise·an·error,·or·return·an·empty·list. |
119 | •·There·is·a·risk·of·SQL·injection.·Assuming·the·string·is·constructed·dynamically·(using·Ada's·&·operator),·it | 119 | •·There·is·a·risk·of·SQL·injection.·Assuming·the·string·is·constructed·dynamically·(using·Ada’s·&·operator),·it |
120 | might·be·easy·for·a·user·to·pass·a·string·that·breaks·the·query,·and·even·destroys·things·in·the·database. | 120 | might·be·easy·for·a·user·to·pass·a·string·that·breaks·the·query,·and·even·destroys·things·in·the·database. |
121 | •·As·discussed·previously,·the·SQL·code·might·not·be·portable·across·DBMS.·For·instance,·creating·an·automatically·increment·integer·primary·key·in·a·table·is·DBMS·specific. | 121 | •·As·discussed·previously,·the·SQL·code·might·not·be·portable·across·DBMS.·For·instance,·creating·an·automatically·increment·integer·primary·key·in·a·table·is·DBMS·specific. |
122 | •·The·string·is·fragile·if·the·database·schema·changes.·Finding·whether·a·schema·change·impacts·any·of·the | 122 | •·The·string·is·fragile·if·the·database·schema·changes.·Finding·whether·a·schema·change·impacts·any·of·the |
123 | queries·requires·looking·at·all·the·strings·in·your·application. | 123 | queries·requires·looking·at·all·the·strings·in·your·application. |
124 | •·performance·might·be·an·issue.·Whenever·you·execute·a·query,·the·DBMS·will·analyze·it,·decide·how·to·execute | 124 | •·performance·might·be·an·issue.·Whenever·you·execute·a·query,·the·DBMS·will·analyze·it,·decide·how·to·execute |
125 | it·(for·instance,·whether·it·should·traverse·all·the·rows·of·a·table,·or·whether·it·can·do·a·faster·lookup),·and·then | 125 | it·(for·instance,·whether·it·should·traverse·all·the·rows·of·a·table,·or·whether·it·can·do·a·faster·lookup),·and·then |
| |
Offset 178, 124 lines modified | Offset 178, 125 lines modified |
178 | Chapter·1.·SQL:·Database·interface | 178 | Chapter·1.·SQL:·Database·interface |
| |
179 | \xcGNATCOLL·Documentation·-·Database·packages,·Release·0.0 | 179 | \xcGNATCOLL·Documentation·-·Database·packages,·Release·0.0 |
| |
180 | 1.2·Database·example | 180 | 1.2·Database·example |
181 | This·section·describes·an·example·that·will·be·extended·throughout·this·chapter.·We·will·build·an·application·that | 181 | This·section·describes·an·example·that·will·be·extended·throughout·this·chapter.·We·will·build·an·application·that |
182 | represents·a·library.·Such·a·library·contains·various·media·(books·and·DVDs·for·instance),·and·customers.·A·customer | 182 | represents·a·library.·Such·a·library·contains·various·media·(books·and·DVDs·for·instance),·and·customers.·A·customer |
183 | can·borrow·multiple·media·at·the·same·time,·but·a·media·is·either·at·a·customer's,·or·still·in·the·library. | 183 | can·borrow·multiple·media·at·the·same·time,·but·a·media·is·either·at·a·customer’s,·or·still·in·the·library. |
184 | The·GNATColl·distribution·includes·an·example·directory·which·contains·all·the·code·and·data·for·this·example. | 184 | The·GNATColl·distribution·includes·an·example·directory·which·contains·all·the·code·and·data·for·this·example. |
| |
185 | 1.3·Database·schema | 185 | 1.3·Database·schema |
186 | As·was·mentioned·earlier·(Database·Abstraction·Layers),·GNATColl·relies·on·automatic·code·generation·to·provide·a | 186 | As·was·mentioned·earlier·(Database·Abstraction·Layers),·GNATColl·relies·on·automatic·code·generation·to·provide·a |
187 | type·safe·interface·to·your·database.·This·code·is·generated·by·an·external·tool·called·gnatcoll_db2ada.·In·some·cases, | 187 | type·safe·interface·to·your·database.·This·code·is·generated·by·an·external·tool·called·gnatcoll_db2ada.·In·some·cases, |
188 | this·tool·requires·an·installation·of·python·(www.python.org)·on·your·machine,·since·part·of·the·code·is·written·in·that | 188 | this·tool·requires·an·installation·of·python·(www.python.org)·on·your·machine,·since·part·of·the·code·is·written·in·that |
189 | language. | 189 | language. |
190 | This·tool·is·able·to·output·various·kind·of·information,·and·will·be·fully·described·later·(The·gnatcoll_db2ada·tool). | 190 | This·tool·is·able·to·output·various·kind·of·information,·and·will·be·fully·described·later·(The·gnatcoll_db2ada·tool). |
191 | However,·the·input·is·always·the·same:·this·is·the·schema·of·your·database,·that·is·the·list·of·tables·and·fields·that·make | 191 | However,·the·input·is·always·the·same:·this·is·the·schema·of·your·database,·that·is·the·list·of·tables·and·fields·that·make |
192 | up·your·database.·There·exist·two·ways·to·provide·that·information: | 192 | up·your·database.·There·exist·two·ways·to·provide·that·information: |
193 | •·From·a·running·database | 193 | •·From·a·running·database |
194 | If·you·pass·the·DBMS·vendor·(postgresql,·sqlite,...)·and·the·connection·parameters·to·gnatcoll_db2ada,·it·is | 194 | If·you·pass·the·DBMS·vendor·(postgresql,·sqlite,.·.·.·)·and·the·connection·parameters·to·gnatcoll_db2ada,·it·is |
195 | able·to·query·the·schema·on·its·own.·However,·this·should·not·be·the·preferred·method:·this·is·similar·to·reverse | 195 | able·to·query·the·schema·on·its·own.·However,·this·should·not·be·the·preferred·method:·this·is·similar·to·reverse |
196 | engineering·assembly·code·into·the·original·high-level·code,·and·some·semantic·information·will·be·missing.·For | 196 | engineering·assembly·code·into·the·original·high-level·code,·and·some·semantic·information·will·be·missing.·For |
197 | instance,·in·SQL·we·have·to·create·tables·just·to·represent·the·many-to-many·relationships.·These·extra·tables | 197 | instance,·in·SQL·we·have·to·create·tables·just·to·represent·the·many-to-many·relationships.·These·extra·tables |
198 | are·part·of·the·implementation·of·the·schema,·but·are·just·noise·when·it·comes·to·the·semantics·of·the·schema. | 198 | are·part·of·the·implementation·of·the·schema,·but·are·just·noise·when·it·comes·to·the·semantics·of·the·schema. |
199 | For·this·reason,·it·is·better·to·use·the·second·solution·below: | 199 | For·this·reason,·it·is·better·to·use·the·second·solution·below: |
200 | •·From·a·textual·description | 200 | •·From·a·textual·description |
201 | Using·the·-dbmodel·switch·to·gnatcoll_db2ada,·you·can·pass·a·file·that·describes·the·schema.·We·do·not·use | 201 | Using·the·-dbmodel·switch·to·gnatcoll_db2ada,·you·can·pass·a·file·that·describes·the·schema.·We·do·not·use |
202 | SQL·as·the·syntax·in·this,·because·as·explained·above·this·is·too·low-level.·This·text·file·also·provides·additional | 202 | SQL·as·the·syntax·in·this,·because·as·explained·above·this·is·too·low-level.·This·text·file·also·provides·additional |
203 | capabilities·that·do·not·exist·when·reverse-engineering·an·existing·database,·for·instance·the·ability·to·use·name | 203 | capabilities·that·do·not·exist·when·reverse-engineering·an·existing·database,·for·instance·the·ability·to·use·name |
204 | to·represent·reverse·relationships·for·foreign·keys·(see·below·and·the·ORM). | 204 | to·represent·reverse·relationships·for·foreign·keys·(see·below·and·the·ORM). |
205 | The·most·convenient·editor·for·this·file·is·Emacs,·using·the·org-mode·which·provides·convenient·key·shortcuts | 205 | The·most·convenient·editor·for·this·file·is·Emacs,·using·the·org-mode·which·provides·convenient·key·shortcuts |
206 | for·editing·the·contents·of·ASCII·tables.·But·any·text·editor·will·do,·and·you·do·not·need·to·align·the·columns·in | 206 | for·editing·the·contents·of·ASCII·tables.·But·any·text·editor·will·do,·and·you·do·not·need·to·align·the·columns·in |
207 | this·file. | 207 | this·file. |
208 | All·lines·starting·with·a·hash·sign·('#')·will·be·ignored. | 208 | All·lines·starting·with·a·hash·sign·(‘#’)·will·be·ignored. |
209 | This·file·is·a·collection·of·ASCII·tables,·each·of·which·relates·to·one·table·or·one·SQL·view·in·your·database. | 209 | This·file·is·a·collection·of·ASCII·tables,·each·of·which·relates·to·one·table·or·one·SQL·view·in·your·database. |
210 | The·paragraphs·start·with·a·line·containing: | 210 | The·paragraphs·start·with·a·line·containing: |
211 | table·::= | 211 | table·::= |
212 | '|'·('ABSTRACT')?·('TABLE'|'VIEW')·['('·supertable·')'] | 212 | '|'·('ABSTRACT')?·('TABLE'|'VIEW')·['('·supertable·')'] |
213 | '|'·<name>·'|'·<name_row> | 213 | '|'·<name>·'|'·<name_row> |
214 | "name"·is·the·name·of·the·table.·The·third·pipe·and·third·column·are·optional,·and·should·be·used·to·specify·the | 214 | “name”·is·the·name·of·the·table.·The·third·pipe·and·third·column·are·optional,·and·should·be·used·to·specify·the |
215 | name·for·the·element·represented·by·a·single·row.·For·instance,·if·the·table·is·called·"books",·the·third·column | 215 | name·for·the·element·represented·by·a·single·row.·For·instance,·if·the·table·is·called·“books”,·the·third·column |
216 | could·contain·"book".·This·is·used·when·generating·objects·for·use·with·GNATCOLL.SQL.ORM. | 216 | could·contain·“book”.·This·is·used·when·generating·objects·for·use·with·GNATCOLL.SQL.ORM. |
217 | If·the·first·line·starts·with·the·keyword·ABSTRACT,·then·no·instance·of·that·table·actually·exists·in·the·database. | 217 | If·the·first·line·starts·with·the·keyword·ABSTRACT,·then·no·instance·of·that·table·actually·exists·in·the·database. |
218 | This·is·used·in·the·context·of·table·inheritance,·so·define·shared·fields·only·once·among·multiple·tables. | 218 | This·is·used·in·the·context·of·table·inheritance,·so·define·shared·fields·only·once·among·multiple·tables. |
219 | The·keyword·TABLE·can·be·followed·by·the·name·of·a·table·from·which·it·inherits·the·fields.·Currently,·that | 219 | The·keyword·TABLE·can·be·followed·by·the·name·of·a·table·from·which·it·inherits·the·fields.·Currently,·that |
220 | supertable·must·be·abstract,·and·the·fields·declared·in·that·table·are·simply·duplicated·in·the·new·table. | 220 | supertable·must·be·abstract,·and·the·fields·declared·in·that·table·are·simply·duplicated·in·the·new·table. |
| |
221 | 1.2.·Database·example | 221 | 1.2.·Database·example |
| |
222 | 3 | 222 | 3 |
| |
223 | \xcGNATCOLL·Documentation·-·Database·packages,·Release·0.0 | 223 | \xcGNATCOLL·Documentation·-·Database·packages,·Release·0.0 |
| |
224 | Following·the·declaration·of·the·table,·the·file·then·describe·their·fields,·each·on·a·separate·line.·Each·of·these | 224 | Following·the·declaration·of·the·table,·the·file·then·describe·their·fields,·each·on·a·separate·line.·Each·of·these |
225 | lines·must·start·with·a·pipe·character·("|"),·and·contain·a·number·of·pipe-separated·fields.·The·order·of·the·fields | 225 | lines·must·start·with·a·pipe·character·(“|”),·and·contain·a·number·of·pipe-separated·fields.·The·order·of·the·fields |
226 | is·always·given·by·the·following·grammar: | 226 | is·always·given·by·the·following·grammar: |
227 | fields·::= | 227 | fields·::= |
228 | '|'·<name>·'|'·<type> | 228 | '|'·<name>·'|'·<type> |
229 | '|'·('PK'|''|'NULL'|'NOT·NULL'|'INDEX'|'UNIQUE'|'NOCASE') | 229 | '|'·('PK'|''|'NULL'|'NOT·NULL'|'INDEX'|'UNIQUE'|'NOCASE') |
230 | '|'·[default]·'|'·[doc]·'|' | 230 | '|'·[default]·'|'·[doc]·'|' |
231 | The·type·of·the·field·is·the·SQL·type·("INTEGER",·"TEXT",·"TIMESTAMP",·"DATE",·"DOUBLE·PRECISION",·"MONEY",·"BOOLEAN",·"TIME",·"CHARACTER(1)").·Any·maximal·length·can·be·specified·for | 231 | The·type·of·the·field·is·the·SQL·type·(“INTEGER”,·“TEXT”,·“TIMESTAMP”,·“DATE”,·“DOUBLE·PRECISION”,·“MONEY”,·“BOOLEAN”,·“TIME”,·“CHARACTER(1)”).·Any·maximal·length·can·be·specified·for |
232 | strings,·not·just·1·as·in·this·example.·The·tool·will·automatically·convert·these·to·Ada·when·generating·Ada | 232 | strings,·not·just·1·as·in·this·example.·The·tool·will·automatically·convert·these·to·Ada·when·generating·Ada·code. |
233 | code.·A·special·type·("AUTOINCREMENT")·is·an·integer·that·is·automatically·incremented·according·to·available·ids·in·the·table.·The·exact·type·used·will·depend·on·the·specific·DBMS. | 233 | A·special·type·(“AUTOINCREMENT”)·is·an·integer·that·is·automatically·incremented·according·to·available·ids |
| 234 | in·the·table.·The·exact·type·used·will·depend·on·the·specific·DBMS. |
234 | The·property·'NOCASE'·indicates·that·comparison·should·be·case·insensitive·for·this·field. | 235 | The·property·‘NOCASE’·indicates·that·comparison·should·be·case·insensitive·for·this·field. |
235 | If·the·field·is·a·foreign·key·(that·is·a·value·that·must·correspond·to·a·row·in·another·table),·you·can·use·the·special | 236 | If·the·field·is·a·foreign·key·(that·is·a·value·that·must·correspond·to·a·row·in·another·table),·you·can·use·the·special |
236 | syntax·for·its·type: | 237 | syntax·for·its·type: |
237 | fk_type·::=·'FK'·<table_name>·[·'('·<reverse_name>·')'·] | 238 | fk_type·::=·'FK'·<table_name>·[·'('·<reverse_name>·')'·] |
238 | As·you·can·see,·the·type·of·the·field·is·not·specified·explicitly,·but·will·always·be·that·of·the·foreign·table's·primary | 239 | As·you·can·see,·the·type·of·the·field·is·not·specified·explicitly,·but·will·always·be·that·of·the·foreign·table’s·primary |
239 | key.·With·this·syntax,·the·foreign·table·must·have·a·single·field·for·its·primary·key.·GNATColl·does·not·force·a | 240 | key.·With·this·syntax,·the·foreign·table·must·have·a·single·field·for·its·primary·key.·GNATColl·does·not·force·a |
240 | specific·order·for·the·declaration·of·tables:·if·is·valid·to·have·a·foreign·key·to·a·table·that·hasn't·been·declared·yet. | 241 | specific·order·for·the·declaration·of·tables:·if·is·valid·to·have·a·foreign·key·to·a·table·that·hasn’t·been·declared·yet. |
241 | There·is·however·a·restriction·if·you·use·the·model·to·create·a·sqlite·database·(through·the·-createdb·switch·of | 242 | There·is·however·a·restriction·if·you·use·the·model·to·create·a·sqlite·database·(through·the·-createdb·switch·of |
242 | gnatcoll_db2ada):·in·this·case,·a·reference·to·a·table·that·hasn't·been·defined·yet·may·not·be·not·through·a·field | 243 | gnatcoll_db2ada):·in·this·case,·a·reference·to·a·table·that·hasn’t·been·defined·yet·may·not·be·not·through·a·field |
243 | marked·as·NOT·NULL.·This·is·a·limitation·of·the·sqlite·backend·itself.·The·solution·in·this·case·is·to·reorder·the | 244 | marked·as·NOT·NULL.·This·is·a·limitation·of·the·sqlite·backend·itself.·The·solution·in·this·case·is·to·reorder·the |
244 | declaration·of·tables,·or·drop·the·NOT·NULL·constraint. | 245 | declaration·of·tables,·or·drop·the·NOT·NULL·constraint. |
245 | Another·restriction·is·that·a·foreign·key·that·is·also·a·primary·key·must·reference·a·table·that·has·already·been | 246 | Another·restriction·is·that·a·foreign·key·that·is·also·a·primary·key·must·reference·a·table·that·has·already·been |
246 | defined.·You·need·to·reorder·the·declaration·of·your·tables·to·ensure·this·is·the·case. | 247 | defined.·You·need·to·reorder·the·declaration·of·your·tables·to·ensure·this·is·the·case. |
247 | "reverse_name"·is·the·optional·name·that·will·be·generated·in·the·Ada·code·for·the·reverse·relationship,·in·the | 248 | “reverse_name”·is·the·optional·name·that·will·be·generated·in·the·Ada·code·for·the·reverse·relationship,·in·the |
248 | context·of·GNATCOLL.SQL.ORM.·If·the·"reverse_name"·is·empty·(the·parenthesis·are·shown),·no·reverse·relationship·is·generated.·If·the·parenthesis·and·the·reverse_name·are·both·omitted,·a·default·name·is·generated | 249 | context·of·GNATCOLL.SQL.ORM.·If·the·“reverse_name”·is·empty·(the·parenthesis·are·shown),·no·reverse·relationship·is·generated.·If·the·parenthesis·and·the·reverse_name·are·both·omitted,·a·default·name·is·generated |
249 | based·on·the·name·of·the·field. | 250 | based·on·the·name·of·the·field. |
250 | The·third·column·in·the·fields·definition·indicates·the·constraints·of·the·type.·Multiple·keywords·can·be·used·if | 251 | The·third·column·in·the·fields·definition·indicates·the·constraints·of·the·type.·Multiple·keywords·can·be·used·if |
251 | they·are·separated·by·commas.·Thus,·"NOT·NULL,·INDEX"·indicates·a·column·that·must·be·set·by·the·user, | 252 | they·are·separated·by·commas.·Thus,·“NOT·NULL,·INDEX”·indicates·a·column·that·must·be·set·by·the·user, |
252 | and·for·which·an·index·is·created·to·speed·up·look·ups. | 253 | and·for·which·an·index·is·created·to·speed·up·look·ups. |
253 | –·A·primary·key·("PK") | 254 | –·A·primary·key·(“PK”) |
254 | –·The·value·must·be·defined·("NOT·NULL") | 255 | –·The·value·must·be·defined·(“NOT·NULL”) |
Max diff block lines reached; 69023/83038 bytes (83.12%) of diff not shown.
|