php - What is the best way to enter data into a small database when mapping tables? -


i have small problem believe of clever people out there have simple solution for. haven't realised yet.

i designer project , part of work depend upon postgresql database have 1 version of truth. set tables using common practices such using pk (serial) each table. when link 2 tables use foreign key. helps me in sanity checking design , doing reports on it.

take example following 3 tables 1 field each:

student_id : student_name 1          : j bloggs  class_id   : class_name 1          : physics  student_class_assoc : student_id : class_id 1                   : 1          : 1 

i can input data using pgadmin students , classes no problem, when comes associating student , class have go each table , find id. in case trivial, when have around 70 or 80 entries becomes troublesome. ideally way able input data searching through student_name , class_name field , entering releveant id.

i've thought using simple php form this, thought ask else first see if there better solutions.

best regards,

adam

assuming student_class_assoc serial

insert student_class_assoc (student_id, class_id) select student_id, class_id     (values         ('j bloggs', 'physics'),         ('m mary', 'math')     ) (student_name, class_name)     inner join     student using (student_name)     inner join     class using (class_name) 

but there problem of common names. if there 2 m mary both in math class.


Comments

Popular posts from this blog

jQuery Mobile app not scrolling in Firefox -

c++ - How to add Crypto++ library to Qt project -

php array slice every 2th rule -