summaryrefslogtreecommitdiff
path: root/demos/time-tracker/protected/App_Data/MySQL4
diff options
context:
space:
mode:
Diffstat (limited to 'demos/time-tracker/protected/App_Data/MySQL4')
-rw-r--r--demos/time-tracker/protected/App_Data/MySQL4/category.xml93
-rw-r--r--demos/time-tracker/protected/App_Data/MySQL4/mysql-reset.sql26
-rw-r--r--demos/time-tracker/protected/App_Data/MySQL4/projects.xml156
-rw-r--r--demos/time-tracker/protected/App_Data/MySQL4/reports.xml87
-rw-r--r--demos/time-tracker/protected/App_Data/MySQL4/time-entry.xml93
-rw-r--r--demos/time-tracker/protected/App_Data/MySQL4/time-tracker-mysql.sql135
-rw-r--r--demos/time-tracker/protected/App_Data/MySQL4/users.xml137
7 files changed, 727 insertions, 0 deletions
diff --git a/demos/time-tracker/protected/App_Data/MySQL4/category.xml b/demos/time-tracker/protected/App_Data/MySQL4/category.xml
new file mode 100644
index 00000000..e9248e6d
--- /dev/null
+++ b/demos/time-tracker/protected/App_Data/MySQL4/category.xml
@@ -0,0 +1,93 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<sqlMap>
+
+<resultMap id="category-result" class="CategoryRecord">
+ <result property="Name" column="Name" />
+ <result property="EstimateDuration" column="EstimateDuration" type="float" />
+ <result property="ProjectID" column="ProjectID" type="integer" />
+ <result property="Abbreviation" column="Abbreviation" />
+ <result property="ID" column="CategoryID" type="integer" />
+ <result property="ActualDuration" column="ActualDuration" type="float" />
+</resultMap>
+
+<insert id="AddNewCategory" parameterClass="CategoryRecord">
+ INSERT INTO categories
+ (Name, ProjectID, Abbreviation, EstimateDuration)
+ VALUES(#Name#, #ProjectID#, #Abbreviation#, #EstimateDuration#)
+ <selectKey property="ID" type="post" resultClass="int">
+ select LAST_INSERT_ID() as value
+ </selectKey>
+</insert>
+
+<select id="GetCategoryByID" parameterClass="integer" resultMap="category-result">
+ SELECT
+ categories.*,
+ sum(time_entry.Duration) as ActualDuration
+ FROM
+ categories
+ LEFT JOIN time_entry ON categories.CategoryID = time_entry.CategoryID
+ WHERE
+ categories.CategoryID = #value#
+ GROUP BY
+ categories.CategoryID
+ ORDER BY
+ categories.Name
+</select>
+
+<select id="GetAllCategories" resultMap="category-result">
+ SELECT
+ categories.*,
+ sum(time_entry.Duration) as ActualDuration
+ FROM
+ categories
+ LEFT JOIN time_entry ON categories.CategoryID = time_entry.CategoryID
+ GROUP BY
+ categories.CategoryID
+ ORDER BY
+ categories.Name
+</select>
+
+<delete id="DeleteCategory" parameterClass="integer">
+ DELETE FROM categories WHERE CategoryID = #value#
+</delete>
+
+<select id="GetCategoriesByProjectID" resultMap="category-result">
+ SELECT
+ categories.*,
+ sum(time_entry.Duration) as ActualDuration
+ FROM
+ categories
+ LEFT JOIN time_entry ON categories.CategoryID = time_entry.CategoryID
+ WHERE
+ categories.ProjectID = #value#
+ GROUP BY
+ categories.CategoryID
+ ORDER BY
+ categories.Name
+</select>
+
+<select id="GetCategoryByNameInProject" parameterClass="array" resultMap="category-result">
+ SELECT
+ categories.*,
+ sum(time_entry.Duration) as ActualDuration
+ FROM
+ categories
+ LEFT JOIN time_entry ON categories.CategoryID = time_entry.CategoryID
+ WHERE
+ categories.ProjectID = #project#
+ AND categories.Name = #category#
+ GROUP BY
+ categories.CategoryID
+</select>
+
+<update id="UpdateCategory" parameterClass="CategoryRecord">
+ UPDATE categories SET
+ Abbreviation = #Abbreviation#,
+ EstimateDuration = #EstimateDuration#,
+ Name = #Name#,
+ ProjectId = #ProjectID#
+ WHERE
+ CategoryID = #ID#
+</update>
+
+</sqlMap> \ No newline at end of file
diff --git a/demos/time-tracker/protected/App_Data/MySQL4/mysql-reset.sql b/demos/time-tracker/protected/App_Data/MySQL4/mysql-reset.sql
new file mode 100644
index 00000000..e9581952
--- /dev/null
+++ b/demos/time-tracker/protected/App_Data/MySQL4/mysql-reset.sql
@@ -0,0 +1,26 @@
+TRUNCATE `user_roles`;
+TRUNCATE `role_types`;
+TRUNCATE `project_members`;
+TRUNCATE `time_entry`;
+TRUNCATE `signon`;
+TRUNCATE `categories`;
+TRUNCATE `project`;
+TRUNCATE `users`;
+
+INSERT INTO role_types (RoleType, Description) VALUES
+('admin', 'Project administrator may additionally view the list of all users.'),
+('consultant', 'Consultant may log time entries only.'),
+('manager', 'Project manager may additionally edit all projects and view reports.');
+
+INSERT INTO users (Username, Password, EmailAddress, Disabled) VALUES
+('admin', '21232f297a57a5a743894a0e4a801fc3', 'admin@pradosoft.com', 0),
+('manager', '1d0258c2440a8d19e716292b231e3190', 'manager@pradosoft.com', 0),
+('consultant', '7adfa4f2ba9323e6c1e024de375434b0', 'consultant@pradosoft.com', 0);
+
+INSERT INTO user_roles (UserID, RoleType) VALUES
+('admin', 'admin'),
+('admin', 'manager'),
+('admin', 'consultant'),
+('manager', 'manager'),
+('manager', 'consultant'),
+('consultant', 'consultant'); \ No newline at end of file
diff --git a/demos/time-tracker/protected/App_Data/MySQL4/projects.xml b/demos/time-tracker/protected/App_Data/MySQL4/projects.xml
new file mode 100644
index 00000000..099e7fef
--- /dev/null
+++ b/demos/time-tracker/protected/App_Data/MySQL4/projects.xml
@@ -0,0 +1,156 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<sqlMap>
+
+<resultMap id="project-result" class="ProjectRecord">
+ <result property="ID" column="ProjectID" type="integer"/>
+ <result property="Name" column="Name" />
+ <result property="Description" column="Description" />
+ <result property="DateCreated" column="CreationDate" typeHandler="DateTime" />
+ <result property="EstimateDuration" column="EstimateDuration" type="float" />
+ <result property="CompletionDate" column="CompletionDate" typeHandler="DateTime" />
+ <result property="CreatorUserName" column="CreatorID" />
+ <result property="ManagerUserName" column="ManagerID" />
+ <result property="ActualDuration" column="ActualDuration" type="float" />
+</resultMap>
+
+<select id="ProjectNameExists" resultClass="boolean">
+ SELECT COUNT(Name) FROM project WHERE Name = #value#
+</select>
+
+<insert id="CreateNewProject" parameterClass="ProjectRecord">
+ INSERT INTO project
+ (Name, Description, CreationDate, EstimateDuration, CompletionDate, CreatorID, ManagerID)
+ VALUES
+ (#Name#, #Description#, NOW(), #EstimateDuration#,
+ #CompletionDate, typeHandler=DateTime#,
+ #CreatorUserName#, #ManagerUserName#)
+ <selectKey property="ID" type="post" resultClass="int">
+ select LAST_INSERT_ID() as value
+ </selectKey>
+</insert>
+
+<select id="GetProjectByID" parameterClass="integer" resultMap="project-result">
+ SELECT
+ project.ProjectID as ProjectID,
+ project.Name as Name,
+ project.Description as Description,
+ project.CreationDate as CreationDate,
+ project.EstimateDuration as EstimateDuration,
+ project.CompletionDate as CompletionDate,
+ project.CreatorID as CreatorID,
+ project.ManagerID as ManagerID,
+ SUM(time_entry.Duration) as ActualDuration
+ FROM project
+ LEFT JOIN categories ON project.ProjectID = categories.ProjectID
+ LEFT JOIN time_entry ON categories.CategoryID = time_entry.CategoryID
+ WHERE
+ project.ProjectID = #value#
+ AND Disabled = 0
+ GROUP BY
+ project.ProjectID
+ ORDER BY
+ project.Name
+</select>
+
+<select id="GetAllProjects" resultMap="project-result">
+ SELECT
+ project.ProjectID as ProjectID,
+ project.Name as Name,
+ project.Description as Description,
+ project.CreationDate as CreationDate,
+ project.EstimateDuration as EstimateDuration,
+ project.CompletionDate as CompletionDate,
+ project.CreatorID as CreatorID,
+ project.ManagerID as ManagerID,
+ SUM(time_entry.Duration) as ActualDuration
+ FROM project
+ LEFT JOIN categories ON project.ProjectID = categories.ProjectID
+ LEFT JOIN time_entry ON categories.CategoryID = time_entry.CategoryID
+ WHERE
+ Disabled = 0
+ GROUP BY
+ project.ProjectID
+</select>
+
+<select id="GetAllProjectsOrdered" resultMap="project-result" extends="GetAllProjects">
+ ORDER BY $sort$ $order$
+</select>
+
+<select id="GetProjectsByManagerName" resultMap="project-result">
+ SELECT
+ project.ProjectID as ProjectID,
+ project.Name as Name,
+ project.Description as Description,
+ project.CreationDate as CreationDate,
+ project.EstimateDuration as EstimateDuration,
+ project.CompletionDate as CompletionDate,
+ project.CreatorID as CreatorID,
+ project.ManagerID as ManagerID,
+ SUM(time_entry.Duration) as ActualDuration
+ FROM project
+ LEFT JOIN categories ON project.ProjectID = categories.ProjectID
+ LEFT JOIN time_entry ON categories.CategoryID = time_entry.CategoryID
+ WHERE
+ Disabled = 0
+ AND project.ManagerID = #value#
+ GROUP BY
+ project.ProjectID
+ ORDER BY
+ project.Name
+</select>
+
+<select id="GetProjectsByUserName" resultMap="project-result">
+ SELECT
+ project.ProjectID as ProjectID,
+ project.Name as Name,
+ project.Description as Description,
+ project.CreationDate as CreationDate,
+ project.EstimateDuration as EstimateDuration,
+ project.CompletionDate as CompletionDate,
+ project.CreatorID as CreatorID,
+ project.ManagerID as ManagerID,
+ SUM(time_entry.Duration) as ActualDuration
+ FROM project
+ LEFT JOIN categories ON project.ProjectID = categories.ProjectID
+ LEFT JOIN time_entry ON categories.CategoryID = time_entry.CategoryID,
+ project_members
+ WHERE
+ project_members.ProjectID = project.ProjectID
+ AND project_members.UserID = #value#
+ AND project.Disabled = 0
+ GROUP BY
+ project.ProjectID
+ ORDER BY
+ project.Name
+</select>
+
+<update id="DeleteProject" parameterClass="integer">
+ UPDATE project SET Disabled = 1 WHERE ProjectID = #value#
+</update>
+
+<select id="GetProjectMembers" parameterClass="integer">
+ SELECT UserID FROM project_members WHERE ProjectID = #value#
+</select>
+
+<insert id="AddUserToProject" parameterClass="array">
+ INSERT INTO project_members (UserID, ProjectID)
+ VALUES(#username#, #project#)
+</insert>
+
+<delete id="RemoveUserFromProject" parameterClass="array">
+ DELETE FROM project_members WHERE ProjectID = #project# AND UserID = #username#
+</delete>
+
+<update id="UpdateProject" parameterClass="ProjectRecord">
+ UPDATE project
+ SET
+ CompletionDate = #CompletionDate, typeHandler=DateTime#,
+ Description = #Description#,
+ EstimateDuration = #EstimateDuration#,
+ ManagerId =#ManagerUserName#,
+ Name = #Name#
+ WHERE
+ ProjectID = #ID#
+</update>
+
+</sqlMap> \ No newline at end of file
diff --git a/demos/time-tracker/protected/App_Data/MySQL4/reports.xml b/demos/time-tracker/protected/App_Data/MySQL4/reports.xml
new file mode 100644
index 00000000..4b537708
--- /dev/null
+++ b/demos/time-tracker/protected/App_Data/MySQL4/reports.xml
@@ -0,0 +1,87 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<sqlMap>
+
+<resultMap id="project-category-user" class="ProjectReport" GroupBy="ProjectID">
+ <result property="ProjectName" column="ProjectName" />
+ <result property="EstimateHours" column="ProjectEstimate" type="float"/>
+ <result property="EstimateCompletion" column="ProjectCompletion" type="DateTime" />
+ <result property="Categories" type="TList" resultMapping="category-user-report" />
+</resultMap>
+
+<resultMap id="category-user-report" class="CategoryReport" GroupBy="CategoryID" >
+ <result property="CategoryName" column="CategoryName" />
+ <result property="EstimateHours" column="CategoryEstimate" type="float" />
+ <result property="members" type="array" resultMapping="member-report" />
+</resultMap>
+
+<resultMap id="member-report" class="array">
+ <result property="username" column="Username" />
+ <result property="hours" column="ActualDuration" type="float" />
+</resultMap>
+
+<select id="GetTimeReportByProjectIDs" resultMap="project-category-user">
+ SELECT
+ categories.Name as CategoryName,
+ categories.CategoryID as CategoryID,
+ project.ProjectID as ProjectID,
+ categories.EstimateDuration as CategoryEstimate,
+ project.Name as ProjectName,
+ project.EstimateDuration as ProjectEstimate,
+ project.CompletionDate as ProjectCompletion,
+ time_entry.UserID as Username,
+ SUM(time_entry.Duration) as ActualDuration
+ FROM
+ project
+ LEFT JOIN categories ON categories.ProjectID = project.ProjectID
+ LEFT JOIN time_entry ON categories.CategoryID = time_entry.CategoryID
+ WHERE
+ project.ProjectID IN ( $value$ )
+ GROUP BY
+ categories.ProjectID,
+ categories.CategoryID,
+ time_entry.UserID
+ ORDER BY
+ project.ProjectID
+</select>
+
+
+<resultMap id="time-entry-user-report" class="UserReport" GroupBy="Username">
+ <result property="Username" column="Username" />
+ <result property="Projects" resultMapping="project-user-report" />
+</resultMap>
+
+<resultMap id="project-user-report" class="UserProjectReport">
+ <result property="ProjectName" column="ProjectName" />
+ <result property="CategoryName" column="CategoryName" />
+ <result property="Duration" column="Duration" type="float" />
+ <result property="Description" column="Description" />
+ <result property="ReportDate" column="EntryDate" type="DateTime" />
+</resultMap>
+
+<select id="GetTimeReportByUsername" resultMap="time-entry-user-report">
+ SELECT
+ users.Username,
+ project.Name as ProjectName,
+ categories.Name as CategoryName,
+ time_entry.Duration,
+ time_entry.Description,
+ time_entry.EntryDate
+ FROM
+ users
+ LEFT JOIN time_entry ON time_entry.UserID = users.Username
+ AND time_entry.EntryDate BETWEEN
+ #startDate, typeHandler=DateTime# AND
+ #endDate, typeHandler=DateTime#
+ LEFT JOIN categories ON time_entry.CategoryID = categories.CategoryID
+ LEFT JOIN project ON categories.ProjectID = project.ProjectID
+ AND project.ProjectID in ($projects$)
+ WHERE
+ users.Username in ($members$)
+ ORDER BY
+ users.Username ASC,
+ time_entry.EntryDate ASC,
+ project.Name ASC,
+ categories.Name ASC
+</select>
+
+</sqlMap> \ No newline at end of file
diff --git a/demos/time-tracker/protected/App_Data/MySQL4/time-entry.xml b/demos/time-tracker/protected/App_Data/MySQL4/time-entry.xml
new file mode 100644
index 00000000..4838e625
--- /dev/null
+++ b/demos/time-tracker/protected/App_Data/MySQL4/time-entry.xml
@@ -0,0 +1,93 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<sqlMap>
+
+<insert id="AddNewTimeEntry" parameterClass="TimeEntryRecord">
+ INSERT INTO time_entry(
+ EntryCreated,
+ Duration,
+ Description,
+ CategoryID,
+ EntryDate,
+ CreatorID,
+ UserID
+ )
+ VALUES(
+ NOW(),
+ #Duration#,
+ #Description#,
+ #Category.ID#,
+ #ReportDate, typeHandler=DateTime#,
+ #CreatorUserName#,
+ #Username#
+ )
+ <selectKey property="ID" type="post" resultClass="int">
+ select LAST_INSERT_ID() as value
+ </selectKey>
+</insert>
+
+<resultMap id="time-entry-result" class="TimeEntryRecord">
+ <result property="ID" column="EntryID" type="integer" />
+ <result property="DateCreated" column="EntryCreated" typeHandler="DateTime" />
+ <result property="Duration" column="Duration" type="float" />
+ <result property="Description" column="Description" />
+ <result property="Category" column="CategoryID" />
+ <result property="ReportDate" column="EntryDate" typeHandler="DateTime" />
+ <result property="CreatorUserName" column="CreatorID" />
+ <result property="Username" column="UserID" />
+</resultMap>
+
+<resultMap id="time-entry-category-result" class="TimeEntryRecord">
+ <result property="ID" column="EntryID" type="integer" />
+ <result property="DateCreated" column="EntryCreated" typeHandler="DateTime" />
+ <result property="Duration" column="Duration" type="float" />
+ <result property="Description" column="Description" />
+ <result property="Category" resultMapping="entry-category" />
+ <result property="ReportDate" column="EntryDate" typeHandler="DateTime" />
+ <result property="CreatorUserName" column="CreatorID" />
+ <result property="Username" column="UserID" />
+</resultMap>
+
+<resultMap id="entry-category" class="CategoryRecord">
+ <result property="ID" column="CategoryID" />
+ <result property="Name" column="CategoryName" />
+</resultMap>
+
+<select id="GetTimeEntryByID" resultMap="time-entry-result">
+ SELECT
+ *
+ FROM
+ time_entry
+ WHERE
+ EntryID = #value#
+</select>
+
+<delete id="DeleteTimeEntry" parameterClass="integer">
+ DELETE FROM time_entry WHERE EntryID = #value#
+</delete>
+
+<select id="GetAllTimeEntriesByProjectIdAndUser" resultMap="time-entry-category-result">
+ SELECT
+ time_entry.*,
+ categories.Name as CategoryName
+ FROM
+ time_entry, categories
+ WHERE
+ time_entry.UserID = #username#
+ AND time_entry.CategoryID = categories.CategoryID
+ AND categories.ProjectID = #project#
+ ORDER BY
+ EntryID ASC
+</select>
+
+<update id="UpdateTimeEntry" parameterClass="TimeEntryRecord">
+ UPDATE time_entry SET
+ Duration = #Duration#,
+ Description = #Description#,
+ CategoryID = #Category.ID#,
+ EntryDate = #ReportDate, typeHandler=DateTime#,
+ UserID = #Username#
+ WHERE
+ EntryID = #ID#
+</update>
+
+</sqlMap> \ No newline at end of file
diff --git a/demos/time-tracker/protected/App_Data/MySQL4/time-tracker-mysql.sql b/demos/time-tracker/protected/App_Data/MySQL4/time-tracker-mysql.sql
new file mode 100644
index 00000000..89de378a
--- /dev/null
+++ b/demos/time-tracker/protected/App_Data/MySQL4/time-tracker-mysql.sql
@@ -0,0 +1,135 @@
+DROP TABLE IF EXISTS user_roles;
+CREATE TABLE user_roles (
+ UserID varchar(50) NOT NULL,
+ RoleType varchar(50) NOT NULL,
+ PRIMARY KEY (UserID,RoleType),
+ KEY RoleType (RoleType)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+DROP TABLE IF EXISTS role_types;
+CREATE TABLE role_types (
+ RoleType varchar(50) NOT NULL,
+ Description varchar(255) NOT NULL,
+ PRIMARY KEY (RoleType)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+DROP TABLE IF EXISTS project_members;
+CREATE TABLE project_members (
+ UserID varchar(50) NOT NULL,
+ ProjectID int(11) NOT NULL,
+ PRIMARY KEY (UserID,ProjectID),
+ KEY ProjectID (ProjectID)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+DROP TABLE IF EXISTS time_entry;
+CREATE TABLE time_entry (
+ EntryID int(11) NOT NULL auto_increment,
+ EntryCreated datetime NOT NULL,
+ Duration float(10,2) NOT NULL default '0.00',
+ Description varchar(1000) default NULL,
+ CategoryID int(11) NOT NULL default '0',
+ EntryDate datetime default NULL,
+ CreatorID varchar(50) NOT NULL,
+ UserID varchar(50) NOT NULL,
+ PRIMARY KEY (EntryID),
+ KEY CategoryID (CategoryID),
+ KEY CreatorID (CreatorID),
+ KEY UserID (UserID)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
+
+DROP TABLE IF EXISTS signon;
+CREATE TABLE signon (
+ SessionToken varchar(32) NOT NULL,
+ Username varchar(50) NOT NULL,
+ LastSignOnDate datetime NOT NULL,
+ PRIMARY KEY (SessionToken),
+ KEY Username (Username)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+DROP TABLE IF EXISTS categories;
+CREATE TABLE categories (
+ CategoryID int(11) NOT NULL auto_increment,
+ `Name` varchar(255) NOT NULL,
+ ProjectID int(11) NOT NULL,
+ ParentCategoryID int(11) default '0',
+ Abbreviation varchar(255) default NULL,
+ EstimateDuration float(10,2) default '0.00',
+ PRIMARY KEY (CategoryID),
+ UNIQUE KEY UniqueNamePerProject (`Name`,ProjectID),
+ KEY ProjectID (ProjectID)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
+
+DROP TABLE IF EXISTS project;
+CREATE TABLE project (
+ ProjectID int(11) NOT NULL auto_increment,
+ `Name` varchar(255) NOT NULL,
+ Description varchar(255) default NULL,
+ CreationDate datetime NOT NULL,
+ Disabled tinyint(1) NOT NULL default '0',
+ EstimateDuration float(10,2) NOT NULL default '0.00',
+ CreatorID varchar(50) NOT NULL,
+ ManagerID varchar(50) default NULL,
+ PRIMARY KEY (ProjectID),
+ KEY `Name` (`Name`),
+ KEY CreatorID (CreatorID),
+ KEY ManagerID (ManagerID)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
+
+DROP TABLE IF EXISTS users;
+CREATE TABLE users (
+ Username varchar(50) NOT NULL,
+ `Password` varchar(50) NOT NULL,
+ EmailAddress varchar(100) NOT NULL,
+ Disabled tinyint(1) NOT NULL default '0',
+ PRIMARY KEY (Username)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+ALTER TABLE `categories`
+ ADD CONSTRAINT categories_ibfk_1
+ FOREIGN KEY (ProjectID) REFERENCES project (ProjectID);
+
+ALTER TABLE `project`
+ ADD CONSTRAINT project_ibfk_2
+ FOREIGN KEY (ManagerID) REFERENCES users (Username),
+ ADD CONSTRAINT project_ibfk_1
+ FOREIGN KEY (CreatorID) REFERENCES users (Username);
+
+ALTER TABLE `project_members`
+ ADD CONSTRAINT project_members_ibfk_1
+ FOREIGN KEY (UserID) REFERENCES users (Username),
+ ADD CONSTRAINT project_members_ibfk_2
+ FOREIGN KEY (ProjectID) REFERENCES project (ProjectID);
+
+ALTER TABLE `signon`
+ ADD CONSTRAINT signon_ibfk_1
+ FOREIGN KEY (Username) REFERENCES users (Username);
+
+ALTER TABLE `time_entry`
+ ADD CONSTRAINT time_entry_ibfk_2
+ FOREIGN KEY (UserID) REFERENCES users (Username),
+ ADD CONSTRAINT time_entry_ibfk_1
+ FOREIGN KEY (CategoryID) REFERENCES categories (CategoryID);
+
+ALTER TABLE `user_roles`
+ ADD CONSTRAINT user_roles_ibfk_2
+ FOREIGN KEY (RoleType) REFERENCES role_types (RoleType),
+ ADD CONSTRAINT user_roles_ibfk_1
+ FOREIGN KEY (UserID) REFERENCES users (Username);
+
+INSERT INTO role_types (RoleType, Description) VALUES
+('admin', 'Project administrator may additionally view the list of all users.'),
+('consultant', 'Consultant may log time entries only.'),
+('manager', 'Project manager may additionally edit all projects and view reports.');
+
+INSERT INTO users (Username, Password, EmailAddress, Disabled) VALUES
+('admin', '21232f297a57a5a743894a0e4a801fc3', 'admin@pradosoft.com', 0),
+('manager', '1d0258c2440a8d19e716292b231e3190', 'manager@pradosoft.com', 0),
+('consultant', '7adfa4f2ba9323e6c1e024de375434b0', 'consultant@pradosoft.com', 0);
+
+INSERT INTO user_roles (UserID, RoleType) VALUES
+('admin', 'admin'),
+('admin', 'manager'),
+('admin', 'consultant'),
+('manager', 'manager'),
+('manager', 'consultant'),
+('consultant', 'consultant'); \ No newline at end of file
diff --git a/demos/time-tracker/protected/App_Data/MySQL4/users.xml b/demos/time-tracker/protected/App_Data/MySQL4/users.xml
new file mode 100644
index 00000000..6053c7ea
--- /dev/null
+++ b/demos/time-tracker/protected/App_Data/MySQL4/users.xml
@@ -0,0 +1,137 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<sqlMap>
+
+<resultMap id="time-tracker-user" class="TimeTrackerUser" GroupBy="Name">
+ <result property="Name" column="Name" />
+ <result property="EmailAddress" column="EmailAddress" />
+ <result property="Roles" Type="array" resultMapping="user-roles-result" />
+</resultMap>
+
+<resultMap id="user-roles-result">
+ <result column="role" />
+</resultMap>
+
+<!--
+<select id="GetUserByName" parameterClass="string" resultMap="TimeTrackerUser">
+ SELECT
+ users.Username as Name,
+ users.EmailAddress as EmailAddress,
+ user_roles.RoleType as role
+ FROM
+ users
+ LEFT JOIN user_roles ON users.Username = user_roles.UserID
+ WHERE
+ Username = #value#
+ AND
+ Disabled = 0
+</select>
+-->
+
+<select id="UsernameExists" parameterClass="string" resultClass="boolean">
+ SELECT COUNT(Username) FROM users WHERE Username = #value#
+</select>
+
+<select id="GetUserByName" parameterClass="string" resultMap="time-tracker-user">
+ SELECT
+ users.Username as Name,
+ users.EmailAddress as EmailAddress,
+ user_roles.RoleType as role
+ FROM
+ users
+ LEFT JOIN user_roles ON users.Username = user_roles.UserID
+ WHERE
+ Username = #value#
+ AND
+ Disabled = 0
+</select>
+
+<select id="GetAllUsers" resultMap="time-tracker-user">
+ SELECT
+ users.Username as Name,
+ users.EmailAddress as EmailAddress,
+ user_roles.RoleType as role
+ FROM
+ users
+ LEFT JOIN user_roles ON users.Username = user_roles.UserID
+ WHERE
+ Disabled = 0
+</select>
+
+<select id="ValidateUser" resultClass="boolean">
+ SELECT
+ count(Username)
+ FROM
+ users
+ WHERE
+ username = #username# AND password = #password#
+ AND
+ Disabled = 0
+</select>
+
+<insert id="AddNewUser" parameterClass="array">
+ INSERT INTO
+ users (Username, Password, EmailAddress)
+ VALUES
+ (#user.Name#, #password#, #user.EmailAddress#)
+</insert>
+
+<update id="DeleteUserByName">
+ UPDATE users SET Disabled = 1 WHERE username = #value#
+</update>
+
+<insert id="RegisterAutoSignon" parameterClass="array">
+ INSERT INTO
+ signon (SessionToken, Username, LastSignOnDate)
+ VALUES
+ (#token#, #username#, NOW())
+</insert>
+
+<select id="ValidateAutoSignon" resultMap="time-tracker-user">
+ SELECT
+ users.Username as Name,
+ users.EmailAddress as EmailAddress,
+ user_roles.RoleType as role
+ FROM
+ users LEFT JOIN user_roles ON users.Username = user_roles.UserID,
+ signon
+ WHERE
+ users.Username = signon.Username
+ AND signon.SessionToken = #value#
+ AND users.Disabled = 0
+</select>
+
+<update id="UpdateSignon">
+ UPDATE signon SET LastSignOnDate = NOW()
+ WHERE SessionToken = #value#
+</update>
+
+<delete id="DeleteUserRoles" parameterClass="TimeTrackerUser">
+ DELETE FROM user_roles WHERE UserID = #Name#
+</delete>
+
+<update id="AddUserRole" parameterClass="array">
+ INSERT INTO user_roles (UserID, RoleType)
+ VALUES(#username#, #role#)
+</update>
+
+<update id="UpdateUserDetails" parameterClass="TimeTrackerUser">
+ UPDATE users
+ SET EmailAddress = #EmailAddress#
+ WHERE Username = #Name#
+</update>
+
+<update id="UpdateUserDetailsAndPassword" parameterClass="array">
+ UPDATE users
+ SET EmailAddress = #user.EmailAddress#, Password=#password#
+ WHERE Username = #user.Name#
+</update>
+
+<delete id="DeleteAutoSignon">
+ DELETE FROM signon WHERE Username = #value#
+</delete>
+
+<delete id="DeleteAllSignon">
+ DELETE FROM signon
+</delete>
+
+</sqlMap> \ No newline at end of file