怎么创建sqlite的主外键关联。。。要具体的代码。。或者帮我解决问题: 30

db.execSQL("createtable"+OnlineTable+"("+videoId+"integer,"+name+"text,"+type+"text,"... db.execSQL("create table "+OnlineTable+
"("+videoId +" integer,"
+name+" text,"+type+" text,"+region+" text,"+year+
" text,"+actor+" text,"
+television+" text,"+introduction +" text,"+
collection+" text ,"
+number+" integer primary key not null,"
+" references "+JujiTable+"("+number+"))");
db.execSQL("create table "+JujiTable+
"("+videoId+" integer ,"
+webside+" text,"+link+" text,"+number+" integer primary key)");
/*
//创建添加的触发器
db.execSQL("create trigger fk_Movie_deptid " +
"before insert on "+OnlineTable+" for each row begin " +
"select case when ((select "+number+" from "+JujiTable+
" where "+number+"=new."+number+")is null) then raise " +
"(abort,'foreign key violation') end;end");*/
//创建触发器
db.execSQL("create trigger fk_Movie_deptid " +
"after insert on "+OnlineTable+" for each row begin " +
"select case when ((select "+number+" from "+JujiTable+
" where "+number+"=new."+number+")is null) then raise " +
"(ABORT,'Foreign Key Violation') end;end");

//创建视图
db.execSQL("create view "+ viewEmps+" as select "+OnlineTable+"."+videoId+" as _id,"
+
""+OnlineTable+"."+type+","+
OnlineTable+"."+actor+","
+OnlineTable+"."+name+","
+OnlineTable+"."+number+","
+OnlineTable+"."+television+","
+OnlineTable+"."+year+","
+OnlineTable+"."+introduction+","
+OnlineTable+"."+collection+","
+OnlineTable+"."+region+","+
""+JujiTable+"."+webside+","+JujiTable+"."+videoId+","
+JujiTable+"."+number+","
+JujiTable+"."+link+""
+" from "+OnlineTable+
" join "+JujiTable+" on "+OnlineTable+"."+number+"="+JujiTable+"."+number+"");
展开
 我来答
903390263
2012-07-09 · TA获得超过694个赞
知道答主
回答量:370
采纳率:0%
帮助的人:178万
展开全部
当然
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式