DATA_STRUCTURE.md 16.8 KB
Newer Older
1
## Description
2

3 4
This document describes the architecture of the Ninja Forms database layer.

5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
## Current Structure (1.1)

This section contains the current structure of the Ninja Forms data layer and is updated each time that structure changes. For legacy data, please see the individual version notes.

### Forms

_**nf3_forms**_ (Table of individual Forms)
* id (The unique ID of the Form)
  * int(11)
  * NOT NULL
  * AUTO_INCREMENT
  * Primary Key
* title (The displayable title of the Form)
  * longtext
  * COLLATE DATABASE_DEFAULT
20 21 22
* key (The administrative key of the Form)
  * longtext
  * COLLATE DATABASE_DEFAULT
23 24 25 26 27 28 29
* created_at (The date/time the Form was created)
  * timestamp
  * NOT NULL
  * DEFAULT CURRENT_TIMESTAMP
  * ON UPDATE CURRENT_TIMESTAMP
* updated_at (The date/time the Form was last updated)
  * datetime
30 31 32 33
* views (The number of times the Form has been viewed)
  * int(11)
* subs (The Form's number of lifetime Submissions)
  * int(11)
34 35 36
* form_title (The displayable title of the Form)
  * longtext
  * COLLATE utf8mb4_general_ci (fallback to utf8_general_ci)
Eric Windham's avatar
Eric Windham committed
37
* default_label_pos (The default label position of fields on the Form)
38 39 40 41 42 43 44 45 46 47
  * varchar(15)
* show_title (Whether or not to show the Form title)
  * bit(1)
* clear_complete (Whether or not to clear the Form after submission)
  * bit(1)
* hide_complete (Whether or not to hide the Form after submission)
  * bit(1)
* logged_in (Whether or not the user must be logged in to view the Form)
  * bit(1)
* seq_num (The number of the next submission to the Form)
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
  * int(11)


_**nf3_form_meta**_ (Table of Settings assoicated with each Form)
* id (The unique ID of the Setting)
  * int(11)
  * NOT NULL
  * AUTO_INCREMENT
  * Primary Key
* parent_id (The Form ID this Setting is associated with)
  * int(11)
  * NOT NULL
  * Foreign Key ON *nf3_forms* id
* key (The administrative key of the Setting)
  * longtext
  * COLLATE DATABASE_DEFAULT
  * NOT NULL
* value (The value of the Setting)
  * longtext
  * COLLATE DATABASE_DEFAULT
68 69 70 71 72 73
* meta_key (The administrative key of the Setting)
  * longtext
  * COLLATE utf8mb4_general_ci (fallback to utf8_general_ci)
* meta_value (The value of the Setting)
  * longtext
  * COLLATE utf8mb4_general_ci (fallback to utf8_general_ci)
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102

### Fields

_**nf3_fields**_ (Table of individual Fields)
* id (The unique ID of the Field)
  * int(11)
  * NOT NULL
  * AUTO_INCREMENT
  * Primary Key
* label (The displayable label of the Field)
  * longtext
  * COLLATE DATABASE_DEFAULT
* key (The administrative key of the Field)
  * longtext
  * COLLATE DATABASE_DEFAULT
* type (The type of Field this record represents)
  * longtext
  * COLLATE DATABASE_DEFAULT
* parent_id (The Form ID this Field is associated with)
  * int(11)
  * NOT NULL
  * Foreign Key ON *nf3_forms* id
* created_at (The date/time the Field was created)
  * timestamp
  * NOT NULL
  * DEFAULT CURRENT_TIMESTAMP
  * ON UPDATE CURRENT_TIMESTAMP
* updated_at (The date/time the Field was last updated)
  * datetime
103

104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293

_**nf3_field_meta**_ (Table of Settings associated with each Field)
* id (The unique ID of the Setting)
  * int(11)
  * NOT NULL
  * AUTO_INCREMENT
  * Primary Key
* parent_id (The Field ID this Setting is associated with)
  * int(11)
  * NOT NULL
  * Foreign Key ON *nf3_fields* id
* key (The administrative key of the Setting)
  * longtext
  * COLLATE DATABASE_DEFAULT
  * NOT NULL
* value (The value of the Setting)
  * longtext
  * COLLATE DATABASE_DEFAULT
  
### Actions

_**nf3_actions**_ (Table of individual Actions)
* id (The unique ID of the Action)
  * int(11)
  * NOT NULL
  * AUTO_INCREMENT
  * Primrary Key
* title (The displayable title of the Action)
  * longtext
  * COLLATE DATABASE_DEFAULT
* key (The administrative key of the Action)
  * longtext
  * COLLATE DATABASE_DEFAULT
* type (The type of Action this record represents)
  * longtext
  * COLLATE DATABASE_DEFAULT
* active (Whether or not the Action is active)
  * tinyint(1)
  * DEFAULT 1
* parent_id (The Form ID this Action is associated with)
  * int(11)
  * NOT NULL
  * Foreign Key ON *nf3_forms* id
* created_at (The date/time the Action was created)
  * timestamp
  * NOT NULL
  * DEFAULT CURRENT_TIMESTAMP
  * ON UPDATE CURRENT_TIMESTAMP
* updated_at (The date/time the Action was last updated)
  * datetime


_**nf3_action_meta**_ (Table of Settings associated with each Action)
* id (The unique ID of the Setting)
  * int(11)
  * NOT NULL
  * AUTO_INCREMENT
  * Primary KEY
* parent_id (The Action ID this Setting is associated with)
  * int(11)
  * NOT_NULL
  * Foreign Key ON *nf3_actions* id
* key (The administrative key of the Setting)
  * longtext
  * COLLATE DATABASE_DEFAULT
  * NOT NULL
* value (The value of the Setting)
  * longtext
  * COLLATE DATABASE_DEFAULT

### Objects

_**nf3_objects**_ (Table of non-structured Objects)
* id (The unique ID of the Object)
  * int(11)
  * NOT NULL
  * AUTO_INCREMENT
  * Primrary Key
* type (The type of Object this record represents)
  * longtext
  * COLLATE DATABASE_DEFAULT
* title (The displayable title of the Object)
  * longtext
  * COLLATE DATABASE_DEFAULT
* created_at (The date/time the Object was created)
  * timestamp
  * NOT NULL
  * DEFAULT CURRENT_TIMESTAMP
  * ON UPDATE CURRENT_TIMESTAMP
* updated_at (The date/time the Object was last updated)
  * datetime


_**nf3_object_meta**_ (Table of Settings associated with each Object)
* id (The unique ID of the Setting)
  * int(11)
  * NOT NULL
  * AUTO_INCREMENT
  * Primary KEY
* parent_id (The Object ID this Setting is associated with)
  * int(11)
  * NOT_NULL
  * Foreign Key ON *nf3_objects* id
* key (The administrative key of the Setting)
  * longtext
  * COLLATE DATABASE_DEFAULT
  * NOT NULL
* value (The value of the Setting)
  * longtext
  * COLLATE DATABASE_DEFAULT


_**nf3_relationships**_ (Table of Relationships between Objects)
* id (The unique ID of the Relationship)
  * int(11)
  * NOT NULL
  * AUTO_INCREMENT
  * Primary KEY
* child_id (The child Object ID this record is associated with)
  * int(11)
  * NOT_NULL
  * Foreign Key ON *nf3_objects* id
* child_type (The type of Object represented by child_id)
  * longtext
  * COLLATE DATABASE_DEFAULT
  * NOT NULL
* parent_id (The parent Object ID this record is associated with)
  * int(11)
  * NOT_NULL
  * Foreign Key ON *nf3_objects* id
* parent_type (The type of Object represented by parent_id)
  * longtext
  * COLLATE DATABASE_DEFAULT
  * NOT NULL
* created_at (The date/time the Relationship was created)
  * timestamp
  * NOT NULL
  * DEFAULT CURRENT_TIMESTAMP
  * ON UPDATE CURRENT_TIMESTAMP
* updated_at (The date/time the Relationship was last updated)
  * datetime


_**options**_ (The default WordPress options table)
* option_name = 'nf_form_%' WHERE % = *nf3_forms* id
* option_value = Serialized JSON Object (The Ninja Forms Cache)

### Submissions

_**posts**_ (The default WordPress posts table)
* id (The unique ID of the Post)
  * bigint(20)
  * NOT NULL
  * AUTO_INCREMENT
  * Primary Key
* post_type = 'nf_sub'


_**postmeta**_ (The default WordPress postmeta table)
* meta_id (The unique ID of the Metadata)
  * bigint(20)
  * NOT NULL
  * AUTO_INCREMENT
  * Primary Key
* post_id (The Post ID this Metadata is associated with)
  * bigint(20)
  * NOT NULL
  * DEFAULT 0
  * Foreign Key ON *posts* id
* meta_key (The identifiable key by which this record is referenced)
  * varchar(255)
  * COLLATE DATABASE_DEFAULT
* meta_value (The value of this record)
  * longtext
  * COLLATE DATABASE_DEFAULT

### Upgrades

_**nf3_upgrades**_ (Table of Forms as they exist in the current structure and the stage of upgrade currently applied to each Form)
* id (The unique ID of the Form)
  * int(11)
  * NOT NULL
  * Primary Key
* cache (The Ninja Forms cache as it was retrieved from the *options* table)
  * longtext
  * COLLATE utf8mb4_general_ci (fallback to utf8_general_ci)
* stage (The current upgrade stage of the Form)
  * int(11)
  * NOT NULL
  * DEFAULT 0
KR Moorhouse's avatar
KR Moorhouse committed
294 295 296
  
### Chunks

KR Moorhouse's avatar
KR Moorhouse committed
297 298 299 300 301 302 303 304 305 306 307 308
_**nf3_chunks**_ (Table of Chunks created on publish to be reconstructed into a Ninja Forms cache)
* id (The unique ID of the Chunk)
  * int(11)
  * NOT NULL
  * AUTO_INCREMENT
  * Primary Key
* name (The name of the Chunk)
  * varchar(200)
  * COLLATE utf8mb4_general_ci (fallback to utf8_general_ci)
* value (The value of the Chunk)
  * longtext
  * COLLATE utf8mb4_general_ci (fallback to utf8_general_ci)
309

KR Moorhouse's avatar
KR Moorhouse committed
310 311
### Chunks

KR Moorhouse's avatar
KR Moorhouse committed
312 313 314 315 316 317 318 319 320 321 322 323
_**nf3_chunks**_ (Table of Chunks created on publish to be reconstructed into a Ninja Forms cache)
* id (The unique ID of the Chunk)
  * int(11)
  * NOT NULL
  * AUTO_INCREMENT
  * Primary Key
* name (The name of the Chunk)
  * varchar(200)
  * COLLATE utf8mb4_general_ci (fallback to utf8_general_ci)
* value (The value of the Chunk)
  * longtext
  * COLLATE utf8mb4_general_ci (fallback to utf8_general_ci)
324

KR Moorhouse's avatar
KR Moorhouse committed
325
## Version 1.0
326

327 328
Defined initial structure for Ninja Forms data layer.

KR Moorhouse's avatar
KR Moorhouse committed
329
### Forms
KR Moorhouse's avatar
KR Moorhouse committed
330

331 332
_**nf3_forms**_ (Table of individual Forms)
* id (The unique ID of the Form)
333 334 335 336
  * int(11)
  * NOT NULL
  * AUTO_INCREMENT
  * Primary Key
337
* title (The displayable title of the Form)
338 339
  * longtext
  * COLLATE DATABASE_DEFAULT
340
* key (The administrative key of the Form)
341 342
  * longtext
  * COLLATE DATABASE_DEFAULT
343
* created_at (The date/time the Form was created)
344 345 346 347
  * timestamp
  * NOT NULL
  * DEFAULT CURRENT_TIMESTAMP
  * ON UPDATE CURRENT_TIMESTAMP
348
* updated_at (The date/time the Form was last updated)
349
  * datetime
350
* views (The number of times the Form has been viewed)
351
  * int(11)
352
* subs (The Form's number of lifetime Submissions)
353
  * int(11)
KR Moorhouse's avatar
KR Moorhouse committed
354 355


356 357
_**nf3_form_meta**_ (Table of Settings assoicated with each Form)
* id (The unique ID of the Setting)
358 359 360 361
  * int(11)
  * NOT NULL
  * AUTO_INCREMENT
  * Primary Key
362
* parent_id (The Form ID this Setting is associated with)
363 364 365
  * int(11)
  * NOT NULL
  * Foreign Key ON *nf3_forms* id
366
* key (The administrative key of the Setting)
367 368 369
  * longtext
  * COLLATE DATABASE_DEFAULT
  * NOT NULL
370
* value (The value of the Setting)
371 372
  * longtext
  * COLLATE DATABASE_DEFAULT
KR Moorhouse's avatar
KR Moorhouse committed
373

KR Moorhouse's avatar
KR Moorhouse committed
374
### Fields
KR Moorhouse's avatar
KR Moorhouse committed
375

KR Moorhouse's avatar
KR Moorhouse committed
376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401
_**nf3_fields**_ (Table of individual Fields)
* id (The unique ID of the Field)
  * int(11)
  * NOT NULL
  * AUTO_INCREMENT
  * Primary Key
* label (The displayable label of the Field)
  * longtext
  * COLLATE DATABASE_DEFAULT
* key (The administrative key of the Field)
  * longtext
  * COLLATE DATABASE_DEFAULT
* type (The type of Field this record represents)
  * longtext
  * COLLATE DATABASE_DEFAULT
* parent_id (The Form ID this Field is associated with)
  * int(11)
  * NOT NULL
  * Foreign Key ON *nf3_forms* id
* created_at (The date/time the Field was created)
  * timestamp
  * NOT NULL
  * DEFAULT CURRENT_TIMESTAMP
  * ON UPDATE CURRENT_TIMESTAMP
* updated_at (The date/time the Field was last updated)
  * datetime
KR Moorhouse's avatar
KR Moorhouse committed
402 403


KR Moorhouse's avatar
KR Moorhouse committed
404 405 406 407 408 409 410 411 412 413 414 415 416 417
_**nf3_field_meta**_ (Table of Settings associated with each Field)
* id (The unique ID of the Setting)
  * int(11)
  * NOT NULL
  * AUTO_INCREMENT
  * Primary Key
* parent_id (The Field ID this Setting is associated with)
  * int(11)
  * NOT NULL
  * Foreign Key ON *nf3_fields* id
* key (The administrative key of the Setting)
  * longtext
  * COLLATE DATABASE_DEFAULT
  * NOT NULL
KR Moorhouse's avatar
KR Moorhouse committed
418 419 420
* value (The value of the Setting)
  * longtext
  * COLLATE DATABASE_DEFAULT
KR Moorhouse's avatar
KR Moorhouse committed
421
  
KR Moorhouse's avatar
KR Moorhouse committed
422
### Actions
KR Moorhouse's avatar
KR Moorhouse committed
423

KR Moorhouse's avatar
KR Moorhouse committed
424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452
_**nf3_actions**_ (Table of individual Actions)
* id (The unique ID of the Action)
  * int(11)
  * NOT NULL
  * AUTO_INCREMENT
  * Primrary Key
* title (The displayable title of the Action)
  * longtext
  * COLLATE DATABASE_DEFAULT
* key (The administrative key of the Action)
  * longtext
  * COLLATE DATABASE_DEFAULT
* type (The type of Action this record represents)
  * longtext
  * COLLATE DATABASE_DEFAULT
* active (Whether or not the Action is active)
  * tinyint(1)
  * DEFAULT 1
* parent_id (The Form ID this Action is associated with)
  * int(11)
  * NOT NULL
  * Foreign Key ON *nf3_forms* id
* created_at (The date/time the Action was created)
  * timestamp
  * NOT NULL
  * DEFAULT CURRENT_TIMESTAMP
  * ON UPDATE CURRENT_TIMESTAMP
* updated_at (The date/time the Action was last updated)
  * datetime
KR Moorhouse's avatar
KR Moorhouse committed
453 454


KR Moorhouse's avatar
KR Moorhouse committed
455 456 457 458 459 460 461 462 463 464 465 466 467 468
_**nf3_action_meta**_ (Table of Settings associated with each Action)
* id (The unique ID of the Setting)
  * int(11)
  * NOT NULL
  * AUTO_INCREMENT
  * Primary KEY
* parent_id (The Action ID this Setting is associated with)
  * int(11)
  * NOT_NULL
  * Foreign Key ON *nf3_actions* id
* key (The administrative key of the Setting)
  * longtext
  * COLLATE DATABASE_DEFAULT
  * NOT NULL
KR Moorhouse's avatar
KR Moorhouse committed
469 470
* value (The value of the Setting)
  * longtext
471
  * COLLATE DATABASE_DEFAULT
KR Moorhouse's avatar
KR Moorhouse committed
472

473
### Objects
KR Moorhouse's avatar
KR Moorhouse committed
474

475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493
_**nf3_objects**_ (Table of non-structured Objects)
* id (The unique ID of the Object)
  * int(11)
  * NOT NULL
  * AUTO_INCREMENT
  * Primrary Key
* type (The type of Object this record represents)
  * longtext
  * COLLATE DATABASE_DEFAULT
* title (The displayable title of the Object)
  * longtext
  * COLLATE DATABASE_DEFAULT
* created_at (The date/time the Object was created)
  * timestamp
  * NOT NULL
  * DEFAULT CURRENT_TIMESTAMP
  * ON UPDATE CURRENT_TIMESTAMP
* updated_at (The date/time the Object was last updated)
  * datetime
KR Moorhouse's avatar
KR Moorhouse committed
494 495


496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512
_**nf3_object_meta**_ (Table of Settings associated with each Object)
* id (The unique ID of the Setting)
  * int(11)
  * NOT NULL
  * AUTO_INCREMENT
  * Primary KEY
* parent_id (The Object ID this Setting is associated with)
  * int(11)
  * NOT_NULL
  * Foreign Key ON *nf3_objects* id
* key (The administrative key of the Setting)
  * longtext
  * COLLATE DATABASE_DEFAULT
  * NOT NULL
* value (The value of the Setting)
  * longtext
  * COLLATE DATABASE_DEFAULT
KR Moorhouse's avatar
KR Moorhouse committed
513 514


515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543
_**nf3_relationships**_ (Table of Relationships between Objects)
* id (The unique ID of the Relationship)
  * int(11)
  * NOT NULL
  * AUTO_INCREMENT
  * Primary KEY
* child_id (The child Object ID this record is associated with)
  * int(11)
  * NOT_NULL
  * Foreign Key ON *nf3_objects* id
* child_type (The type of Object represented by child_id)
  * longtext
  * COLLATE DATABASE_DEFAULT
  * NOT NULL
* parent_id (The parent Object ID this record is associated with)
  * int(11)
  * NOT_NULL
  * Foreign Key ON *nf3_objects* id
* parent_type (The type of Object represented by parent_id)
  * longtext
  * COLLATE DATABASE_DEFAULT
  * NOT NULL
* created_at (The date/time the Relationship was created)
  * timestamp
  * NOT NULL
  * DEFAULT CURRENT_TIMESTAMP
  * ON UPDATE CURRENT_TIMESTAMP
* updated_at (The date/time the Relationship was last updated)
  * datetime
KR Moorhouse's avatar
KR Moorhouse committed
544 545


546 547 548
_**options**_ (The default WordPress options table)
* option_name = 'nf_form_%' WHERE % = *nf3_forms* id
* option_value = Serialized JSON Object (The Ninja Forms Cache)
KR Moorhouse's avatar
KR Moorhouse committed
549

550
### Submissions
KR Moorhouse's avatar
KR Moorhouse committed
551

552 553 554 555 556 557 558
_**posts**_ (The default WordPress posts table)
* id (The unique ID of the Post)
  * bigint(20)
  * NOT NULL
  * AUTO_INCREMENT
  * Primary Key
* post_type = 'nf_sub'
KR Moorhouse's avatar
KR Moorhouse committed
559 560


561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576
_**postmeta**_ (The default WordPress postmeta table)
* meta_id (The unique ID of the Metadata)
  * bigint(20)
  * NOT NULL
  * AUTO_INCREMENT
  * Primary Key
* post_id (The Post ID this Metadata is associated with)
  * bigint(20)
  * NOT NULL
  * DEFAULT 0
  * Foreign Key ON *posts* id
* meta_key (The identifiable key by which this record is referenced)
  * varchar(255)
  * COLLATE DATABASE_DEFAULT
* meta_value (The value of this record)
  * longtext
577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595
  * COLLATE DATABASE_DEFAULT

## Version 1.1

Defined tracker table for data structure updates.

### Upgrades

_**nf3_upgrades**_ (Table of Forms as they exist in the current structure and the stage of upgrade currently applied to each Form)
* id (The unique ID of the Form)
  * int(11)
  * NOT NULL
  * Primary Key
* cache (The Ninja Forms cache as it was retrieved from the *options* table)
  * longtext
  * COLLATE utf8mb4_general_ci (fallback to utf8_general_ci)
* stage (The current upgrade stage of the Form)
  * int(11)
  * NOT NULL
596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623
  * DEFAULT 0

Defined chunks table for ensuring collate of chunked publish.

### Chunks

_**nf3_chunks**_ (Table of Chunks created on publish to be reconstructed into a Ninja Forms cache)
* id (The unique ID of the Chunk)
  * int(11)
  * NOT NULL
  * AUTO_INCREMENT
  * Primary Key
* name (The name of the Chunk)
  * varchar(200)
  * COLLATE utf8mb4_general_ci (fallback to utf8_general_ci)
* value (The value of the Chunk)
  * longtext
  * COLLATE utf8mb4_general_ci (fallback to utf8_general_ci)

Updated forms tables

### Forms

_**nf3_forms**_ (Table of individual Forms)
ADDED:
* form_title (The displayable title of the Form)
  * longtext
  * COLLATE utf8mb4_general_ci (fallback to utf8_general_ci)
Eric Windham's avatar
Eric Windham committed
624
* default_label_pos (The default label position of fields on the Form)
625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643
  * varchar(15)
* show_title (Whether or not to show the Form title)
  * bit(1)
* clear_complete (Whether or not to clear the Form after submission)
  * bit(1)
* hide_complete (Whether or not to hide the Form after submission)
  * bit(1)
* logged_in (Whether or not the user must be logged in to view the Form)
  * bit(1)
* seq_num (The number of the next submission to the Form)
  * int(11)

_**nf3_form_meta**_ (Table of Settings assoicated with each Form)
ADDED:
* meta_key (The administrative key of the Setting)
  * longtext
  * COLLATE utf8mb4_general_ci (fallback to utf8_general_ci)
* meta_value (The value of the Setting)
  * longtext
KR Moorhouse's avatar
KR Moorhouse committed
644
  * COLLATE utf8mb4_general_ci (fallback to utf8_general_ci)