Click here to Skip to main content
15,895,538 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
The site i am working on is a car rent project.
In my home page i have a form where the user can select Date of pick up , place of pick up , date of return , and the car type.
Now this 4 informations are input values that i store as cookies when the user presses the (book it) button.
After the user presses the (book it) button in the home page the form is submited and it redirects in another page where a list of cars is shown to the user according to the values of the previous form.
When click on a car you like you go to a new page where you have the car details and also i retrieve the values of the form that were stored as cookies and i display them in case he wants to change them.
So in this page with the car details the user can press the submit button to book the car.

What I have tried:

Now in the sql server i have 2 tables (Products) and (RentInfo). Products are the products that i create in the admin panel and i also display them in the pages and (RentInfo) is the table where i want to store the form values and the car details after the users presses the (book it) button in the car details page.
Now the problem is how can i save the form values and the car details in the the (RentInfo) table without duplicating the car details, since i have them already in the (Products) table. How can i retrieve them from there everytime i want to display the (RentInfo) table in my admin panel?
I WORK ON RAZOR WEB PAGES IN VISUAL STUDIO ASP.NET
If its too hard to understand my question please let me know.
Posted
Updated 11-Apr-19 23:39pm

1 solution

From the way you have phrased your question it sounds like you need to learn some simple database design techniques. There are plenty of free resources to help you - here is a starting point[^]
Basically, each row in your Products table should have a unique identifier - this is often an int identity(1,1) but many people prefer GUIDs. Either way, it is important that each row identifier is unique within this table.
On your RentInfo table you store that identifier instead of all of the car details, and when retrieving the data you must JOIN the tables e.g.
SQL
SELECT * 
FROM RentInfo 
INNER JOIN Products ON RentInfo.ProductID = Products.ProductID

Here are some specific links that you might find useful
Relational Database Design with an Auto Insurance Database Sample[^]
Visual Representation of SQL Joins[^]
SQL Server Tutorial[^]
MS SQL Server Tutorial[^]
Or if you prefer books try Beginning Database Design - From Novice to Professional | Clare Churcher | Apress[^]
Finally, there are loads of examples of Database design at http://www.databaseanswers.org/data_models/[^]
 
Share this answer
 
Comments
simple world 12-Apr-19 9:23am    
Thank You. Your solution was exactly what i was looking for, and thank you for the useful links, you are right i need to learn a lot more.

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