github.com/dolthub/dolt/go@v0.40.5-0.20240520175717-68db7794bea6/serial/foreign_key.fbs (about)

     1  // Copyright 2022 Dolthub, Inc.
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //     http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  
    15  namespace serial;
    16  
    17  // https://dev.mysql.com/doc/refman/8.0/en/create-table-foreign-keys.html#foreign-key-referential-actions
    18  enum ForeignKeyReferentialAction : uint8 {
    19    DefaultAction = 0,
    20    Cascade = 1,
    21    NoAction = 2,
    22    Restrict = 3,
    23    SetNull = 4,
    24  }
    25  
    26  table ForeignKeyCollection {
    27    foreign_keys:[ForeignKey];
    28  }
    29  
    30  table ForeignKey {
    31    // foreign key name
    32    name:string;
    33  
    34    // child table
    35    child_table_name:string;
    36    child_table_index:string;
    37    child_table_columns:[uint64];
    38  
    39    // parent table
    40    parent_table_name:string;
    41    parent_table_index:string;
    42    parent_table_columns:[uint64];
    43  
    44    // reference options
    45    on_update:ForeignKeyReferentialAction;
    46    on_delete:ForeignKeyReferentialAction;
    47  
    48    // unresolved details
    49    unresolved_child_columns:[string];
    50    unresolved_parent_columns:[string];
    51    
    52    // For tables in the non-default schema, these fields are set 
    53    child_table_database_schema:[string];
    54    parent_table_database_schema:[string];
    55  }
    56  
    57  // KEEP THIS IN SYNC WITH fileidentifiers.go
    58  file_identifier "DFKC";
    59  
    60  root_type ForeignKeyCollection;