Click here to Skip to main content
12,954,856 members (75,764 online)
Rate this:
 
Please Sign up or sign in to vote.
See more:
hello friends please help i have these two table dbo.carInfo and dbo.Record

the first table dbo.carInfo contains fields
has these fields
id
plateNo
plateCity
plateColor
ownerFullName
mobile

and the second table dbo.Record has these fields
id
plateNo
plateCity
plateColor
location
date
tax
mobile


Now what i want to ask is that. in those two table there are some common fields
the first table already has all values in the fields. now i want to do some thing like that whenever i want to insert a new record to the second table if some vallues of these two table are equal automatically fetch the mobile data from the first table to the second table.

please help me and do it for me please i really need it
Posted 9-Nov-12 2:42am
hardi24269
Updated 9-Nov-12 6:05am
Maciej Los253.2K
v2

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

Your database is not normalized properly. There should never be this kind of duplication in data. A much better model would look like this.
dbo.Car
   id
   plateNo
   plateCity
   plateColor
   ownerFullName
   mobile
dbo.Record
   id
   carId (foreign key to dbo.Car)
   location
   date
   tax
   mobile

Now when you insert data, you only insert it in one place and data integrity is maintained automatically.

When you want record data for a car the query is simple.
SELECT * 
  FROM Car
       INNER JOIN Record ON Record.CarId = Car.Id
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

    Print Answers RSS
Top Experts
Last 24hrsThis month
OriginalGriff 6,539
CHill60 3,490
Maciej Los 3,153
ppolymorphe 2,030
Jochen Arndt 1,975


Advertise | Privacy | Mobile
Web02 | 2.8.170525.1 | Last Updated 9 Nov 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100