0
  1. i have two tables where customer table
    customer_id(pk),fullname,matric_id,ic_no,gender,address,postcode,state,hp_number,tel_number,username,password,repeatpassword.

    booktickect table **ticket_id(pk)**,*customer_id(fk)*,liner,direction,from,f_date,f_time,destination,t_date,t_time,total_price

  2. actually i have inserted 8 data in the customer table,hence it shows 8 as the cardinality of my primary key(customer_id).But why when i take a look at my foreign key(customer_id),its cardinality is showing 0 instead of 8.

  3. and another thing is in the sql database where there is an option of inserting values.my values for the foreign key has been updated to the 8 id's from the customer table.hence i think this shows that the foreign key is working but if i want to insert data into the database,i can't do so.tq in advance

Satia Anbalagan
  • 35
  • 1
  • 1
  • 5
  • In PHPMyAdmin, "cardinality" is the "number of unique values" for that column. If your bookticket table is empty, the `bookticket.customer_id` column will have cardinality of zero. – Andomar May 12 '13 at 18:48
  • The dropdown for the foreign key fetches values from the referenced customer table. The cardinality for `customer_id` in the `bookticket` table is the number of unique values for `customer_id` in the `bookticket` table. – Andomar May 12 '13 at 19:00
  • tq @Andomar.another thing is when i open the insert option in the phpmyadmin,i can see the values of the foreign key(customer_id)in the bookticket table which is inherited from the other table(customer).in my php, i can also get the customer_id for the current session `echo $_SESSION['customer_id'];` but when i want to insert into database ,the values is not being inserted into the table.this is my code `$customer_id=mysql_insert_id(); $query="INSERT INTO bookticket VALUES('','$customer_id','$liner','$direction','$from','$f_date','$f_time','$destination','$t_date','$t_time','$total_price')";` – Satia Anbalagan May 12 '13 at 19:05
  • 1
    Be sure to [check MySQL errors](http://stackoverflow.com/a/4125792/50552) with `mysql_error()`. From a quick glance, you typically can't enter `''` as your primary key. It's either an auto-increment column (in which case you should omit it from the `insert` entirely) or it's your job to enter a unique value there. – Andomar May 12 '13 at 19:09
  • Thank You Mr.@Andomar .By default i have set the primary key to auto increment.and that `' '` quote that i did is because i follow it from a video tutorial where they implement an empty single quoted space for auto incremented primary key – Satia Anbalagan May 13 '13 at 09:14

0 Answers0