Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- USE tempdb;
- IF OBJECT_ID('FK_Student_GroupStudent', 'F')IS NOT NULL
- ALTER TABLE Student DROP CONSTRAINT FK_Student_GroupStudent;
- IF OBJECT_ID('GroupStudent', 'U')IS NOT NULL
- DROP TABLE GroupStudent;
- IF OBJECT_ID('Student', 'U')IS NOT NULL
- DROP TABLE Student;
- IF OBJECT_ID('Score', 'U')IS NOT NULL
- DROP TABLE Score;
- CREATE TABLE GroupStudent (
- Id INT IDENTITY(1, 1),
- Number VARCHAR(11) NOT NULL
- )
- CREATE TABLE Student (
- Id INT IDENTITY(1, 1),
- GroupId INT NOT NULL,
- FIO NVARCHAR(1024) NOT NULL
- )
- ALTER TABLE GroupStudent ADD
- CONSTRAINT PK_GroupStudent PRIMARY KEY CLUSTERED
- (
- id
- ) ON [PRIMARY]
- ALTER TABLE Student ADD
- CONSTRAINT FK_Student_GroupStudent FOREIGN KEY
- (
- GroupId
- ) REFERENCES GroupStudent (
- Id
- )
- CREATE TABLE Score (
- StudentId INT NOT NULL,
- date DATE NOT NULL,
- Score TINYINT NOT NULL
- )
Advertisement
Add Comment
Please, Sign In to add comment