Page 1 of 1

update a database

PostPosted: 02. January 2011 09:50
by manolis1986
hello to all and happy new year

I have successfully created a database with xampp. In my data base there are 2 tables company(id, name, address, bank account) workers(name, id, comID, compname, compaccount, workeraddress,) id is the primary key in both tables. Bank acount is a unique field for the comany which means that each company has 1 bank acount.
As it is obvious workers wokr in a company. So i have created a "one to many" relationship between company and workers. What i want is for each new worker when i type the compID, the other fields that related to the company ID to be automatically fullfiled.

Thanks Alot
Manolis

Re: update a database

PostPosted: 02. January 2011 12:07
by WilliL
I think the best way is to write a php script.
If your are not familiar with php /mysql there is an interesting page http://www.w3schools.com/PHP/php_intro.asp

Re: update a database

PostPosted: 03. January 2011 05:46
by JonB
Ummm.

Does that mean your worker records contain will data (other than the Company ID) from the appropriate 'Company Master'???? OR do you mean you wish to DISPLAY/SELECT that additional Company info??

If you mean the first case, you are not following database normalization best practices. IF you move data from the Company Master (other than the ID field) into employee records, then any change to the shared fields in the Company Master will require updating all the employee records WHERE there is a match on Company ID ...

I'm guessing you did this in MySQL???

If you haven't, you might want to read up on the differences between InnoDB (often used for accounting type work) and MyISAM (often used for text related tasks) - a bit of a broad generalization, but each has a very different strong point that the other lacks (Foreign Keys vs. Full Text Indexing) Storage engine is a table level choice, so a database can use both types - however that leads to a hard-to-manage hybrid processing. (whatever, LOL) :)

You might want to also read up on 'stored procedures' (not for auto-filling, but for routine tasks - like temporary result tables and automated consistency maintenance)

Good Luck
8)