I have made some tables and created relationship from phpmyadmin.
Relationship is as below
[IMG]http://img295.imageshack.us/img295/2411/relationship.jpg[/IMG]
Problem is that requisition table allow material id which is not in material table. what is the problem. How can I solve this.

Simply Foreign key can not be such value which is not in primary key. How can I do that

Member Avatar for 1stDAN

If requisition table allows material ids (r_mat_id) which are not in material table, so where come this r_mat_id from? If this odd requirement is indeed necessary, you may omit foreign key definition in requisition table to get it function.

Btw, there seems to be a many to many realtionship between user and project. Therefore the complete primary key of permission table should consist of all primary key columns of both related table, thus it should be (user_id,user_name, prj_name, prj_id). On the other hand, if user_id is unique key of user table so why is user_name also part of its primary key, ditto for prj_name?

If requisition table allows material ids (r_mat_id) which are not in material table, so where come this r_mat_id from? If this odd requirement is indeed necessary, you may omit foreign key definition in requisition table to get it function.

Btw, there seems to be a many to many realtionship between user and project. Therefore the complete primary key of permission table should consist of all primary key columns of both related table, thus it should be (user_id,user_name, prj_name, prj_id). On the other hand, if user_id is unique key of user table so why is user_name also part of its primary key, ditto for prj_name?

I want that requisition table will notw allows material ids(r_mat_id) which is not in material table. How can I do that.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.