DBVIEW
src/org/dbview/input_addons/DbForeignKey.java
00001 /*
00002         DbView - Graph Visualization
00003     Copyright (C) 2012  Denis BEURIVE
00004 
00005     This program is free software: you can redistribute it and/or modify
00006     it under the terms of the GNU General Public License as published by
00007     the Free Software Foundation, either version 3 of the License, or
00008     (at your option) any later version.
00009 
00010     This program is distributed in the hope that it will be useful,
00011     but WITHOUT ANY WARRANTY; without even the implied warranty of
00012     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013     GNU General Public License for more details.
00014 
00015     You should have received a copy of the GNU General Public License
00016     along with this program.  If not, see <http://www.gnu.org/licenses/>.
00017 */
00018 
00019 /**
00020  * @author Denis Beurive
00021  */
00022 package org.dbview.input_addons;
00023 
00024 /**
00025  * <p>This class represents a foreign key.</p>
00026  * <p>Please note that there are two kinds of foreign key:</p>
00027  * <ul>
00028  *     <li>Hard foreign key: This kind of key is materialized by a constraint.</li>
00029  *     <li>Soft foreign key: This kind of key is only materialized by its name.</li>
00030  * </ul>
00031  * <p>A foreign key is defined by a &quot;reference field&quot; and a &quot;dependent field&quot;.</p>
00032  *
00033  * @author Denis Beurive
00034  */
00035 public class DbForeignKey
00036 {
00037     /**
00038      * Name of the "reference" table.
00039      */
00040         public String table_name = null;
00041 
00042         /**
00043          * Name of the "reference" field, within the "reference" table.
00044          */
00045         public String field_name = null;
00046 
00047         /**
00048          * Name of the "reference" table.
00049          */
00050         public String reference_table_name = null;
00051 
00052         /**
00053          * Name of the "reference" field, within the "target" table.
00054          */
00055         public String reference_field_name = null;
00056 
00057         /**
00058          * Return the full name of the field.
00059          * @return The méthod the full name of the field.
00060          */
00061         public String getFullName() { return this.table_name + "." + this.field_name; }
00062         
00063         /**
00064          * Create a foreign key.
00065          * @param in_table_name Name of the "dependent" table.
00066          * @param in_field_name Name of the "dependent" field, within the "reference" table.
00067          * @param in_reference_table_name Name of the "reference" table.
00068          * @param in_reference_field_name Name of the "reference" field, within the "reference" table.
00069          */
00070         public DbForeignKey(String in_table_name, String in_field_name, String in_reference_table_name, String in_reference_field_name)
00071         {
00072                 this.table_name        = in_table_name;
00073                 this.field_name        = in_field_name;
00074                 this.reference_field_name = in_reference_field_name;
00075                 this.reference_table_name = in_reference_table_name;
00076         }
00077 }