Set Primary Key,Unique Key,Foreign Key
Set to Primary Key ,Foreign Key , Unique Key Sql Server DataBase Table Fields Using Visual Studio
DEMO
Primary Key
CREATE TABLE [dbo].[country] (
Unique Key
Next - Set Primary Key To id Field - Select Field - Right Click - Set Primary Key
Next - Unique Key - Assign - name Field
Next - Assign Another Table - Same Field of Unique Field Set Foreign Key
Set to Primary Key ,Foreign Key , Unique Key Sql Server DataBase Table Fields Using Visual Studio
DEMO
Primary Key
CREATE TABLE [dbo].[country] (
[id]
INT IDENTITY (1, 1) NOT NULL,
[name]
VARCHAR (50) NOT NULL,
[country] VARCHAR
(50) NOT NULL,
[amount]
VARCHAR (50) NOT NULL,
CONSTRAINT [PK_country] PRIMARY KEY CLUSTERED ([id] ASC),
);
CREATE TABLE [dbo].[country] (
[id]
INT IDENTITY (1, 1) NOT NULL,
[name]
VARCHAR (50) NOT NULL,
[country] VARCHAR
(50) NOT NULL,
[amount]
VARCHAR (50) NOT NULL,
CONSTRAINT [PK_country] PRIMARY KEY CLUSTERED ([id] ASC),
UNIQUE NONCLUSTERED ([name] ASC)
);
Foreign Key
CREATE TABLE [dbo].[register] (
[username] VARCHAR
(50) NOT NULL,
[password] VARCHAR
(50) NOT NULL,
[country]
VARCHAR (50) NOT NULL,
[name]
VARCHAR (50) NOT NULL,
CONSTRAINT [FK_reg_country] FOREIGN KEY ([name]) REFERENCES [dbo].[country] ([name])
);
First - Add - New Web Form - Create Database Tables - Fields
Next - Set Primary Key To id Field - Select Field - Right Click - Set Primary Key
Next - Unique Key - Assign - name Field
Next - Assign Another Table - Same Field of Unique Field Set Foreign Key
0 comments:
Post a Comment