Tuesday, April 5, 2011

Public database setup

Database was setup, the connection string is:
Data Source=knotpedia.db.6221122.hostedresource.com; Initial Catalog=knotpedia; User ID=knotpedia; Password=Hexsoft2003;
If you want to setup the database in your own computer, you could download and setup Microsoft SQL Server 2005+ and management studio and execute following statement:
USE [master]
GO
/****** Object:  Database [Knot]    Script Date: 04/05/2011 20:21:11 ******/
CREATE DATABASE [Knot] ON  PRIMARY
( NAME = N'Knot', FILENAME = N'D:\Project\Knot\Database\Knot.mdf' , SIZE = 3072KB , MAXSIZE = UNLIMITED, FILEGROWTH = 1024KB )
 LOG ON
( NAME = N'Knot_log', FILENAME = N'D:\Project\Knot\Database\Knot_log.ldf' , SIZE = 1024KB , MAXSIZE = 2048GB , FILEGROWTH = 1024KB )
GO
ALTER DATABASE [Knot] SET COMPATIBILITY_LEVEL = 90
GO
IF (1 = FULLTEXTSERVICEPROPERTY('IsFullTextInstalled'))
begin
EXEC [Knot].[dbo].[sp_fulltext_database] @action = 'enable'
end
GO
ALTER DATABASE [Knot] SET ANSI_NULL_DEFAULT OFF
GO
ALTER DATABASE [Knot] SET ANSI_NULLS OFF
GO
ALTER DATABASE [Knot] SET ANSI_PADDING OFF
GO
ALTER DATABASE [Knot] SET ANSI_WARNINGS OFF
GO
ALTER DATABASE [Knot] SET ARITHABORT OFF
GO
ALTER DATABASE [Knot] SET AUTO_CLOSE ON
GO
ALTER DATABASE [Knot] SET AUTO_CREATE_STATISTICS ON
GO
ALTER DATABASE [Knot] SET AUTO_SHRINK OFF
GO
ALTER DATABASE [Knot] SET AUTO_UPDATE_STATISTICS ON
GO
ALTER DATABASE [Knot] SET CURSOR_CLOSE_ON_COMMIT OFF
GO
ALTER DATABASE [Knot] SET CURSOR_DEFAULT  GLOBAL
GO
ALTER DATABASE [Knot] SET CONCAT_NULL_YIELDS_NULL OFF
GO
ALTER DATABASE [Knot] SET NUMERIC_ROUNDABORT OFF
GO
ALTER DATABASE [Knot] SET QUOTED_IDENTIFIER OFF
GO
ALTER DATABASE [Knot] SET RECURSIVE_TRIGGERS OFF
GO
ALTER DATABASE [Knot] SET  DISABLE_BROKER
GO
ALTER DATABASE [Knot] SET AUTO_UPDATE_STATISTICS_ASYNC OFF
GO
ALTER DATABASE [Knot] SET DATE_CORRELATION_OPTIMIZATION OFF
GO
ALTER DATABASE [Knot] SET TRUSTWORTHY OFF
GO
ALTER DATABASE [Knot] SET ALLOW_SNAPSHOT_ISOLATION OFF
GO
ALTER DATABASE [Knot] SET PARAMETERIZATION SIMPLE
GO
ALTER DATABASE [Knot] SET READ_COMMITTED_SNAPSHOT OFF
GO
ALTER DATABASE [Knot] SET HONOR_BROKER_PRIORITY OFF
GO
ALTER DATABASE [Knot] SET  READ_WRITE
GO
ALTER DATABASE [Knot] SET RECOVERY SIMPLE
GO
ALTER DATABASE [Knot] SET  MULTI_USER
GO
ALTER DATABASE [Knot] SET PAGE_VERIFY CHECKSUM
GO
ALTER DATABASE [Knot] SET DB_CHAINING OFF
GO
USE [Knot]
GO
/****** Object:  Table [dbo].[Knot]    Script Date: 04/05/2011 20:21:12 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Knot](
    [Id] [uniqueidentifier] NOT NULL,
    [Name] [nvarchar](50) NOT NULL,
    [Description] [nvarchar](4000) NOT NULL,
 CONSTRAINT [PK_Knot] PRIMARY KEY CLUSTERED
(
    [Id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[Fixture]    Script Date: 04/05/2011 20:21:12 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Fixture](
    [Id] [uniqueidentifier] NOT NULL,
    [Material] [int] NOT NULL,
    [Knot] [uniqueidentifier] NOT NULL,
 CONSTRAINT [PK_Fixture] PRIMARY KEY CLUSTERED
(
    [Id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[Line]    Script Date: 04/05/2011 20:21:12 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Line](
    [Id] [uniqueidentifier] NOT NULL,
    [Material] [int] NOT NULL,
    [Knot] [uniqueidentifier] NOT NULL,
 CONSTRAINT [PK_Line] PRIMARY KEY CLUSTERED
(
    [Id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  StoredProcedure [dbo].[KnotUpdate]    Script Date: 04/05/2011 20:21:13 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[KnotUpdate]
    @Id uniqueidentifier,
    @Name nvarchar(50),
    @Description nvarchar(4000)
AS
UPDATE
    [Knot]
SET
    [Knot].[Name] = @Name,
    [Knot].[Description] = @Description
WHERE
    [Knot].[Id] = @Id
GO
/****** Object:  StoredProcedure [dbo].[KnotRemove]    Script Date: 04/05/2011 20:21:13 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[KnotRemove]
    @Id uniqueidentifier
AS
DELETE
    [Knot]
WHERE
    [Knot].[Id] = @Id
GO
/****** Object:  StoredProcedure [dbo].[KnotGetAll]    Script Date: 04/05/2011 20:21:13 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[KnotGetAll]
AS
SELECT
    [Knot].[Id],
    [Knot].[Name],
    [Knot].[Description]
FROM
    [Knot]
GO
/****** Object:  StoredProcedure [dbo].[KnotGet]    Script Date: 04/05/2011 20:21:13 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[KnotGet]
    @Id uniqueidentifier
AS
SELECT
    [Knot].[Id],
    [Knot].[Name],
    [Knot].[Description]
FROM
    [Knot]
WHERE
    [Knot].[Id] = @Id
GO
/****** Object:  StoredProcedure [dbo].[KnotAdd]    Script Date: 04/05/2011 20:21:13 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[KnotAdd]
    @Id uniqueidentifier,
    @Name nvarchar(50),
    @Description nvarchar(4000)
AS
INSERT
    [Knot]
VALUES (
    @Id,
    @Name,
    @Description
)
GO
/****** Object:  StoredProcedure [dbo].[FixtureUpdate]    Script Date: 04/05/2011 20:21:13 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[FixtureUpdate]
    @Id uniqueidentifier,
    @Material int,
    @Knot uniqueidentifier
AS
UPDATE
    [Fixture]
SET
    [Fixture].[Material] = @Material,
    [Fixture].[Knot] = @Knot
WHERE
    [Fixture].[Id] = @Id
GO
/****** Object:  StoredProcedure [dbo].[FixtureRemoveByKnot]    Script Date: 04/05/2011 20:21:13 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[FixtureRemoveByKnot]
    @Knot uniqueidentifier
AS
DELETE
    [Fixture]
WHERE
    [Fixture].[Knot] = @Knot
GO
/****** Object:  StoredProcedure [dbo].[FixtureRemove]    Script Date: 04/05/2011 20:21:13 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[FixtureRemove]
    @Id uniqueidentifier
AS
DELETE
    [Fixture]
WHERE
    [Fixture].[Id] = @Id
GO
/****** Object:  StoredProcedure [dbo].[FixtureGetByKnot]    Script Date: 04/05/2011 20:21:13 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[FixtureGetByKnot]
    @Knot uniqueidentifier
AS
SELECT
    [Fixture].[Id],
    [Fixture].[Material]
FROM
    [Fixture]
WHERE
    [Fixture].[Knot] = @Knot
GO
/****** Object:  StoredProcedure [dbo].[FixtureGetAll]    Script Date: 04/05/2011 20:21:13 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[FixtureGetAll]
AS
SELECT
    [Fixture].[Id],
    [Fixture].[Material],
    [FixtureKnot].[Id],
    [FixtureKnot].[Name],
    [FixtureKnot].[Description]
FROM
    [Fixture]
    JOIN [Knot] AS [FixtureKnot] ON [Fixture].[Knot] = [FixtureKnot].[Id]
GO
/****** Object:  StoredProcedure [dbo].[FixtureGet]    Script Date: 04/05/2011 20:21:13 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[FixtureGet]
    @Id uniqueidentifier
AS
SELECT
    [Fixture].[Id],
    [Fixture].[Material],
    [FixtureKnot].[Id],
    [FixtureKnot].[Name],
    [FixtureKnot].[Description]
FROM
    [Fixture]
    JOIN [Knot] AS [FixtureKnot] ON [Fixture].[Knot] = [FixtureKnot].[Id]
WHERE
    [Fixture].[Id] = @Id
GO
/****** Object:  StoredProcedure [dbo].[FixtureAdd]    Script Date: 04/05/2011 20:21:13 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[FixtureAdd]
    @Id uniqueidentifier,
    @Material int,
    @Knot uniqueidentifier
AS
INSERT
    [Fixture]
VALUES (
    @Id,
    @Material,
    @Knot
)
GO
/****** Object:  Table [dbo].[Step]    Script Date: 04/05/2011 20:21:13 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Step](
    [Id] [uniqueidentifier] NOT NULL,
    [Description] [nvarchar](4000) NOT NULL,
    [Line] [uniqueidentifier] NOT NULL,
 CONSTRAINT [PK_Step] PRIMARY KEY CLUSTERED
(
    [Id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  StoredProcedure [dbo].[LineUpdate]    Script Date: 04/05/2011 20:21:13 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[LineUpdate]
    @Id uniqueidentifier,
    @Material int,
    @Knot uniqueidentifier
AS
UPDATE
    [Line]
SET
    [Line].[Material] = @Material,
    [Line].[Knot] = @Knot
WHERE
    [Line].[Id] = @Id
GO
/****** Object:  StoredProcedure [dbo].[LineRemoveByKnot]    Script Date: 04/05/2011 20:21:13 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[LineRemoveByKnot]
    @Knot uniqueidentifier
AS
DELETE
    [Line]
WHERE
    [Line].[Knot] = @Knot
GO
/****** Object:  StoredProcedure [dbo].[LineRemove]    Script Date: 04/05/2011 20:21:13 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[LineRemove]
    @Id uniqueidentifier
AS
DELETE
    [Line]
WHERE
    [Line].[Id] = @Id
GO
/****** Object:  StoredProcedure [dbo].[LineGetByKnot]    Script Date: 04/05/2011 20:21:13 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[LineGetByKnot]
    @Knot uniqueidentifier
AS
SELECT
    [Line].[Id],
    [Line].[Material]
FROM
    [Line]
WHERE
    [Line].[Knot] = @Knot
GO
/****** Object:  StoredProcedure [dbo].[LineGetAll]    Script Date: 04/05/2011 20:21:13 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[LineGetAll]
AS
SELECT
    [Line].[Id],
    [Line].[Material],
    [LineKnot].[Id],
    [LineKnot].[Name],
    [LineKnot].[Description]
FROM
    [Line]
    JOIN [Knot] AS [LineKnot] ON [Line].[Knot] = [LineKnot].[Id]
GO
/****** Object:  StoredProcedure [dbo].[LineGet]    Script Date: 04/05/2011 20:21:13 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[LineGet]
    @Id uniqueidentifier
AS
SELECT
    [Line].[Id],
    [Line].[Material],
    [LineKnot].[Id],
    [LineKnot].[Name],
    [LineKnot].[Description]
FROM
    [Line]
    JOIN [Knot] AS [LineKnot] ON [Line].[Knot] = [LineKnot].[Id]
WHERE
    [Line].[Id] = @Id
GO
/****** Object:  StoredProcedure [dbo].[LineAdd]    Script Date: 04/05/2011 20:21:13 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[LineAdd]
    @Id uniqueidentifier,
    @Material int,
    @Knot uniqueidentifier
AS
INSERT
    [Line]
VALUES (
    @Id,
    @Material,
    @Knot
)
GO
/****** Object:  StoredProcedure [dbo].[StepUpdate]    Script Date: 04/05/2011 20:21:13 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[StepUpdate]
    @Id uniqueidentifier,
    @Description nvarchar(4000),
    @Line uniqueidentifier
AS
UPDATE
    [Step]
SET
    [Step].[Description] = @Description,
    [Step].[Line] = @Line
WHERE
    [Step].[Id] = @Id
GO
/****** Object:  StoredProcedure [dbo].[StepRemoveByLine]    Script Date: 04/05/2011 20:21:13 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[StepRemoveByLine]
    @Line uniqueidentifier
AS
DELETE
    [Step]
WHERE
    [Step].[Line] = @Line
GO
/****** Object:  StoredProcedure [dbo].[StepRemove]    Script Date: 04/05/2011 20:21:13 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[StepRemove]
    @Id uniqueidentifier
AS
DELETE
    [Step]
WHERE
    [Step].[Id] = @Id
GO
/****** Object:  StoredProcedure [dbo].[StepGetByLine]    Script Date: 04/05/2011 20:21:13 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[StepGetByLine]
    @Line uniqueidentifier
AS
SELECT
    [Step].[Id],
    [Step].[Description]
FROM
    [Step]
WHERE
    [Step].[Line] = @Line
GO
/****** Object:  StoredProcedure [dbo].[StepGetAll]    Script Date: 04/05/2011 20:21:13 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[StepGetAll]
AS
SELECT
    [Step].[Id],
    [Step].[Description],
    [StepLine].[Id],
    [StepLine].[Material],
    [StepLineKnot].[Id],
    [StepLineKnot].[Name],
    [StepLineKnot].[Description]
FROM
    [Step]
    JOIN [Line] AS [StepLine] ON [Step].[Line] = [StepLine].[Id]
    JOIN [Knot] AS [StepLineKnot] ON [StepLine].[Knot] = [StepLineKnot].[Id]
GO
/****** Object:  StoredProcedure [dbo].[StepGet]    Script Date: 04/05/2011 20:21:13 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[StepGet]
    @Id uniqueidentifier
AS
SELECT
    [Step].[Id],
    [Step].[Description],
    [StepLine].[Id],
    [StepLine].[Material],
    [StepLineKnot].[Id],
    [StepLineKnot].[Name],
    [StepLineKnot].[Description]
FROM
    [Step]
    JOIN [Line] AS [StepLine] ON [Step].[Line] = [StepLine].[Id]
    JOIN [Knot] AS [StepLineKnot] ON [StepLine].[Knot] = [StepLineKnot].[Id]
WHERE
    [Step].[Id] = @Id
GO
/****** Object:  StoredProcedure [dbo].[StepAdd]    Script Date: 04/05/2011 20:21:13 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[StepAdd]
    @Id uniqueidentifier,
    @Description nvarchar(4000),
    @Line uniqueidentifier
AS
INSERT
    [Step]
VALUES (
    @Id,
    @Description,
    @Line
)
GO
/****** Object:  Table [dbo].[Point]    Script Date: 04/05/2011 20:21:13 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Point](
    [Id] [uniqueidentifier] NOT NULL,
    [X] [real] NOT NULL,
    [Y] [real] NOT NULL,
    [Z] [real] NOT NULL,
    [Step] [uniqueidentifier] NOT NULL,
 CONSTRAINT [PK_Point] PRIMARY KEY CLUSTERED
(
    [Id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  StoredProcedure [dbo].[PointUpdate]    Script Date: 04/05/2011 20:21:13 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[PointUpdate]
    @Id uniqueidentifier,
    @X real,
    @Y real,
    @Z real,
    @Step uniqueidentifier
AS
UPDATE
    [Point]
SET
    [Point].[X] = @X,
    [Point].[Y] = @Y,
    [Point].[Z] = @Z,
    [Point].[Step] = @Step
WHERE
    [Point].[Id] = @Id
GO
/****** Object:  StoredProcedure [dbo].[PointRemoveByStep]    Script Date: 04/05/2011 20:21:13 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[PointRemoveByStep]
    @Step uniqueidentifier
AS
DELETE
    [Point]
WHERE
    [Point].[Step] = @Step
GO
/****** Object:  StoredProcedure [dbo].[PointRemove]    Script Date: 04/05/2011 20:21:13 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[PointRemove]
    @Id uniqueidentifier
AS
DELETE
    [Point]
WHERE
    [Point].[Id] = @Id
GO
/****** Object:  StoredProcedure [dbo].[PointGetByStep]    Script Date: 04/05/2011 20:21:13 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[PointGetByStep]
    @Step uniqueidentifier
AS
SELECT
    [Point].[Id],
    [Point].[X],
    [Point].[Y],
    [Point].[Z]
FROM
    [Point]
WHERE
    [Point].[Step] = @Step
GO
/****** Object:  StoredProcedure [dbo].[PointGetAll]    Script Date: 04/05/2011 20:21:13 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[PointGetAll]
AS
SELECT
    [Point].[Id],
    [Point].[X],
    [Point].[Y],
    [Point].[Z],
    [PointStep].[Id],
    [PointStep].[Description],
    [PointStepLine].[Id],
    [PointStepLine].[Material],
    [PointStepLineKnot].[Id],
    [PointStepLineKnot].[Name],
    [PointStepLineKnot].[Description]
FROM
    [Point]
    JOIN [Step] AS [PointStep] ON [Point].[Step] = [PointStep].[Id]
    JOIN [Line] AS [PointStepLine] ON [PointStep].[Line] = [PointStepLine].[Id]
    JOIN [Knot] AS [PointStepLineKnot] ON [PointStepLine].[Knot] = [PointStepLineKnot].[Id]
GO
/****** Object:  StoredProcedure [dbo].[PointGet]    Script Date: 04/05/2011 20:21:13 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[PointGet]
    @Id uniqueidentifier
AS
SELECT
    [Point].[Id],
    [Point].[X],
    [Point].[Y],
    [Point].[Z],
    [PointStep].[Id],
    [PointStep].[Description],
    [PointStepLine].[Id],
    [PointStepLine].[Material],
    [PointStepLineKnot].[Id],
    [PointStepLineKnot].[Name],
    [PointStepLineKnot].[Description]
FROM
    [Point]
    JOIN [Step] AS [PointStep] ON [Point].[Step] = [PointStep].[Id]
    JOIN [Line] AS [PointStepLine] ON [PointStep].[Line] = [PointStepLine].[Id]
    JOIN [Knot] AS [PointStepLineKnot] ON [PointStepLine].[Knot] = [PointStepLineKnot].[Id]
WHERE
    [Point].[Id] = @Id
GO
/****** Object:  StoredProcedure [dbo].[PointAdd]    Script Date: 04/05/2011 20:21:13 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[PointAdd]
    @Id uniqueidentifier,
    @X real,
    @Y real,
    @Z real,
    @Step uniqueidentifier
AS
INSERT
    [Point]
VALUES (
    @Id,
    @X,
    @Y,
    @Z,
    @Step
)
GO
/****** Object:  ForeignKey [FK_Fixture_Knot]    Script Date: 04/05/2011 20:21:12 ******/
ALTER TABLE [dbo].[Fixture]  WITH CHECK ADD  CONSTRAINT [FK_Fixture_Knot] FOREIGN KEY([Knot])
REFERENCES [dbo].[Knot] ([Id])
GO
ALTER TABLE [dbo].[Fixture] CHECK CONSTRAINT [FK_Fixture_Knot]
GO
/****** Object:  ForeignKey [FK_Line_Knot]    Script Date: 04/05/2011 20:21:12 ******/
ALTER TABLE [dbo].[Line]  WITH CHECK ADD  CONSTRAINT [FK_Line_Knot] FOREIGN KEY([Knot])
REFERENCES [dbo].[Knot] ([Id])
GO
ALTER TABLE [dbo].[Line] CHECK CONSTRAINT [FK_Line_Knot]
GO
/****** Object:  ForeignKey [FK_Step_Line]    Script Date: 04/05/2011 20:21:13 ******/
ALTER TABLE [dbo].[Step]  WITH CHECK ADD  CONSTRAINT [FK_Step_Line] FOREIGN KEY([Line])
REFERENCES [dbo].[Line] ([Id])
GO
ALTER TABLE [dbo].[Step] CHECK CONSTRAINT [FK_Step_Line]
GO
/****** Object:  ForeignKey [FK_Point_Step]    Script Date: 04/05/2011 20:21:13 ******/
ALTER TABLE [dbo].[Point]  WITH CHECK ADD  CONSTRAINT [FK_Point_Step] FOREIGN KEY([Step])
REFERENCES [dbo].[Step] ([Id])
GO
ALTER TABLE [dbo].[Point] CHECK CONSTRAINT [FK_Point_Step]
GO

Interface Manual

The Model has 7 important signatures: 4 member functions and 3 static functions of KnotModel class.
public KnotModel(): Initializes the knot model.
public void Add(): Add the knot instance into database.
public void Update(): Update the knot instance into database.
public void Save(string filename): Saves the knot into XML file.
public static List<KnotModel> GetAll(): Gets the all knot list from database.
public static KnotModel GetById(Guid id): Gets the knot by specified ID from database.
public static KnotModel Load(string filename): Loads knot form XML file.
Most people confuse different between Entity and Model, anybody knows different between memory and storage? that it! they design in different purpose. Entity use to persistent with database, however, Model use to represent business unit. One is storage oriented, another is business oriented.
One knot contains a lot of objects and lines(?), one line contains a lot of step and one step contain a lot of point. That logic is make sense, but Entity is not, isn't it.

Entity package

This is the final design of Entity, I and Jun decided to remove some useless function such as user as well as comment. Consequently, there are only 5 classes left, which are persistent 5 table in database.
Knot represent the knot entries in database, Fixture represent the objects such as tree, hook or loop for specified knot. Line represent the strings for specified knot, one knot has one, may be two(or more?) strings. Step represent the status or snapshot for particular string, the core functionality is show the steps of knot. Point store the sequence of point for particular step of line.

Architecture

Our system use EMVC architecture. Different between form MVC, I add a entity package which use to president with database table and data access. It is the common way to expend database stuff into MVC architecture.
Unfortunately, the code in final version do not really separate the Controller with View, which lose the testability of user interface(in MVC's purpose, Controller is testable), but anyway, Model is separated, so Model is testable and the unit test is finish.

Thursday, October 21, 2010

Data Access Prototype Description

Hexsoft.Knots.DataAccess.PointData
Represent the point data access.
Methods:
  • Add(System.Guid,System.Int32,System.Int32,System.Int32,System.Int32)
    Add the point.
    Parameters:
    • id: The id of the point.
    • line: The line of the point.
    • x: The x of the point.
    • y: The y of the point.
    • z: The z of the point.
  • Set(System.Guid,System.Int32,System.Int32,System.Int32,System.Int32)
    Set the point.
    Parameters:
    • id: The id of the point.
    • line: The line of the point.
    • x: The x of the point.
    • y: The y of the point.
    • z: The z of the point.
  • Remove(System.Guid)
    Remove the point.
    Parameters:
    • id: The id of the point.
  • GetById(System.Guid)
    Get the point by id.
    Parameters:
    • id: The id of the point.
    Returns:
    • The point entity.
  • GetAll()
    Get all the points.
    Returns:
    • The Point entities.
Hexsoft.Knots.DataAccess.UserData
Represent the user data access.
Methods:
  • Add(System.Guid,System.String,System.String,System.String)
    Add the user.
    Parameters:
    • id: The id of the user.
    • name: The name of the user.
    • email: The email of the user.
    • password: The password of the user.
  • Set(System.Guid,System.String,System.String,System.String)
    Set the user.
    Parameters:
    • id: The id of the user.
    • name: The name of the user.
    • email: The email of the user.
    • password: The password of the user.
  • Remove(System.Guid)
    Remove the user.
    Parameters:
    • id: The id of the user.
  • GetById(System.Guid)
    Get the user by id.
    Parameters:
    • id: The id of the user.
    Returns:
    • The user entity.
  • GetAll()
    Get all the users.
    Returns:
    • The User entities.
Hexsoft.Knots.DataAccess.StepData
Represent the step data access.
Methods:
  • Add(System.Guid,System.String,System.String,System.Guid)
    Add the step.
    Parameters:
    • id: The id of the step.
    • type: The type of the step.
    • description: The description of the step.
    • knot: The knot of the step.
  • Set(System.Guid,System.String,System.String,System.Guid)
    Set the step.
    Parameters:
    • id: The id of the step.
    • type: The type of the step.
    • description: The description of the step.
    • knot: The knot of the step.
  • Remove(System.Guid)
    Remove the step.
    Parameters:
    • id: The id of the step.
  • RemoveByKnot(System.Guid)
    Remove the step by knot.
    Parameters:
    • knot: The knot of the step.
  • GetById(System.Guid)
    Get the step by id.
    Parameters:
    • id: The id of the step.
    Returns:
    • The step entity.
  • GetAll()
    Get all the steps.
    Returns:
    • The Step entities.
  • GetByKnot(System.Guid)
    Get the steps by knot.
    Parameters:
    • knot: The knot of the step.
    Returns:
    • The step entities.
Hexsoft.Knots.DataAccess.KnotData
Represent the knot data access.
Methods:
  • Add(System.Guid,System.String,System.String,System.Guid)
    Add the knot.
    Parameters:
    • id: The id of the knot.
    • name: The name of the knot.
    • description: The description of the knot.
    • user: The user of the knot.
  • Set(System.Guid,System.String,System.String,System.Guid)
    Set the knot.
    Parameters:
    • id: The id of the knot.
    • name: The name of the knot.
    • description: The description of the knot.
    • user: The user of the knot.
  • Remove(System.Guid)
    Remove the knot.
    Parameters:
    • id: The id of the knot.
  • RemoveByUser(System.Guid)
    Remove the knot by user.
    Parameters:
    • user: The user of the knot.
  • GetById(System.Guid)
    Get the knot by id.
    Parameters:
    • id: The id of the knot.
    Returns:
    • The knot entity.
  • GetAll()
    Get all the knots.
    Returns:
    • The Knot entities.
  • GetByUser(System.Guid)
    Get the knots by user.
    Parameters:
    • user: The user of the knot.
    Returns:
    • The knot entities.
Hexsoft.Knots.DataAccess.ClassificationData
Represent the classification data access.
Methods:
  • Add(System.Guid,System.Guid)
    Add the classification.
    Parameters:
    • knot: The knot of the classification.
    • category: The category of the classification.
  • Remove(System.Guid,System.Guid)
    Remove the classification.
    Parameters:
    • knot: The knot of the classification.
    • category: The category of the classification.
  • RemoveByKnot(System.Guid)
    Remove the classification by knot.
    Parameters:
    • knot: The knot of the classification.
  • RemoveByCategory(System.Guid)
    Remove the classification by category.
    Parameters:
    • category: The category of the classification.
  • GetAll()
    Get all the classifications.
    Returns:
    • The Classification entities.
  • GetByKnot(System.Guid)
    Get the classifications by knot.
    Parameters:
    • knot: The knot of the classification.
    Returns:
    • The classification entities.
  • GetByCategory(System.Guid)
    Get the classifications by category.
    Parameters:
    • category: The category of the classification.
    Returns:
    • The classification entities.
Hexsoft.Knots.DataAccess.LineData
Represent the line data access.
Methods:
  • Add(System.Guid,System.Guid,System.Int32)
    Add the line.
    Parameters:
    • id: The id of the object.
    • knot: The knot of the object.
    • material: The material of the line.
  • Set(System.Guid,System.Guid,System.Int32)
    Set the line.
    Parameters:
    • id: The id of the object.
    • knot: The knot of the object.
    • material: The material of the line.
  • Remove(System.Guid)
    Remove the line.
    Parameters:
    • id: The id of the line.
  • RemoveByKnot(System.Guid)
    Remove the line by knot.
    Parameters:
    • knot: The knot of the line.
  • GetById(System.Guid)
    Get the line by id.
    Parameters:
    • id: The id of the line.
    Returns:
    • The line entity.
  • GetAll()
    Get all the lines.
    Returns:
    • The Line entities.
  • GetByKnot(System.Guid)
    Get the lines by knot.
    Parameters:
    • knot: The knot of the line.
    Returns:
    • The line entities.
Hexsoft.Knots.DataAccess.CategoryData
Represent the category data access.
Methods:
  • Add(System.Guid,System.String)
    Add the category.
    Parameters:
    • id: The id of the category.
    • name: The name of the category.
  • Set(System.Guid,System.String)
    Set the category.
    Parameters:
    • id: The id of the category.
    • name: The name of the category.
  • Remove(System.Guid)
    Remove the category.
    Parameters:
    • id: The id of the category.
  • GetById(System.Guid)
    Get the category by id.
    Parameters:
    • id: The id of the category.
    Returns:
    • The category entity.
  • GetAll()
    Get all the categorys.
    Returns:
    • The Category entities.
Hexsoft.Knots.DataAccess.FixtureData
Represent the fixture data access.
Methods:
  • Add(System.Guid,System.Guid,System.Int32)
    Add the fixture.
    Parameters:
    • id: The id of the object.
    • knot: The knot of the object.
    • number: The number of the fixture.
  • Set(System.Guid,System.Guid,System.Int32)
    Set the fixture.
    Parameters:
    • id: The id of the object.
    • knot: The knot of the object.
    • number: The number of the fixture.
  • Remove(System.Guid)
    Remove the fixture.
    Parameters:
    • id: The id of the fixture.
  • RemoveByKnot(System.Guid)
    Remove the fixture by knot.
    Parameters:
    • knot: The knot of the fixture.
  • GetById(System.Guid)
    Get the fixture by id.
    Parameters:
    • id: The id of the fixture.
    Returns:
    • The fixture entity.
  • GetAll()
    Get all the fixtures.
    Returns:
    • The Fixture entities.
  • GetByKnot(System.Guid)
    Get the fixtures by knot.
    Parameters:
    • knot: The knot of the fixture.
    Returns:
    • The fixture entities.
Hexsoft.Knots.DataAccess.ObjectData
Represent the object data access.
Methods:
  • Add(System.Guid,System.Guid)
    Add the object.
    Parameters:
    • id: The id of the object.
    • knot: The knot of the object.
  • Set(System.Guid,System.Guid)
    Set the object.
    Parameters:
    • id: The id of the object.
    • knot: The knot of the object.
  • Remove(System.Guid)
    Remove the object.
    Parameters:
    • id: The id of the object.
  • RemoveByKnot(System.Guid)
    Remove the object by knot.
    Parameters:
    • knot: The knot of the object.
  • GetById(System.Guid)
    Get the object by id.
    Parameters:
    • id: The id of the object.
    Returns:
    • The object entity.
  • GetAll()
    Get all the objects.
    Returns:
    • The Object entities.
  • GetByKnot(System.Guid)
    Get the objects by knot.
    Parameters:
    • knot: The knot of the object.
    Returns:
    • The object entities.

Entity Prototype Description

Hexsoft.Knots.Entity.Object
Represent the object entity.
Properties:
  • Id
    Get or set the id of the object.
  • Knot
    Get or set the knot of the object.
Methods:
  • #ctor(System.Guid,Hexsoft.Knots.Entity.Knot)
    Initialize the object entity.
    Parameters:
    • id: The id of the object.
    • knot: The knot of the object.
Hexsoft.Knots.Entity.User
Represent the user entity.
Properties:
  • Id
    Get or set the id of the user.
  • Name
    Get or set the name of the user.
  • Email
    Get or set the email of the user.
  • Password
    Get or set the password of the user.
Methods:
  • #ctor(System.Guid,System.String,System.String,System.String)
    Initialize the user entity.
    Parameters:
    • id: The id of the user.
    • name: The name of the user.
    • email: The email of the user.
    • password: The password of the user.
Hexsoft.Knots.Entity.Step
Represent the step entity.
Properties:
  • Id
    Get or set the id of the step.
  • Type
    Get or set the type of the step.
  • Description
    Get or set the description of the step.
  • Knot
    Get or set the knot of the step.
Methods:
  • #ctor(System.Guid,System.String,System.String,Hexsoft.Knots.Entity.Knot)
    Initialize the step entity.
    Parameters:
    • id: The id of the step.
    • type: The type of the step.
    • description: The description of the step.
    • knot: The knot of the step.
Hexsoft.Knots.Entity.Category
Represent the category entity.
Properties:
  • Id
    Get or set the id of the category.
  • Name
    Get or set the name of the category.
Methods:
  • #ctor(System.Guid,System.String)
    Initialize the category entity.
    Parameters:
    • id: The id of the category.
    • name: The name of the category.
Hexsoft.Knots.Entity.Knot
Represent the knot entity.
Properties:
  • Id
    Get or set the id of the knot.
  • Name
    Get or set the name of the knot.
  • Description
    Get or set the description of the knot.
  • User
    Get or set the user of the knot.
Methods:
  • #ctor(System.Guid,System.String,System.String,Hexsoft.Knots.Entity.User)
    Initialize the knot entity.
    Parameters:
    • id: The id of the knot.
    • name: The name of the knot.
    • description: The description of the knot.
    • user: The user of the knot.
Hexsoft.Knots.Entity.Fixture
Represent the fixture entity.
Properties:
  • Number
    Get or set the number of the fixture.
Methods:
  • #ctor(System.Guid,Hexsoft.Knots.Entity.Knot,System.Int32)
    Initialize the fixture entity.
    Parameters:
    • id: The id of the object.
    • knot: The knot of the object.
    • number: The number of the fixture.
Hexsoft.Knots.Entity.Line
Represent the line entity.
Properties:
  • Material
    Get or set the material of the line.
Methods:
  • #ctor(System.Guid,Hexsoft.Knots.Entity.Knot,System.Int32)
    Initialize the line entity.
    Parameters:
    • id: The id of the object.
    • knot: The knot of the object.
    • material: The material of the line.
Hexsoft.Knots.Entity.Point
Represent the point entity.
Properties:
  • Id
    Get or set the id of the point.
  • Line
    Get or set the line of the point.
  • X
    Get or set the x of the point.
  • Y
    Get or set the y of the point.
  • Z
    Get or set the z of the point.
Methods:
  • #ctor(System.Guid,System.Int32,System.Int32,System.Int32,System.Int32)
    Initialize the point entity.
    Parameters:
    • id: The id of the point.
    • line: The line of the point.
    • x: The x of the point.
    • y: The y of the point.
    • z: The z of the point.
Hexsoft.Knots.Entity.Classification
Represent the classification entity.
Properties:
  • Knot
    Get or set the knot of the classification.
  • Category
    Get or set the category of the classification.
Methods:
  • #ctor(Hexsoft.Knots.Entity.Knot,Hexsoft.Knots.Entity.Category)
    Initialize the classification entity.
    Parameters:
    • knot: The knot of the classification.
    • category: The category of the classification.