Forum » Programiranje » mySQL 5 -> SQLite 3.x
mySQL 5 -> SQLite 3.x
'FireSTORM' ::
Kako bi spravil mySQL statemnts v SQLite?
Oz. drugače povedano kake se naredi naslednja stvar v SQLite:
Ok, dodajanje tabel in generiranje primary keyev mi ne povzroča problemov, povzroča mi probleme FOREIGN KEY in koliko sem bral na SQLite website piše da še to ni implementirano. Kako pa potem lahko nadomestim ta foreign key?
Oz. drugače povedano kake se naredi naslednja stvar v SQLite:
DROP TABLE IF EXISTS HISTORY; DROP TABLE IF EXISTS OWNERSHIP; DROP TABLE IF EXISTS CLIENT; DROP TABLE IF EXISTS CONTENT; DROP TABLE IF EXISTS MEDIUM; CREATE TABLE MEDIUM ( ID_MED INT NOT NULL AUTO_INCREMENT, ID_OWN INT NOT NULL, ID_CLI INT NOT NULL, TITLE VARCHAR(250) NOT NULL, DESCRIPTION VARCHAR(150), MED_TYPE VARCHAR(20) NOT NULL, NUMBER INT NOT NULL, TIME_LENDED DATETIME, TIME_BORROWED DATETIME, TIME_ADDED DATETIME NOT NULL, PRIMARY KEY (ID_MED)) ENGINE = MYISAM; CREATE TABLE CONTENT ( ID_CON INT NOT NULL AUTO_INCREMENT, ID_MED INT NOT NULL, TITLE VARCHAR(250) NOT NULL, DESCRIPTION VARCHAR(150), CON_TYPE VARCHAR(50), PRIMARY KEY (ID_CON)) ENGINE = MYISAM; CREATE TABLE CLIENT ( ID_CLI INT NOT NULL AUTO_INCREMENT, NAME VARCHAR(100) NOT NULL, SURNAME VARCHAR(200), ADDRESS VARCHAR(250), POST VARCHAR(150), POST_NUM INT, CONTACT_NUM INT NOT NULL, PRIMARY KEY (ID_CLI)) ENGINE = MYISAM; CREATE TABLE OWNERSHIP ( ID_OWN INT NOT NULL AUTO_INCREMENT, OWNERSHIP VARCHAR(50) NOT NULL, PRIMARY KEY (ID_OWN)) ENGINE = MYISAM; CREATE TABLE HISTORY ( ID_HIS INT NOT NULL AUTO_INCREMENT, ID_CLI INT NOT NULL, ID_MED INT NOT NULL, LENDED DATETIME NOT NULL, BORROWED DATETIME NOT NULL, RETURNED DATETIME NOT NULL, PRIMARY KEY (ID_HIS)) ENGINE = MYISAM; ALTER TABLE CONTENT ADD FOREIGN KEY (ID_MED) REFERENCES MEDIUM (ID_MED) ON DELETE RESTRICT ON UPDATE RESTRICT; ALTER TABLE HISTORY ADD FOREIGN KEY (ID_MED) REFERENCES MEDIUM (ID_MED) ON DELETE RESTRICT ON UPDATE RESTRICT; ALTER TABLE MEDIUM ADD FOREIGN KEY (ID_CLI) REFERENCES CLIENT (ID_CLI) ON DELETE RESTRICT ON UPDATE RESTRICT; ALTER TABLE HISTORY ADD FOREIGN KEY (ID_CLI) REFERENCES CLIENT (ID_CLI) ON DELETE RESTRICT ON UPDATE RESTRICT; ALTER TABLE MEDIUM ADD FOREIGN KEY (ID_OWN) REFERENCES OWNERSHIP (ID_OWN) ON DELETE RESTRICT ON UPDATE RESTRICT;
Ok, dodajanje tabel in generiranje primary keyev mi ne povzroča problemov, povzroča mi probleme FOREIGN KEY in koliko sem bral na SQLite website piše da še to ni implementirano. Kako pa potem lahko nadomestim ta foreign key?
Those penguins.... They sure aint normal....
krho ::
Foreign keye s triggerji :), ostalo pa vidim, da si itak že pogruntal. Mimogrede SQLite zahteva batchanje (če se le da, zadeva je čisti ACID) INSERT/UPDATE/DELETE stavkov za dober performance.
si.Mail odprto-kodni odjemalec elektronske pošte. - http://www.simail.si
Uredite si svojo zbirko filmov, serij in iger - http://xcollect.sf.net
Uredite si svojo zbirko filmov, serij in iger - http://xcollect.sf.net
'FireSTORM' ::
Sem čist newbie z bazami, bi mi lahko morda napisal en primerek kako bi to naredil z triggerji?
Those penguins.... They sure aint normal....
Vredno ogleda ...
Tema | Ogledi | Zadnje sporočilo | |
---|---|---|---|
Tema | Ogledi | Zadnje sporočilo | |
» | PostgreSQL pomočOddelek: Programiranje | 2500 (1993) | Mato989 |
» | MySQL RelacijeOddelek: Izdelava spletišč | 1098 (864) | mkos2 |
» | SQL težavaOddelek: Programiranje | 5137 (4419) | joseti |
» | MySql Vprasanje - problem dupliciranih kljucevOddelek: Izdelava spletišč | 1430 (1252) | KernelPanic |
» | mysql vnosOddelek: Izdelava spletišč | 1548 (1513) | asgard2.0 |