Hello everyone here. I am new to vb.net database programming yet i want to create a point of sale software using it. So far I have created a local database, POSSdatabase.sdf , and I have 2 tables, Inventory and Transactions.

My problem is how do I relate these 2 tables? I have primary key Item Code in both tables. I want to make Inventory table as main maybe, and transaction will reference any data from it.

[Edit]
Another problem is how do I calculate value Quantity and Price column in Transaction to a new column Total in the same table.

Thanks for any help.

My problem is how do I relate these 2 tables? I have primary key Item Code in both tables. I want to make Inventory table as main maybe, and transaction will reference any data from it.

First, you need to know what primary and foreign keys are:

A primary key is a special type of constraint that identifies a single column or set of columns, which in turn uniquely identifies all rows in the table.A primary
key enforces entity integrity,meaning that rows are guaranteed to be unambiguous and
unique.

In the context of relational databases, a foreign key is a referential constraint between two tables.

Having said this, both tables must have a primary key. Then, since your Inventory table is the main, there would also be need for a column with the same name and datatype as the primary key in the transaction table that would reference it and this would be known as the foreign key on the Inventory table but the primary key on the transaction table and then you can use 'JOINS' to retrieve data from both tables

read here for more on primary and foreign keys

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.