Deliverables database table

From TaskDepender
Jump to: navigation, search
(Undo revision 963 by Fred (talk))
(Description)
 
Line 3: Line 3:
 
== Description ==
 
== Description ==
  
To hold the [[Task_management_method#Deliverable|deliverables]], a database table is created. The following constraint applied:
+
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.
* When the Deliverable is contained in a container task and that task is deleted, the Deliverable needs to be deleted as well.
+
 
 +
== Constraints ==
 +
 
 +
The following constraints apply for the deliverables table:
 +
* When a container task is deleted, the contained tasks need 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 a deliverable is deleted, all its connections are deleted as well.
  
 
== Design ==
 
== Design ==
  
The <b><tt>Deliverables</tt></b> table has the following fields:
+
The <tt>Deliverables</tt> table has the following fields:
  
 
{| valign="top" border="1" cellpadding="3" cellspacing="0"
 
{| valign="top" border="1" cellpadding="3" cellspacing="0"
Line 20: Line 26:
 
| <tt>Description</tt>|| text || [[System Data Format|SDF string]].
 
| <tt>Description</tt>|| text || [[System Data Format|SDF string]].
 
|- valign="top"
 
|- valign="top"
| <tt>Resource</tt> || text || E.g. name or initials of a person responsible for the deliverable.
+
| <tt>X</tt> || integer || The x-coordinate of the deliverable in the diagram, expressed in pixels.
 
|- valign="top"
 
|- valign="top"
| <tt>X</tt> || integer || The x-coordinate of the deliverable in the diagram.
+
| <tt>Y</tt> || integer || The y-coordinate of the deliverable in the diagram, expressed in pixels.
 
|- valign="top"
 
|- valign="top"
| <tt>Y</tt> || integer || The y-coordinate of the deliverable in the diagram.
+
| <tt>Width</tt> || integer || The width of the deliverable in the diagram, expressed in pixels.
 +
|- valign="top"
 +
| <tt>Height</tt> || integer || The height of the deliverable in the diagram, expressed in pixels.
 
|- valign="top"
 
|- valign="top"
 
| <tt>ContainerId</tt> || integer || The id of the container task. Set to 0 if defined at the top level.
 
| <tt>ContainerId</tt> || integer || The id of the container task. Set to 0 if defined at the top level.
Line 31: Line 39:
 
|- valign="top"
 
|- valign="top"
 
| <tt>Available</tt> || integer || Whether or not the deliverable is ready to be used as input for the dependent task.
 
| <tt>Available</tt> || integer || Whether or not the deliverable is ready to be used as input for the dependent task.
 +
|- valign="top"
 +
| <tt>ConnectionId</tt> || integer || If the deliverable is a clone, this value in not 0 and indicates the id of the entry in the [[Connections database table|connection]].
 
|}
 
|}
  
To implement the constraint, <tt>ContainerId</tt> column is referenced to the <tt>Id</tt> of the [[Tasks database table|tasks table]].
 
  
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]].
+
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]]
  
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.
 
 
== 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, ContainerId)
 
VALUES (%s, %s, %s, %d, %d, %s, %d, (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)
 
</syntaxhighlight>
 
 
=== Delete deliverable ===
 
 
<syntaxhighlight lang="sql">
 
DELETE FROM Deliverables WHERE Id=%d
 
</syntaxhighlight>
 
  
 
----
 
----
 
 
* [[Database]]
 
* [[Database]]

Latest revision as of 06:53, 30 November 2011