How do we create relation ships between tables using a sql query?
im using MS Access and VB.net.
Please post an example,tht would b really appreciated.
First you need to understand a whole lot about keys and constraints.
Creating a Table with a Foreign Key Reference
This demonstrates how to create a table with a foreign key. In this example, I define two foreign key references within the definition of a CREATE TABLE statement:
CREATE TABLE Person.EmployeeCreditRating( EmployeeCreditRating int NOT NULL PRIMARY KEY, BusinessEntityID int NOT NULL, CreditRatingID int NOT NULL, CONSTRAINT FK_EmployeeCreditRating_Employee FOREIGN KEY(BusinessEntityID) REFERENCES HumanResources.Employee(BusinessEntityID), CONSTRAINT FK_EmployeeCreditRating_CreditRating FOREIGN KEY(CreditRatingID) REFERENCES Person.CreditRating(CreditRatingID) )
How It Works:
In this example, a table was created with two foreign key references. The first four lines of code
defined the table name and its three columns:
CREATE TABLE Person.EmployeeCreditRating( EmployeeCreditRating int NOT NULL PRIMARY KEY, BusinessEntityID int NOT NULL, CreditRatingID int NOT NULL,
On the next line, the name of the first foreign key constraint is defined (must be a unique name in the current database):
The constraint type is defined, followed by the table’s column (which will be referencing an outside primary key table):
The referenced table is defined, with that table’s primary key column defined in parentheses:
A second foreign key is then created for the CreditRatingID column, which references the primary key of the Person.CreditRating table:
CONSTRAINT FK_EmployeeCreditRating_CreditRating FOREIGN KEY(CreditRatingID) REFERENCES Person.CreditRating(CreditRatingID)
thanks for the reply.,i have got a lil idea how to we do this by seeing at ur code.and btw,how do v create one-one,one-many,many-many relationships here?
Hi, as I was told that my code doesn’t scale well at all, I thought perhaps I’d try to get a better understanding of interfaces/abstract classes and classes and the relationship between them.
I don’t want at this stage work on a big separate project as I've already got plenty ...
Hey, so I wanna ask how I need to create a method who will remove word if in that word is 2 same chars. Example: "Potato" in this word there is a 2 "o" chars so this word will need to be removed. "Forum" in this word there is no ...
Hi I'm having a problem implementing a mini shopping cart drop down in the header to show the user all the products they have in their shopping cart. It seems the only solution for this is Ajax, and I've looked all over and can't find anything that I could possibly ...