Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- USE master
- GO
- IF NOT EXISTS (
- SELECT name
- FROM sys.DATABASES
- WHERE name = N'Radiostation'
- )
- CREATE DATABASE [Radiostation]
- GO
- USE [Radiostation]
- CREATE TABLE dbo.Station
- (
- ID_station INT IDENTITY(1,1) NOT NULL PRIMARY KEY,
- Station_rating INT NOT NULL,
- Station_name NVARCHAR(40) NOT NULL
- );
- GO
- CREATE TABLE dbo.Presenter
- (
- ID_presenter INT IDENTITY(1,1) NOT NULL PRIMARY KEY,
- Presenter_rating INT NOT NULL,
- Presenter_name NVARCHAR(40) NOT NULL
- );
- GO
- CREATE TABLE dbo.Program
- (
- ID_prog INT IDENTITY(1,1) NOT NULL PRIMARY KEY,
- Prog_rating INT NOT NULL,
- Prog_name NVARCHAR(40) NOT NULL,
- ID_station INT NOT NULL,
- FOREIGN KEY(ID_station) REFERENCES dbo.Station (ID_station)
- );
- GO
- CREATE TABLE dbo.Edition_Program
- (
- ID_ed INT IDENTITY(1,1) NOT NULL PRIMARY KEY,
- Ed_rating INT NOT NULL,
- Start_time DATETIME NOT NULL,
- End_time DATETIME NOT NULL,
- ID_presenter INT NOT NULL,
- FOREIGN KEY(ID_presenter) REFERENCES dbo.Presenter (ID_presenter),
- ID_prog INT NOT NULL,
- FOREIGN KEY(ID_prog) REFERENCES dbo.Program (ID_prog)
- );
- GO
- CREATE TABLE dbo.Applicant
- (
- ID_applicant INT IDENTITY(1,1) NOT NULL PRIMARY KEY,
- Age INT NOT NULL,
- Name_applicant NVARCHAR(40) NOT NULL,
- Gender NVARCHAR(40) NOT NULL
- );
- GO
- CREATE TABLE dbo.Application
- (
- ID_application INT IDENTITY(1,1) NOT NULL PRIMARY KEY,
- ID_track INT NOT NULL,
- App_time DATETIME NOT NULL,
- ID_applicant INT NOT NULL,
- FOREIGN KEY(ID_applicant) REFERENCES dbo.Applicant (ID_applicant),
- ID_list INT NOT NULL
- );
- GO
- CREATE TABLE dbo.Application_list
- (
- ID_list INT IDENTITY(1,1) NOT NULL PRIMARY KEY,
- ID_ed INT REFERENCES dbo.Edition_Program (ID_ed) NOT NULL,
- ID_app INT REFERENCES dbo.Application (ID_application) NOT NULL
- );
- GO
- CREATE TABLE dbo.Genre
- (
- ID_genre INT IDENTITY(1,1) NOT NULL PRIMARY KEY,
- Genre_rating INT NOT NULL,
- Genre_name NVARCHAR(40) NOT NULL
- );
- GO
- CREATE TABLE dbo.Band
- (
- ID_band INT IDENTITY(1,1) NOT NULL PRIMARY KEY,
- Band_rating INT NOT NULL,
- Band_name NVARCHAR(40) NOT NULL
- );
- GO
- CREATE TABLE dbo.Album
- (
- ID_album INT IDENTITY(1,1) NOT NULL PRIMARY KEY,
- Album_rating INT NOT NULL,
- Album_name NVARCHAR(40) NOT NULL,
- ID_band INT NOT NULL,
- FOREIGN KEY(ID_band) REFERENCES dbo.Band (ID_band)
- );
- GO
- CREATE TABLE dbo.Track
- (
- ID_track INT IDENTITY(1,1) NOT NULL CONSTRAINT PK_Track PRIMARY KEY,
- Track_rating INT NOT NULL,
- Track_name NVARCHAR(40) NOT NULL,
- ID_band INT NOT NULL,
- ID_album INT NOT NULL,
- ID_genre INT NOT NULL
- FOREIGN KEY(ID_band) REFERENCES dbo.Band (ID_band),
- FOREIGN KEY(ID_album) REFERENCES dbo.Album (ID_album),
- FOREIGN KEY(ID_genre) REFERENCES dbo.Genre (ID_genre)
- );
- GO
- INSERT INTO dbo.Band(Band_rating, Band_name)
- VALUES (100, N'Wovenhand');
- GO
- INSERT INTO dbo.Band(Band_rating, Band_name)
- VALUES (90, N'Megadeth');
- GO
- DELETE dbo.Band
- WHERE Band_name = N'Wovenhand'
- DELETE dbo.Band
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement