473,378 Members | 1,447 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

one to many relationship

72 64KB
Hi,
say you have a tblProducts table with the usual list of items and prices and create an invoice that contains a list of products (pkProducts in another table with other releshionships)and a year later decide to totally change the name of a product, that invoice is not correct anymore, if I print it will show the new product and not the original one.
Having a duh moment

Thanks
Dec 7 '20 #1

✓ answered by cactusdata

Simple: Save the current product name and price as fields of the invoice detail (line) record.

3 2558
cactusdata
214 Expert 128KB
Simple: Save the current product name and price as fields of the invoice detail (line) record.
Dec 8 '20 #2
twinnyfo
3,653 Expert Mod 2GB
I should point out that, in general, such advice to save duplicate data as such is a drastic "no-no" in DB design.

However, in this case, this is the only way to save historical product names and prices. The only other possible way to maintain the historical record is to add a date field in the products table and have multiple entries for each product, listing the date with the current product name and price. However, that level of insanity and the complexity of working through invoices would be enough to give anyone a headache. It is simpler to do as CactusData has described.

Additionally, in your case, if the item has changed and not just the name of the product, I would recommend adding a new item to your Products Table. However, if you have a rotating list of products available, this might not be necessary.
Dec 8 '20 #3
Neruda
72 64KB
Great thanks, I just did not dare duplicating data!
Interesting to add a date field in products, as you said a bit OTT for what I am doing but excellent answers
Thanks a lot!
Dec 8 '20 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Apple | last post by:
I have to create a query with many to many relationship, but I can't break it into 2 x 1 to many, should there anyone can teach me how to solve this problem. Thanks in advance!
3
by: lorirobn | last post by:
Hello, I have a report which uses a subreport. When I run the report, I get "Enter Parameter Value" error message for "tblGuestRoom". I click ok and the report seems to work fine. I...
1
by: Michael D. Reed | last post by:
I have two tables in an Access database with a Many-to-Many relationship, there is a connection table. The tables are , , and the connection table is this is a standard Many-to-Many relationship...
1
by: radiodave | last post by:
I don't know how to ask this question but I'll try: I'm making a database (Access 2003) for an Opera buff. I have tables related like: each Opera has many Productions (Madame Butterfly has an...
11
by: RobertJohn | last post by:
Hi all I am using Access 2007 to start a small home library application, and so far it has two tables. 1. Books, with fields Book_ID (Primary Key) and Title, and 2. Authors, with fields...
2
by: paulcjcross | last post by:
How to set up a many to many relationship. I know you need a third table to join the other two. I need one table (table1) with stock_numbers(unique), one table (table2) with job-numbers(unique) and...
6
by: NicoleCartrette | last post by:
Going back to school is easier said than done.. This was posted to an older thread earlier but I don't think it got any attention. Your help is appreciated Professor requires we create a...
2
by: chrisbo | last post by:
I have three tables and want to create a many-to-many relationship between them. The main table has a composite primary key http://www9.vgregion.se/vastarvet/va/bilder/db_photo.jpg This can't...
11
by: Mo Ewing | last post by:
I have one table called "Plants" that has a many-to-many relationship with a table called "Locations" through a third table called "PlantsToLocations". This setup works fine. I have a form where I...
6
by: sg2808 | last post by:
I have two tables (tblPolicyMap and tblBusiness) and the fields within it are: 1. tblPolicyMap PolicyID (PK) PolicyDetail 2. tblBusiness BusinessID (PK) HLProcessName Business_Functions
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.