|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
which way of querying is better?
let's say you have a database with a table filled with an addressid (yes i need an id for addresses), names and addresses... "fname", "lname", "address1", "city", "state", "zip"...
now, my question is... is it better to 1) make a column of address2 (for po box's, apt #'s and such) in the same table where many of the "address2" fields will be blank, or 2) to make a whole new table with the "addressid" and the "address2" and create a query where it would have the database go through both tables thanx : ) |
|
#2
|
||||
|
||||
|
Whichever creates the least amount of replicated data.
table.user id fname lname ... table.address id user_id street city state zip ... one-to-many: one user has many addresses.
__________________
# Jeremy Explain your problem instead of asking how to do what you decided was the solution. |
|
#3
|
|||
|
|||
|
thanx, but actually.. i meant address2 as in:
name -> John Doe street1 -> 123 elm st city -> new york state -> new york zip -> 11001 address2 (or street2) would be apt #101 since many people live in houses that don't need a second line (apt #101) for their address, would it be better create a second table which holds all of the address2 or just keep it in the same table and save (what i'm guessing) processing power from going through another table or is a repeated "null" count as replicated data? thanx |
|
#4
|
||||
|
||||
|
|
|
#5
|
|||
|
|||
|
haha... k.. thanx.... but can you give me a reason why i shouldn't create another table? too much extra work for something so small? takes up too much processing power?
thanx.. : ) |
|
#6
|
||||
|
||||
|
queries are simpler
do not go by processing speed and disk space that's what we did in the 80's, when those things cost something nowadays the difference in speed when you join two tables (assuming you wanted fields out of both tables, which you wouldn't, necessarily, always, in your case), is negligible and the space difference is a wash, too however, when it comes to writing queries, go ahead, have a go yourself, write the queries to insert an address, update an address, and delete an address -- be fair, do two sets of queries, one for the single table model, and the other set for the two-table model then come back and you tell us which way is easier ![]() |
|
#7
|
|||
|
|||
|
haha.. k... thanx.. : )
|
![]() |
| Viewing: Dev Shed Forums > Databases > Database Management > which way of querying is better? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|