Funnily enough, I have absolutely no experience with MySQL foreign keys. I'd like to change that :) My database schema is rather complicated, and I have a lot of work ahead of me, but let's simplify things. Suppose I have **Members Table:** id (PRIMARY KEY) username first_name last_name company etc **Posts Table:** id (PRIMARY KEY) message member_id member_username etc So now what I'd like to do is find a way to use foreign keys (I don't even know if this is possible or what it's designed for) to tell MySQL that posts.member_id relates back to members.id and posts.member_username relates back …

Member Avatar
Member Avatar
+1 forum 10

I am doing program in java .I have designed a jsp page which has 3 drop downlist's...country,state and district.I want to display the values in drop down list state when a country is selected...(for eg:-if india is selected,drop down list state must have only the name of states in india).In Mysql i have created 3 table's...table country has a primary key and country name.table state have state id,state name and a foreign key from country id...What is the code in servlet and jsp to do this?Pls help me to do this pblm...

Member Avatar
Member Avatar
+0 forum 1

Hello, I have a little problem , I am currently developing an application with PHP and MySQL , this application should show me more persons, each person must have one or more services and each service can be inversely associated with several people, for this I have 2 tables, one containing the data of the persons (personnel) and the other contains the names of services and a foreign key that references the id of the persons table (liste_service_log), below the image of two tables, ![jointure.png](/attachments/large/4/ba2389f8fc126d2d5f0ffe1809974c36.png "align-center") the fields etat is a boolean fields and default null, below a picture of …

Member Avatar
Member Avatar
+0 forum 2

I have created a vendors page where I want to show how many vendors exist in the database. I have succcssfully done but main problem is that how do i show that which vendor contains how many products There are 2 tables I have created 1 is products 2nd is vendors <table style="border-collapse: collapse"> <tr> <th>Vendor Name</th> <th>Vendor Address</th> <th>Vendor Email</th> <th>Product Quantity</th> </tr> <?php $query = "SELECT * FROM vendors"; $get_query = mysqli_query($connection, $query); while ($vendors_row = mysqli_fetch_assoc($get_query)) { echo "<tr>"; echo "<td>" . $vendors_row["v_name"] . "</td>"; echo "<td>" . $vendors_row["v_address"] . "</td>"; echo "<td>" . $vendors_row["v_email"] . "</td>"; …

Member Avatar
Member Avatar
+0 forum 4

Hi all. I'm developing a quiz application consisting of multiple choice questions. Here are the tables that I've come up with. CREATE TABLE IF NOT EXISTS `student` ( `s_id` int(10) NOT NULL, `s_name` varchar(30) NOT NULL, `s_email` varchar(30) NOT NULL, PRIMARY KEY (`s_id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; CREATE TABLE IF NOT EXISTS `instructor` ( `i_id` int(6) NOT NULL, `i_name` varchar(30) NOT NULL, `i_email` varchar(30) NOT NULL, PRIMARY KEY (`i_id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; CREATE TABLE IF NOT EXISTS `result` ( `r_id` int(6) NOT NULL AUTO_INCREMENT, `s_id` int(10) NOT NULL, `i_id` int(6) NOT NULL, `r_status` text NOT NULL, `r_score` decimal(6,0) NOT …

Member Avatar
Member Avatar
+0 forum 4

Hi all, I'm having some trouble inserting records into my MySQL db because of how I've set up my foreign keys. The problem is, I don't know how to fix it to make it do what I need it to. Here is my schema: http://imgur.com/t5bVt Here is my php code to run the queries: // Add new email, clean it first $sql = 'insert into customers set email = :email'; $s = $pdo -> prepare($sql); $s -> bindValue(':email', $_POST['email']); $s -> execute(); // Get id of new customer $custid = $pdo -> lastInsertId(); // Create new order for customer $sql …

Member Avatar
Member Avatar
+0 forum 2

hi every one. i have two tables table_1 ( std_id primary key, std_name, tchr_id foreign key ); table_2 ( tchr_id primary key, tchr_name ); as from the above tables i have the foreign key constraint. it mean if i want to delte teacher id it must be firstly deleted from the table 1 and so on so forth. but now my question is m trying to delete with the following query in `php` $query = mysql_query("DELETE FROM table_2 WHERE tchr_id='".$id."'") or die(mysql_error()); but this could't delted and an error is shown as it could be for the foreign key constraint. …

Member Avatar
Member Avatar
+0 forum 1

i have two tables with the following columns: departments: departmentID tinyint not null department varchar( 30 ) not null employees: employeeID SMALLINT(5) not null departmentID tinyint not null firstName varchar(30) not null lastName varchar(30) not null how do i create the two tables using SQL with a foreign key linking the two tables?

Member Avatar
Member Avatar
+0 forum 1

The End.