Deliverables database table - Create

From TaskDepender
Jump to: navigation, search
(Created page with "--place holder--")
 
Line 1: Line 1:
--place holder--
+
''The creation of the [[Deliverables database table]].''
 +
 
 +
== Create ==
 +
 
 +
When a new project is created, the deliverables table is created. Because of the reference to the task (see [[#Constraints|"Constraints"]], the deliverables table must be created ''after'' the [[Tasks database table|tasks table]].
 +
 
 +
== Constraints ==
 +
 
 +
The two constraints for the table can be implemented by by [http://www.sqlite.org/foreignkeys.html#fk_actions referencing] these columns to the appropriate columns. This is done as follows:
 +
* Delete contained deliverable when container is deleted: reference the <tt>ContainerId</tt> column to the <tt>Id</tt> of the [[Tasks database table|tasks table]].
 +
* Delete cloned deliverable when parent deliverable is deleted: self-reference the <tt>ContainerId column to the Id column.
 +
 
 +
* Set <tt>RecourceId</tt> to <tt>NULL</tt> when recource deleted: reference <tt>RecourceId</tt> to the <tt>Id</tt> in the [[Resources database table|resources table]].
 +
 
 +
The last two constraints are implemented via [[Creating a cross reference|cross-referencing]] with the [[Connections database table|<tt>Connections</tt> table]]. Consequently, the <tt>ConnectionId</tt> field is added when this table is created.
 +
 
 +
== SQL statement ==
 +
 
 +
<syntaxhighlight lang="sql">
 +
CREATE TABLE Deliverables
 +
(
 +
  Id INTEGER PRIMARY KEY,
 +
  Name TEXT,
 +
  Description TEXT,
 +
  Resource TEXT,
 +
  X INTEGER,
 +
  Y INTEGER,
 +
  Width INTEGER,
 +
  Height INTEGER,
 +
  ContainerId INTEGER REFERENCES Tasks(Id) ON DELETE CASCADE,
 +
  Link TEXT,
 +
  Available INTEGER,
 +
)
 +
</syntaxhighlight>

Revision as of 19:41, 29 November 2011