Small modifications made to the SQL template script in preparation for the Entity Framework update.
This commit is contained in:
@@ -8,98 +8,26 @@
|
||||
CREATE DATABASE AdvertisingProfitControl
|
||||
|
||||
--Begin creating the tables for the database.
|
||||
CREATE TABLE ActualSales
|
||||
CREATE TABLE WeekEndingDates
|
||||
(
|
||||
Id INTEGER NOT NULL PRIMARY KEY,
|
||||
--Sold and sale price need to be stored as a string since they need to support # Bin(s)
|
||||
--and $#.##/# formatting respectively.
|
||||
Sold VARCHAR(128),
|
||||
SalePrice VARCHAR(128),
|
||||
--Might be over kill to store money like this but better safe then sorry.
|
||||
TotalSales DECIMAL(19,2),
|
||||
Cost DECIMAL(19,2),
|
||||
ProfitReturn DECIMAL(19,2),
|
||||
TotalProfitReturn DECIMAL(19,2),
|
||||
--The attributes of the row can not be null, and neither can the foreign keys.
|
||||
RowPosition INTEGER NOT NULL,
|
||||
--A precision of two digits should be everything we need for the row attribute.
|
||||
RowAttribute INTEGER NOT NULL,
|
||||
--Now begin all the foreign keys.
|
||||
FkAdItemId INTEGER NOT NULL,
|
||||
FkAdSpecialGoupId INTEGER NOT NULL,
|
||||
FkDateId INTEGER NOT NULL
|
||||
WeekEndingDate DATE NOT NULL --A date is required to be entered.
|
||||
)
|
||||
|
||||
CREATE TABLE AdItem
|
||||
CREATE TABLE AdItems
|
||||
(
|
||||
Id INTEGER NOT NULL PRIMARY KEY,
|
||||
AdItem VARCHAR(255) NOT NULL,
|
||||
Description VARCHAR(255) --Optional field may be used later one.
|
||||
)
|
||||
|
||||
CREATE TABLE AdSpecial
|
||||
CREATE TABLE AdSpecials
|
||||
(
|
||||
Id INTEGER NOT NULL PRIMARY KEY,
|
||||
AdSpecial VARCHAR(255) NOT NULL,
|
||||
Description VARCHAR(255) --Optional field may be used later one, most likely in a tool tip.
|
||||
)
|
||||
|
||||
CREATE TABLE Note --Comment is a reserved word so the table and column had to be renamed to "Note" instead.
|
||||
(
|
||||
Id INTEGER NOT NULL PRIMARY KEY,
|
||||
--The current version (1.0.0.0) only allows the user to enter a max of 256 characters into the comments box.
|
||||
Note VARCHAR(256) NOT NULL,
|
||||
FkDateId INTEGER NOT NULL
|
||||
)
|
||||
|
||||
CREATE TABLE CostAnalysis
|
||||
(
|
||||
Id INTEGER NOT NULL PRIMARY KEY,
|
||||
SalesPerManHour DECIMAL(19,2),
|
||||
--Allows percentages between %1000.00 (10,000 percent) and %0.12356.
|
||||
SalaryPercentage DECIMAL(6,2), --The percentage of the manager's salary that was made on this week's sale items.
|
||||
SalaryDollar DECIMAL(19,2), --
|
||||
Supplies DECIMAL(19,2) --Total of costs from invoices (?).
|
||||
)
|
||||
|
||||
CREATE TABLE Holiday
|
||||
(
|
||||
Id INTEGER NOT NULL PRIMARY KEY,
|
||||
Holiday VARCHAR(64) NOT NULL
|
||||
)
|
||||
|
||||
CREATE TABLE Inventory
|
||||
(
|
||||
Id INTEGER NOT NULL PRIMARY KEY,
|
||||
--All values minus the primary key and foreign keys are set as strings to allow
|
||||
--specifying the number of bins of product are present.
|
||||
BeginningInventory VARCHAR(255),
|
||||
Recieved VARCHAR(255),
|
||||
TotalInventory VARCHAR(255),
|
||||
EndingInventory VARCHAR(255),
|
||||
--The attributes of the row can not be null, and neither can the foreign keys.
|
||||
RowPosition INTEGER NOT NULL,
|
||||
--A precision of two digits should be everything we need for the row attribute.
|
||||
RowAttribute INTEGER NOT NULL,
|
||||
--Now begin all the foreign keys.
|
||||
FkAdItemId INTEGER NOT NULL,
|
||||
FkAdSpecialGoupId INTEGER NOT NULL,
|
||||
FkDateId INTEGER NOT NULL
|
||||
)
|
||||
|
||||
CREATE TABLE Invoice
|
||||
(
|
||||
Id INTEGER NOT NULL PRIMARY KEY,
|
||||
InvoiceDate DATE NOT NULL,
|
||||
InvoiceNumber INTEGER NOT NULL,
|
||||
InvoiceNetAmountAtCost DECIMAL(19,2),
|
||||
InvoiceNetAmount DECIMAL(19,2),
|
||||
InvoiceNote VARCHAR(255),
|
||||
--Keys are never allowed to be null.
|
||||
FkSupplierId INTEGER NOT NULL,
|
||||
FkDateId INTEGER NOT NULL
|
||||
)
|
||||
|
||||
CREATE TABLE Projections
|
||||
(
|
||||
Id INTEGER NOT NULL PRIMARY KEY,
|
||||
@@ -115,45 +43,80 @@ TotalProfitReturn DECIMAL(19,2),
|
||||
--The attributes of the row can not be null, and neither can the foreign keys.
|
||||
RowPosition INTEGER NOT NULL,
|
||||
--A precision of two digits should be everything we need for the row attribute.
|
||||
RowAttribute INTEGER NOT NULL,
|
||||
RowAttribute INTEGER NOT NULL, --Rename to "HeaderId"? Point to the header group's ID number perhaps?
|
||||
--Now begin all the foreign keys.
|
||||
FkAdItemId INTEGER NOT NULL,
|
||||
FkAdSpecialGoupId INTEGER NOT NULL,
|
||||
FkDateId INTEGER NOT NULL
|
||||
FkAdItemId INTEGER FOREIGN KEY REFERENCES AdItems(Id),
|
||||
FkAdSpecialId INTEGER FOREIGN KEY REFERENCES AdSpecials(Id),
|
||||
FkDateId INTEGER FOREIGN KEY REFERENCES WeekEndingDates(Id)
|
||||
)
|
||||
|
||||
CREATE TABLE Supplier
|
||||
CREATE TABLE Inventory
|
||||
(
|
||||
Id INTEGER NOT NULL PRIMARY KEY,
|
||||
--All values minus the primary key and foreign keys are set as strings to allow
|
||||
--specifying the number of bins of product are present.
|
||||
BeginningInventory VARCHAR(255),
|
||||
Recieved VARCHAR(255),
|
||||
TotalInventory VARCHAR(255),
|
||||
EndingInventory VARCHAR(255),
|
||||
--The attributes of the row can not be null, and neither can the foreign keys.
|
||||
RowPosition INTEGER NOT NULL,
|
||||
--A precision of two digits should be everything we need for the row attribute.
|
||||
RowAttribute INTEGER NOT NULL, --Rename to "HeaderId"? Point to the header group's ID number perhaps?
|
||||
--Now begin all the foreign keys.
|
||||
FkAdItemId INTEGER FOREIGN KEY REFERENCES AdItems(Id),
|
||||
FkAdSpecialId INTEGER FOREIGN KEY REFERENCES AdSpecials(Id),
|
||||
FkDateId INTEGER FOREIGN KEY REFERENCES WeekEndingDates(Id)
|
||||
)
|
||||
|
||||
CREATE TABLE ActualSales
|
||||
(
|
||||
Id INTEGER NOT NULL PRIMARY KEY,
|
||||
--Sold and sale price need to be stored as a string since they need to support # Bin(s)
|
||||
--and $#.##/# formatting respectively.
|
||||
Sold VARCHAR(128),
|
||||
SalePrice VARCHAR(128),
|
||||
--Might be over kill to store money like this but better safe then sorry.
|
||||
TotalSales DECIMAL(19,2),
|
||||
Cost DECIMAL(19,2),
|
||||
ProfitReturn DECIMAL(19,2),
|
||||
TotalProfitReturn DECIMAL(19,2),
|
||||
--The attributes of the row can not be null, and neither can the foreign keys.
|
||||
RowPosition INTEGER NOT NULL,
|
||||
--A precision of two digits should be everything we need for the row attribute.
|
||||
RowAttribute INTEGER NOT NULL, --Rename to "HeaderId"? Point to the header group's ID number perhaps?
|
||||
--Now begin all the foreign keys.
|
||||
FkAdItemId INTEGER FOREIGN KEY REFERENCES AdItems(Id),
|
||||
FkAdSpecialId INTEGER FOREIGN KEY REFERENCES AdSpecials(Id),
|
||||
FkDateId INTEGER FOREIGN KEY REFERENCES WeekEndingDates(Id)
|
||||
)
|
||||
|
||||
CREATE TABLE Suppliers
|
||||
(
|
||||
Id INTEGER NOT NULL PRIMARY KEY,
|
||||
Supplier VARCHAR(255),
|
||||
Description VARCHAR(255) --Optional field may be used later one.
|
||||
)
|
||||
|
||||
CREATE TABLE Taxable
|
||||
CREATE TABLE Invoices
|
||||
(
|
||||
Id INTEGER NOT NULL PRIMARY KEY,
|
||||
Sunday DECIMAL(19,2),
|
||||
Monday DECIMAL(19,2),
|
||||
Tuesday DECIMAL(19,2),
|
||||
Wednesday DECIMAL(19,2),
|
||||
Thursday DECIMAL(19,2),
|
||||
Friday DECIMAL(19,2),
|
||||
Saturday DECIMAL(19,2),
|
||||
Total DECIMAL(19,2),
|
||||
InvoiceDate DATE NOT NULL,
|
||||
InvoiceNumber INTEGER NOT NULL,
|
||||
InvoiceNetAmountAtCost DECIMAL(19,2),
|
||||
InvoiceNetAmount DECIMAL(19,2),
|
||||
InvoiceNote VARCHAR(255),
|
||||
--Keys are never allowed to be null.
|
||||
FkDateId INTEGER NOT NULL
|
||||
FkSupplierId INTEGER FOREIGN KEY REFERENCES Suppliers(Id),
|
||||
FkDateId INTEGER FOREIGN KEY REFERENCES WeekEndingDates(Id)
|
||||
)
|
||||
|
||||
CREATE TABLE Version
|
||||
CREATE TABLE Notes --Comment is a reserved word so the table and column had to be renamed to "Note" instead.
|
||||
(
|
||||
Id INTEGER NOT NULL PRIMARY KEY,
|
||||
VersionNumber VARCHAR(64) --64 characters should be more then enough to store a version number.
|
||||
)
|
||||
|
||||
CREATE TABLE WeekEndingDate
|
||||
(
|
||||
Id INTEGER NOT NULL PRIMARY KEY,
|
||||
WeekEndingDate DATE NOT NULL --A date is required to be entered.
|
||||
--The current version (1.0.0.0) only allows the user to enter a max of 256 characters into the comments box.
|
||||
Note VARCHAR(256) NOT NULL,
|
||||
FkDateId INTEGER FOREIGN KEY REFERENCES WeekEndingDates(Id)
|
||||
)
|
||||
|
||||
CREATE TABLE WeeklySales
|
||||
@@ -168,5 +131,40 @@ Friday DECIMAL(19,2),
|
||||
Saturday DECIMAL(19,2),
|
||||
TotalSales DECIMAL(19,2),
|
||||
--Keys are never allowed to be null.
|
||||
FkDateId INTEGER NOT NULL
|
||||
FkDateId INTEGER FOREIGN KEY REFERENCES WeekEndingDates(Id)
|
||||
)
|
||||
|
||||
CREATE TABLE Taxable
|
||||
(
|
||||
Id INTEGER NOT NULL PRIMARY KEY,
|
||||
Sunday DECIMAL(19,2),
|
||||
Monday DECIMAL(19,2),
|
||||
Tuesday DECIMAL(19,2),
|
||||
Wednesday DECIMAL(19,2),
|
||||
Thursday DECIMAL(19,2),
|
||||
Friday DECIMAL(19,2),
|
||||
Saturday DECIMAL(19,2),
|
||||
Total DECIMAL(19,2),
|
||||
--Keys are never allowed to be null.
|
||||
FkDateId INTEGER FOREIGN KEY REFERENCES WeekEndingDates(Id)
|
||||
)
|
||||
|
||||
--This table contains items that didn't fit in the other tables.
|
||||
--Just little things that were on the back of the physical
|
||||
--advertising profit control sheet (the Weekly Inventory Control).
|
||||
CREATE TABLE CostAnalysis
|
||||
(
|
||||
Id INTEGER NOT NULL PRIMARY KEY,
|
||||
SalesPerManHour DECIMAL(19,2),
|
||||
--Allows percentages between %1000.00 (10,000 percent) and %0.1235.
|
||||
SalaryPercentage DECIMAL(6,2), --The percentage of the manager's salary that was made on this week's sale items.
|
||||
SalaryDollar DECIMAL(19,2), --
|
||||
Supplies DECIMAL(19,2), --Total of costs from invoices (?).
|
||||
FkDateId INTEGER FOREIGN KEY REFERENCES WeekEndingDates(Id)
|
||||
)
|
||||
|
||||
CREATE TABLE Version
|
||||
(
|
||||
Id INTEGER NOT NULL PRIMARY KEY,
|
||||
VersionNumber VARCHAR(32) --32 characters should be more then enough to store a version number.
|
||||
)
|
||||
Reference in New Issue
Block a user