Vous êtes sur la page 1sur 5

create database InventoryFebruary

use inventoryfebruary
create table CompanyReg
(
name varchar(50),
type varchar(50),
estb varchar(60),
representator char(50),
mobile numeric,
phone numeric,
address varchar(100),
state char(50),
country char(50),
id numeric identity primary key,
emailid varchar(60),
password varchar(60),
question varchar(100),
answer varchar(100),
signuptime datetime
)
create table CompanySignin
(
name varchar(50),
id numeric foreign key references companyreg(id),
emailid varchar(60),
password varchar(60),
status char(20) default 'valid',
)
create table comprecoverypass
(
id numeric ,
emailid varchar(60),
password varchar(60),
question varchar(100),
answer varchar(100)
add constraint fk(id)references compreg(id)
)
create trigger comptri on companyreg
for insert
as
declare @id numeric;
declare @emailid varchar(60);
declare @password varchar(60);
declare @question varchar(100);
declare @answer varchar(100);
select @id=u.id, @emailid=u.emailid, @password=u.password, @question=u.question,
@answer=u.answer from compreg u;
insert into comprecoverypass(u.emailid, u.password, u.question, u.answer ) value
s (@id, @emailid, @password, @question, @answer)

create trigger CompanyTrig on companyreg


for insert
as
declare @name varchar(50);
declare @id numeric;
declare @emailid varchar(60);

declare @password varchar(60);


select @name=c.name, @id=c.id, @emailid=c.emailid, @password=c.password from com
panyreg c;
insert into companysignin (c.name, c.id, c.emailid, c.password) values (@name, @
id, @emailid, @password)

select * from companyreg


insert into companyreg values('DI', 'IT', '2010', 'Varun Sinha', 9560639729, 011
9822, 'laxmi nagar', 'delhi', 'india', 'varun@gmail.com', 'varun@123', 'wats ur
niks name ?', 'monty', getdate())
select * from companysignin
create table userreg
(
firstname char(40),
lastname char(40),
dob varchar(50),
sex char(10),
mobile numeric,
address varchar(100),
state char(50),
country char(50),
id numeric identity primary key,
userid varchar(50),
emailid varchar(60),
password varchar(60),
quesption varchar(100),
answer varchar(50),
signuptime datetime
)
create table usersignin
(
firstname char(40),
id numeric foreign key references userreg(id),
userid varchar(50),
emailid varchar(60),
password varchar(60),
status char(10) default 'valid'
)
create trigger usertrig on userreg
for insert
as
declare @firstname char(40);
declare @id numeric;
declare @userid varchar(50);
declare @emailid varchar(60);
declare @password varchar(60);
select @firstname=u.firstname, @id=u.id, @userid=u.userid, @emailid=u.emailid, @
password=u.password from userreg u;
insert into usersignin(u.firstname, u.id, u.userid, u.emailid, u.password) value
s (@firstname, @id, @userid, @emailid, @password)
select * from userreg
insert into userreg(firstname, lastname, dob, sex, mobile, address, state, count
ry, userid, emailid, password, quesption, answer, signuptime) values('varun', 's

inha', '1991', 'male', 9560639729, 'laxmi nagar', 'new delhi', 'india', 'vs', 'v
arun@mail.com', '@123', 'wats ur name ?', 'monty', getdate())
select * from usersignin
create table userrecoverypass
(
id numeric foreign key references userreg(id),
userid varchar(50),
emailid varchar(60),
password varchar(60),
quesption varchar(100),
answer varchar(50)
)
create trigger forgetpass on userreg
for insert
as
declare @id numeric;
declare @userid varchar(50);
declare @emailid varchar(60);
declare @password varchar(60);
declare @question varchar(100);
declare @answer varchar(50);
select @id=u.id, @userid=u.userid, @emailid=u.emailid, @password=u.password, @qu
estion=u.quesption, @answer=u.answer from userreg u;
insert into userrecoverypass(u.id, u.userid, u.emailid, u.password, u.quesption,
u.answer) values (@id, @userid, @emailid, @password, @question, @answer)
select * from userrecoverypass
select * from Purchase_Transaction
insert Purchase_Transaction values(1, getdate(), 1, 1, 'parle', 'parle', 4, 4, 1
6, 'food, it', 'good for health')
create table Purchase_Transaction
(
TransactionID numeric,
TransactionTime datetime,
Companyid numeric,
dealerid numeric,
itemID numeric ,
ItemName varchar(50),
Brand char(50),
QuantityofItem numeric,
PricePerItem numeric,
TotalPrice numeric,
ItemTag varchar(100),
ItemDesciption varchar(100)
)
SET IDENTITY_INSERT purchase_Transaction Off
drop trigger PTtoPS
create trigger PTtoPS on Purchase_Transaction
for insert
as
declare @TransactionID numeric;
declare @TransactionTime datetime;
declare @Companyid numeric;
declare @dealerid numeric;

declare @itemID numeric ;


declare @ItemName varchar(50);
declare @QuantityofItem numeric;
declare @PricePerItem numeric;
declare @TotalPrice numeric;
select @TransactionID=p.TransactionID, @TransactionTime=p.TransactionTime, @Comp
anyid=p.Companyid, @dealerid=p.dealerid, @itemID=p.itemID, @ItemName=p.ItemName,
@QuantityofItem=p.QuantityofItem, @PricePerItem=p.PricePerItem, @TotalPrice=p.T
otalPrice from purchase_Transaction p;
insert into Purchase_Stock(p.TransactionID, p.TransactionTime, p.Companyid, p.de
alerid, p.itemID, p.ItemName, p.QuantityofItem, p.PricePerItem, p.TotalPrice) va
lues (@TransactionID, @TransactionTime, @Companyid, @dealerid, @itemID, @ItemNam
e, @QuantityofItem, @PricePerItem, @TotalPrice)
drop table Purchase_Stock
create table Purchase_Stock
(
TransactionID numeric,
TransactionTime datetime,
Companyid numeric,
dealerid numeric,
itemID numeric foreign key references purchase_transaction(itemid),
ItemName varchar(50),
QuantityofItem numeric,
PricePerItem numeric,
TotalPrice numeric,
)
drop constraint FK__Purchase___itemI__66B53B20
select * from purchase_stock

create table Pre_Shelling_Stock


(
TransactionID numeric,
Companyid numeric,
dealerid numeric,
itemID numeric identity primary key,
ItemName varchar(50),
Brand char(50),
QuantityofItem numeric,
PricePerItem numeric,
TotalPrice numeric,
)
create table Shelling_Stock
(
TransactionID numeric,
Companyid numeric,
dealerid numeric,
itemID numeric identity primary key,
ItemName varchar(50),
Brand char(50),
QuantityofItem numeric,
PricePerItem numeric,
TotalPrice numeric,
)

create table Shelling_Transaction


(
TransactionID numeric,
TransactionTime datetime,
Companyid numeric,
dealerid numeric,
userID numeric,
itemID numeric identity primary key,
ItemName varchar(50),
Brand char(50),
QuantityofItem numeric,
PricePerItem numeric,
TotalPrice numeric,
)
create table Add_To_Cart
(
TransactionID numeric,
TransactionTime datetime,
Companyid numeric,
userID numeric,
itemID numeric identity primary key,
ItemName varchar(50),
Brand char(50),
QuantityofItem numeric,
PricePerItem numeric,
TotalPrice numeric,
)
select * from companyreg
select * from userreg