Deliverables database table

From TaskDepender
Jump to: navigation, search
(Definition)
(Description)
 
Line 3: Line 3:
 
== Description ==
 
== Description ==
  
The deliverable component is described in [[Task_Management_Method#Deliverable|"Task Management Method"]]. The deliverables in the project are stored in a table in the project database. Since the name does not have to be unique, a deliverable has to have a unique id which can be generated as a integer primary key [http://www.sqlite.org/lang_createtable.html#rowid] by the database[http://www.sqlite.org/lang_createtable.html#rowid]. Since a deliverable represents a graphical element, it has a position, a width and a height. When using a true-type font, the width and height will be determined when the task is displayed.
+
The deliverable component is described in [[Task_Management_Method#Deliverable|"Task Management Method"]]. The deliverables in the project are stored in a table in the project database. Since the name does not have to be unique, a deliverable has to have a unique id which can be generated as a integer primary key [http://www.sqlite.org/lang_createtable.html#rowid] by the database [http://www.sqlite.org/lang_createtable.html#rowid]. Since a deliverable represents a graphical element, it has a position, a width and a height. When using a true-type font, the width and height will be determined when the task is displayed.
 +
 
 +
== Constraints ==
  
 
The following constraints apply for the deliverables table:
 
The following constraints apply for the deliverables table:
* All contained deliverables are deleted when the container task is deleted.
+
* When a container task is deleted, the contained tasks need to be deleted as well.  
* When the Deliverable is a [[Clone|clone]] of a Deliverable at a higher level and that Deliverable is deleted, then its clone needs to be deleted as well.
+
* When the connection between the parent and the connected task is deleted, a [[Clone|cloned deliverable]] must be deleted as well.
* When the connection between the parent and the connected task is deleted, the clone must be deleted as well.
+
* When a deliverable is deleted, all its connections are deleted as well.
  
 
== Design ==
 
== Design ==
  
=== Definition ===
+
The <tt>Deliverables</tt> table has the following fields:
 
+
The <b><tt>Deliverables</tt></b> table has the following fields:
+
  
 
{| valign="top" border="1" cellpadding="3" cellspacing="0"
 
{| valign="top" border="1" cellpadding="3" cellspacing="0"
Line 43: Line 43:
 
|}
 
|}
  
The C-interface structure is given by <tt>tdd_deliverable</tt>.
 
 
=== Constraints ===
 
To implement the constraint, <tt>ContainerId</tt> column is referenced to the <tt>Id</tt> of the [[Tasks database table|tasks 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.
 
 
=== 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]].
 
 
=== Insert ===
 
A deliverable can only be inserted in the current diagram, so in the current container. Therefore, when inserting a deliverable, the <tt>ContainerId</tt> os filled in by using the id of the current container as stored in the [[State variables database table|state-variables table]].
 
 
=== Update ===
 
 
A deliverable can only be updated ore deleted when it is selected. The selected deliverables are listed in the [[Selected_deliverables_database table|selected deliverables table]]. This means that the user does not have to supply the id when updating or deleting a selected deliverable.
 
 
=== Delete ===
 
 
Only selected deliverable can be deleted. This means that the user does not have to supply an id, but simply all selected deliverables are deleted.
 
 
=== Cut ===
 
 
As described in [[Cut selected elements|"Cut selected elements"]], selected elements can be 'cut to the clipboard' by setting the <tt>ContainerId</tt> column to the maximum integer value. Since the <tt>Id</tt> of a deliverable is stored in a [[Types|<tt>uint32</tt>]], this value is explicitly set to 4294967295 (=2<sup>32</sup>).
 
 
=== Paste ===
 
 
As described in [[Paste elements|"Paste elements"]], elements can be pasted into the current diagram by setting the <tt>ContainerId</tt> column to the current container. As follows from the previous section, this is done by finding all the deliverables that have this <tt>ContainerId</tt> set to the maximum integer value of 4294967295.
 
 
== Implementation ==
 
 
=== Create table ===
 
 
<syntaxhighlight lang="sql">
 
CREATE TABLE Deliverables
 
(
 
  Id INTEGER PRIMARY KEY,
 
  Name TEXT,
 
  Description TEXT,
 
  Resource TEXT,
 
  X INTEGER,
 
  Y INTEGER,
 
  ContainerId INTEGER REFERENCES Tasks(Id) ON DELETE CASCADE,
 
  Link TEXT,
 
  Available INTEGER,
 
)
 
</syntaxhighlight>
 
 
=== Insert ===
 
 
<syntaxhighlight lang="sql">
 
INSERT INTO Deliverables
 
(Name,Description, Resource, X, Y, Link, Available, ConnectionId, ContainerId)
 
VALUES (%s, %s, %s, %d, %d, %s, %d, 0, (SELECT Val FROM StateVariables WHERE Name='CurrentContainerId'))
 
</syntaxhighlight>
 
 
=== Update ===
 
 
<syntaxhighlight lang="sql">
 
UPDATE Deliverables SET
 
  Name=%s,
 
  Description=%s,
 
  Resource=%s,
 
  X=%d,
 
  Y=%d,
 
  Link=%s,
 
  Available=%d
 
WHERE Id IN (SELECT Id FROM SelectedDeliverables LIMIT 1)
 
</syntaxhighlight>
 
 
=== Delete deliverable ===
 
 
<syntaxhighlight lang="sql">
 
DELETE FROM Deliverables WHERE Id=%d
 
</syntaxhighlight>
 
 
=== Cut selected deliverables ===
 
 
<syntaxhighlight lang="sql">
 
UPDATE Deliverables SET ContainerId=4294967295 WHERE Id IN (SELECT Id FROM SelectedDeliverables)
 
</syntaxhighlight>
 
  
=== Paste deliverables ===
+
The following actions are defined:
 +
* [[Deliverables database table - Create|Create]]
 +
* [[Deliverables database table - Insert|Insert]]
 +
* [[Deliverables database table - Update|Update]]
 +
* [[Deliverables database table - Delete|Delete]]
 +
* [[Deliverables database table - Cut|Cut]]
 +
* [[Deliverables database table - Paste|Paste]]
  
<syntaxhighlight lang="sql">
 
UPDATE Deliverables SET ContainerId=(SELECT Val FROM StateVariables WHERE Name='CurrentContainerId') WHERE ContainerId=4294967295
 
</syntaxhighlight>
 
  
 
----
 
----
 
* [[Database]]
 
* [[Database]]

Latest revision as of 06:53, 30 November 2011

Personal tools