php - Creating a DAO Query with many One-to-Many Relationships? -


I am developing a web application with PHP and MySQL I have a unit, whose name is user, in which many One-to-many relationships (with other objects) (list of addresses, list of emails, list of phone numbers, etc.) These addresses are supplied in various databases via email, phone number, junction tables for the user. (User_link_addresses, user_link_emails, etc.).

I am now trying to create an efficient DAO for the user unit, especially the methods ReadUserById ($ userId) and readUllUsers () However, since I am an amateur and DAO pattern in SQL , I'm having trouble making this DAO correctly.

I am told that it is important for network efficiency to keep your DAO for a curiosity that reads all the information at one time and then can be mapped accordingly according to that unit. It makes sense, but I'm having trouble generating the A query in which everything has the necessary information and that my unit can be correctly mapped.

Now, I can find this information by executing many questions within a loop after meeting users ... I do not like this idea (and I'm sure this is not correct). Apart from this, I know how to connect with junction tables - just some of this is not with the premises and said that it needs to be properly mapped as well

Table names and fields

Table: User field. : User_id, username, password

table: address field: address_id, street, city, state, ZIP_CODE, type

table: email field: EMAIL_ID, email, type

table: PHONE_NUMBER field: phone_number_id, AREA_CODE, PHONE_NUMBER, type

- junction tables for relations -

table: user_link_address field: user_id, address_id

< P> Table: user_link_email field: user_id, EMAIL_ID

table: user_link_phone_number field: user_id, phone_number_id

Anyway, all help is highly appreciated,

Steve

sometimes It is worth involving organizations within the questions and sometimes it does not. Runs it as a very clean plugin for Ruby on Rails and tells you which queries should be connected to the associated model that analyzes your application

Trying something like you Can:.

 Select  from 'user_link_addresses` to `interiors`` `user`.id =' user_link_addresses`.user_id Join Insider 'user_link_foo`` user`.id =` User_link_foo`.user_id  

If you tell me all your table names and fields, I can help you type more specific queries.


Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -