 |
|
 |
|
Next: Importing / Updating from another DB to MS SQL
|
| Author |
Message |
External

Since: Aug 11, 2004 Posts: 3779
|
(Msg. 16) Posted: Fri Jun 04, 2010 8:13 am
Post subject: Re: Multiple Inserts across multiple tables [Login to view extended thread Info.] Archived from groups: comp>databases>mysql (more info?)
|
|
|
David wrote:
> On 4 June, 12:50, Captain Paralytic wrote:
>> On Jun 4, 10:37 am, David wrote:
>>
>>> On 4 June, 09:27, Captain Paralytic wrote:
>>>> On Jun 3, 7:28 pm, Lennart Jonsson
>>>> wrote:> On 2010-06-03 17:25, Jerry Stuckle wrote:
>>>>> [...]
>>>>>> It's quite common to have multiple clients with one company. Different
>>>>>> departments, for instance, may have separate accounts. But billing
>>>>>> still goes to the same place.
>>>>>> And each account may have one or more users authorized to use the
>>>>>> account; each user would have to be inserted.
>>>>> All agreed, but I don't think I would end up with a data model like the
>>>>> OP's, no matter what
>>>> An author who likes playing with language (e.g. Terry Pratchett or
>>>> Douglas Adams) would say something like:
>>>> "There is no such thing as a perfect data model and this is an
>>>> excellent example."
>>> I can see everyone who has comments suggests that this is an imperfect
>>> model. I would welcome any feedback on why its imperfect, and what
>>> everyone else would do instead.
>> I did that in my first post in this thread.
>> If you need a 1:m relationship, you do it using the primary key from
>> the main (1) table and using it as a foreign key in any (m) tables.
>> If you have a 1:1 relationship, then you either put all the data in a
>> single table or, if you have a good reason for spreading the data
>> amongst many tables, you use the same primary key value in all of
>> them.
>>
>> Really all you have to do is to follow the standard normalisation
>> rules:http://delicious.com/Captain_Paralytic/normalization
>
> Ok, Now I am really confused, because i thought that is what i am
> doing?
>
> insert an address, get the last_insert_id and then update the account
> table with that id.
> I do the same for the contacts, email addresses and numbers
>
> So if im being a bit thick forgive me, but isnt that what you are
> talking about?
>
>
>
You have a 1:m relationship (client:address). How do you indicate
multiple addresses if you are inserting the address id in the client table?
Rather, client_id should be a member of address, and nothing need be
updated in client.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex.DeleteThis@attglobal.net
================== >> Stay informed about: Multiple Inserts across multiple tables |
|
| Back to top |
|
 |  |
External

Since: Aug 11, 2004 Posts: 3779
|
(Msg. 17) Posted: Fri Jun 04, 2010 9:05 am
Post subject: Re: Multiple Inserts across multiple tables [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
David wrote:
> On 4 June, 13:13, Jerry Stuckle wrote:
>> David wrote:
>>> On 4 June, 12:50, Captain Paralytic wrote:
>>>> On Jun 4, 10:37 am, David wrote:
>>>>> On 4 June, 09:27, Captain Paralytic wrote:
>>>>>> On Jun 3, 7:28 pm, Lennart Jonsson
>>>>>> wrote:> On 2010-06-03 17:25, Jerry Stuckle wrote:
>>>>>>> [...]
>>>>>>>> It's quite common to have multiple clients with one company. Different
>>>>>>>> departments, for instance, may have separate accounts. But billing
>>>>>>>> still goes to the same place.
>>>>>>>> And each account may have one or more users authorized to use the
>>>>>>>> account; each user would have to be inserted.
>>>>>>> All agreed, but I don't think I would end up with a data model like the
>>>>>>> OP's, no matter what
>>>>>> An author who likes playing with language (e.g. Terry Pratchett or
>>>>>> Douglas Adams) would say something like:
>>>>>> "There is no such thing as a perfect data model and this is an
>>>>>> excellent example."
>>>>> I can see everyone who has comments suggests that this is an imperfect
>>>>> model. I would welcome any feedback on why its imperfect, and what
>>>>> everyone else would do instead.
>>>> I did that in my first post in this thread.
>>>> If you need a 1:m relationship, you do it using the primary key from
>>>> the main (1) table and using it as a foreign key in any (m) tables.
>>>> If you have a 1:1 relationship, then you either put all the data in a
>>>> single table or, if you have a good reason for spreading the data
>>>> amongst many tables, you use the same primary key value in all of
>>>> them.
>>>> Really all you have to do is to follow the standard normalisation
>>>> rules:http://delicious.com/Captain_Paralytic/normalization
>>> Ok, Now I am really confused, because i thought that is what i am
>>> doing?
>>> insert an address, get the last_insert_id and then update the account
>>> table with that id.
>>> I do the same for the contacts, email addresses and numbers
>>> So if im being a bit thick forgive me, but isnt that what you are
>>> talking about?
>> You have a 1:m relationship (client:address). How do you indicate
>> multiple addresses if you are inserting the address id in the client table?
>>
>> Rather, client_id should be a member of address, and nothing need be
>> updated in client.
>>
>
> Oh, so im doing it the wrong way round.
>
Yes. You way, how would you specify multiple addresses for a single
company?
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex RemoveThis @attglobal.net
================== >> Stay informed about: Multiple Inserts across multiple tables |
|
| Back to top |
|
 |  |
External

Since: Aug 11, 2004 Posts: 3779
|
(Msg. 18) Posted: Fri Jun 04, 2010 9:10 am
Post subject: Re: Multiple Inserts across multiple tables [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
David wrote:
> On 4 June, 14:05, Jerry Stuckle wrote:
>> David wrote:
>>> On 4 June, 13:13, Jerry Stuckle wrote:
>>>> David wrote:
>>>>> On 4 June, 12:50, Captain Paralytic wrote:
>>>>>> On Jun 4, 10:37 am, David wrote:
>>>>>>> On 4 June, 09:27, Captain Paralytic wrote:
>>>>>>>> On Jun 3, 7:28 pm, Lennart Jonsson
>>>>>>>> wrote:> On 2010-06-03 17:25, Jerry Stuckle wrote:
>>>>>>>>> [...]
>>>>>>>>>> It's quite common to have multiple clients with one company. Different
>>>>>>>>>> departments, for instance, may have separate accounts. But billing
>>>>>>>>>> still goes to the same place.
>>>>>>>>>> And each account may have one or more users authorized to use the
>>>>>>>>>> account; each user would have to be inserted.
>>>>>>>>> All agreed, but I don't think I would end up with a data model like the
>>>>>>>>> OP's, no matter what
>>>>>>>> An author who likes playing with language (e.g. Terry Pratchett or
>>>>>>>> Douglas Adams) would say something like:
>>>>>>>> "There is no such thing as a perfect data model and this is an
>>>>>>>> excellent example."
>>>>>>> I can see everyone who has comments suggests that this is an imperfect
>>>>>>> model. I would welcome any feedback on why its imperfect, and what
>>>>>>> everyone else would do instead.
>>>>>> I did that in my first post in this thread.
>>>>>> If you need a 1:m relationship, you do it using the primary key from
>>>>>> the main (1) table and using it as a foreign key in any (m) tables.
>>>>>> If you have a 1:1 relationship, then you either put all the data in a
>>>>>> single table or, if you have a good reason for spreading the data
>>>>>> amongst many tables, you use the same primary key value in all of
>>>>>> them.
>>>>>> Really all you have to do is to follow the standard normalisation
>>>>>> rules:http://delicious.com/Captain_Paralytic/normalization
>>>>> Ok, Now I am really confused, because i thought that is what i am
>>>>> doing?
>>>>> insert an address, get the last_insert_id and then update the account
>>>>> table with that id.
>>>>> I do the same for the contacts, email addresses and numbers
>>>>> So if im being a bit thick forgive me, but isnt that what you are
>>>>> talking about?
>>>> You have a 1:m relationship (client:address). How do you indicate
>>>> multiple addresses if you are inserting the address id in the client table?
>>>> Rather, client_id should be a member of address, and nothing need be
>>>> updated in client.
>>> Oh, so im doing it the wrong way round.
>> Yes. You way, how would you specify multiple addresses for a single
>> company?
>>
>
> The account_id is saved in the address table along with the type of
> address (ie billing, registration, local office etc..)
>
Ok, so then why do you need to update in the account table?
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex.TakeThisOut@attglobal.net
================== >> Stay informed about: Multiple Inserts across multiple tables |
|
| Back to top |
|
 |  |
External

Since: Jan 14, 2008 Posts: 245
|
(Msg. 19) Posted: Fri Jun 04, 2010 10:35 am
Post subject: Re: Multiple Inserts across multiple tables [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
On Jun 4, 2:18 pm, David wrote:
> On 4 June, 14:10, Jerry Stuckle wrote:
> > Ok, so then why do you need to update in the account table?
>
> Yes, I agree with you now. I see that its duplication and totally not
> needed !
Which is what I said in that first post.
And the other advice I offered, to read and follow the normalisation
steps, is the best thing for you to do. >> Stay informed about: Multiple Inserts across multiple tables |
|
| Back to top |
|
 |  |
| Related Topics: | select where multiple joined records match - I'm trying to figure out how to select all the records in one table which have multiple specified records in a second table. Here's a simplified version of my problem. I have two tables, resources and goals. resources table: ID TITLE 1 civil war..
Best way to issue hundreds of inserts/updates??? - Using mysql 4.0.23- What is the best way to execute several (hundreds of) inserts and updates? Rather than issuing tons of individual inserts and updates, can I send the strings to a text file and then have mysql do them all?? IE : query.txt insert..
Document MySQL Tables - I googled and found a number of tools that claim to document MySQL schema, both at the column level and the table level. If you have found any that worked well for you please let me know. Thanks, Joe
PLS HELP! - show databases and tables and columns - Hi, I just wonder if someone can help me with this: I need to create a sql script which will run when user installs/upgrades my app. User may already have the database and tables tructure setup on the server, or may not. The script needs to..
Restoring select databases/tables from an --all-databases .. - I use the --all-databases switch to backup my entire database. Sometimes there's a need to restore individual databases or tables form the backup file. What command should I use for this? Thanks, Raffi |
|
You can post new topics in this forum You can reply to topics in this forum You can edit your posts in this forum You can delete your posts in this forum You can vote in polls in this forum
|
|
|
|
 |
|
|