iphone SDK: Create Relationships in sqlite3 database | Coding Cluster - using asp.net, c#, mvc 4, iphone, php, ios, javascript, in asp.net mvc 3 & more
 

iphone SDK: Create Relationships in sqlite3 database

Tuesday

Create relationships between tables in sqlite3:
                                SQLite supports the definition of foreign key constraints, the following sqlite3 query will be used to create a table "media" with foreign key reference with "incident" table
CREATE TABLE "media" ("media_id" INTEGER PRIMARY KEY  NOT NULL  UNIQUE "incident_id" INTEGER NOT NULL "media_type" VARCHAR NOT NULL "file_name" VARCHAR NOT NULL "path" VARCHAR NOT NULL "created_date" DATETIME NOT NULL "LastModified_date" DATETIME NOT NULL,
 
constraint FK_media__incident foreign key(incident_id) references incident(incident_id))
  This an example for create table with more than one references. Each references separate with commas,
CREATE TABLE "incident_type_list" ("incident_id" INTEGER PRIMARY KEY  NOT NULL  UNIQUE "incident_type_id" INTEGER NOT NULL "created_date" DATETIME NOT NULL "last_modified_date" DATETIME NOT NULL,
 
constraint FK_incident_type_list_incident foreign key(incident_id) references ir_incident(incident_id),
constraint FK_incident_type_list_incident_type foreign key(incident_type_id) references incident_type(type_id))
  Leave some comments if this post useful for you. Thanks!.

0 comments:

Post a Comment

Share your thoughts here...

 
 
 

RECENT POSTS

Boost

 
Blogger Widgets