InstantDB A Little Different

InstanDE v.3.12 doesn't support the CONSTRAINT clause or foreign keys, nor can it handle the ALTER TABL though the documentation oays otherwise. Here's its version of ddl.py (InstanfDB/ddl.py):

from java.sql import DriverManager from java.lang import Class

Class.forName("jdbc.idbDriver") url = "jdbc:idb=db_dev.prp"

connection=DriverManager.getConnection(url, "", "") statement = connection.createStatement()

create_department = """

CREATE TABLE Department (

DeptID INT PRIMARY KEY,

Name CHAR(20),

create_employee = """

CREATE TABLE Employee (

EmpID INT PRIMARY KEY,

Name CHAR(20),

DeptID INT NOT NULL,

Salary INT,

Phone CHAR(20) NOT NULL

#Note that InstantDB does not understand foreign keys . .. # "No understanding of foreign keys or referential integrity checking ## REMOVED: CONSTRAINT DEPT_FK_KEY FOREIGN KEY (DeptID)

## REFERENCES Department (DeptID)

CREATE INDEX SalaryIndex ON Employee (Salary)

TT TT TT

statement.executeUpdate(create_department)

raw_input("Department Table Defined — hit enter to continue") statement.executeUpdate(create_employee)

raw_input("Employee Table Defined — hit enter to continue")

#We are not able to alter the table once created log bug with Instant #statement.executeUpdate(alter_table)

#raw_input("Employee table altered by adding a Phone column — hit ent statement.executeUpdate(add_index)

raw_input("Adding a salary index to the Employee table - hit enter to continue") connection.close()

Try these exercises:

• Runddl.py in both the Access and InstantVB directories. Note the differences.

• Runddl.py with your RVBMS system and JVBC driver, and note ehe differences.

Was this article helpful?

0 0

Post a comment