dakoz
Programmer
- Feb 2, 2002
- 74
- 0
- 0
im new in sql and i'd like 2 ask if this is correct or
if there is another way to do it?
CREATE TABLE [Topics] (
[Topic_Code] [int] NOT NULL ,
[Topic_Name] [char] (30) NOT NULL
)
The following SQL code creates the constraints for this table:
ALTER TABLE [Topics] WITH NOCHECK ADD
CONSTRAINT [PK_Topics] PRIMARY KEY CLUSTERED
(
[Topic_Code]
)
ALTER TABLE [Topics] WITH NOCHECK ADD
CONSTRAINT [CK_Topics] CHECK ([Topic_Code] >= 1 and [Topic_Code] <= 8)
The SQL code that we used in order to create this table is as follows:
CREATE TABLE [Referees] (
[Referee_ID] [int] NOT NULL ,
[Topic_responsible] [int] NOT NULL ,
[LastName] [char] (30) NOT NULL ,
[Middle] [char] (10) NULL ,
[Firstname] [char] (30) NOT NULL ,
[Phonenumber] [char] (20) NULL ,
[Address] [char] (60) NULL
)
The following SQL code creates the constraints for this table:
ALTER TABLE [Referees] WITH NOCHECK ADD
CONSTRAINT [PK_Referees] PRIMARY KEY CLUSTERED
(
[Referee_ID]
)
ALTER TABLE [Referees] WITH NOCHECK ADD
CONSTRAINT [IX_Referees] UNIQUE NONCLUSTERED
(
[Topic_responsible]
)
if there is another way to do it?
CREATE TABLE [Topics] (
[Topic_Code] [int] NOT NULL ,
[Topic_Name] [char] (30) NOT NULL
)
The following SQL code creates the constraints for this table:
ALTER TABLE [Topics] WITH NOCHECK ADD
CONSTRAINT [PK_Topics] PRIMARY KEY CLUSTERED
(
[Topic_Code]
)
ALTER TABLE [Topics] WITH NOCHECK ADD
CONSTRAINT [CK_Topics] CHECK ([Topic_Code] >= 1 and [Topic_Code] <= 8)
The SQL code that we used in order to create this table is as follows:
CREATE TABLE [Referees] (
[Referee_ID] [int] NOT NULL ,
[Topic_responsible] [int] NOT NULL ,
[LastName] [char] (30) NOT NULL ,
[Middle] [char] (10) NULL ,
[Firstname] [char] (30) NOT NULL ,
[Phonenumber] [char] (20) NULL ,
[Address] [char] (60) NULL
)
The following SQL code creates the constraints for this table:
ALTER TABLE [Referees] WITH NOCHECK ADD
CONSTRAINT [PK_Referees] PRIMARY KEY CLUSTERED
(
[Referee_ID]
)
ALTER TABLE [Referees] WITH NOCHECK ADD
CONSTRAINT [IX_Referees] UNIQUE NONCLUSTERED
(
[Topic_responsible]
)