Wednesday, May 31, 2006
Tuesday, May 30, 2006
Monday, May 29, 2006
Wednesday, May 24, 2006
MYSQL TRICKS
>mysql -u root -p
password:****[root]
This is a problem when we are not able to set the referencial integrity in MYSQL it is bit twisted look down to see the solution.
NOW THIS IS WORKING
drop database stock;
CREATE DATABASE stock;
GRANT ALL ON petclinic.* TO pc@localhost IDENTIFIED BY 'pc';
USE stock;
CREATE TABLE STOCKHOLDING (
stockId INT(4) AUTO_INCREMENT,
stockNameShareKhan VARCHAR(30),
stockNameNSE VARCHAR(30),
priceNow FLOAT(30,2),
priceStartOfToday FLOAT(30,2),
INDEX(stockId)
)ENGINE=INNODB;
CREATE TABLE PRICEHISTORY
(
priceHistoryId INT(4) PRIMARY KEY AUTO_INCREMENT,
price FLOAT(30,2),
whenFetch DATE,
stockId INT(4) ,
Index PRICEHISTORY_stock_id (stockId),
FOREIGN KEY(stockId) references stockholding(stockId) on DELETE CASCADE
)ENGINE=INNODB;
ALTER TABLE STOCKHOLDING add primary key (STOCKID);
insert into STOCKHOLDING (stockNameShareKhan,stockNameNSE,priceNow,priceStartOfToday) values ('HICON','HINDCON',10.2,13.2); insert into STOCKHOLDING (stockNameShareKhan,stockNameNSE,priceNow,priceStartOfToday) values ('DASBABA','DASBABA',9.2,120.2);
insert into pricehistory (price,whenfetch,stockid) values(13.23,now(),1);
delete from stockholding where stockid=1;
select * from pricehistory;
select * from stockholding;
-----Original Message-----
From: Das, Souravmay
Sent: Wednesday, May 24, 2006 1:32 PM
To: Sahu, Ashwini Kumar
Subject: I m trying to test why is this not working
drop database stock;
CREATE DATABASE stock;
GRANT ALL ON petclinic.* TO pc@localhost IDENTIFIED BY 'pc';
USE stock;
CREATE TABLE STOCKHOLDING (
stockId INT(4) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
stockNameShareKhan VARCHAR(30),
stockNameNSE VARCHAR(30),
priceNow FLOAT(30,2),
priceStartOfToday FLOAT(30,2),
INDEX(stockId)
)TYPE=INNODB;
CREATE TABLE PRICEHISTORY
(
priceHistoryId INT(4) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
price FLOAT(30,2),
whenFetch DATE,
stockId INT(4) references stockholding(stockId) on DELETE CASCADE,
Index(stockid)
)TYPE=INNODB;
ALTER TABLE PRICEHISTORY ADD FOREIGN KEY (stockId)
REFERENCES STOCKHOLDING(stockId);
insert into STOCKHOLDING (stockNameShareKhan,stockNameNSE,priceNow,priceStartOfToday) values ('HICON','HINDCON',10.2,13.2);
insert into pricehistory (price,whenfetch,stockid) values(13.23,now(),1);
delete from stockholding;
select * from pricehistory;