Hi Marc, - If you use this database for some website, the solution is:
clients (id,name) contacts (id, name, phone, client_id (FK), username, password) companies (id, name) employees (id, name, phone, company_id (FK), username, password) logins table will be removed Then you must build web interface for each group (in this example is interface for contacts and another for employees). - Another solution is: logins (id, username, password, group_type, user_id) group_type: contacts, employees, ... user_id: contact_id or employee_id If group_type is contacts, then query to the contacts table with some contact_id If group_type is employees, then query to the employees table with some employee_id ----- Original Message ----- From: "Marc Guay" <marc.g...@gmail.com> To: mysql@lists.mysql.com Sent: Thursday, July 22, 2010 12:44:17 AM Subject: Table which can reference a number of other tables Hi everyone, I have a question regarding database design, I hope that this is appropriate for the list. Let's say that I have the following tables: clients (id,name) contacts (id, name, phone, client_id (FK)) companies (id, name) employees (id, name, phone, company_id (FK)) logins (id, username, password) What's the best way to connect contacts and employees to the logins table? I've thought of duplicating the username & password fields into both the contacts and employees tables, adding both contact_id and employee_id foreign keys to the logins table, and adding login_id foreign keys to the contacts and employees tables, but none of these solutions seem very smart. Thanks, Marc -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/mysql?unsub=cuong.m...@vienthongso.com -- Best Regards, Cuongmc. -- Nguyen Manh Cuong Phong Ky Thuat - Cong ty Vien Thong So - VTC Dien thoai: 0912051542 Gmail : philipscu...@gmail.com YahooMail : philipscu...@yahoo.com -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/mysql?unsub=arch...@jab.org