Click here to Skip to main content
15,886,798 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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
Updated 9-Nov-12 6:05am
v2

1 solution

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.
SQL
SELECT * 
  FROM Car
       INNER JOIN Record ON Record.CarId = Car.Id
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900