Skip to content

Instantly share code, notes, and snippets.

@AlexArchive
Created February 5, 2015 11:49
Show Gist options
  • Save AlexArchive/71e549152221b553f77e to your computer and use it in GitHub Desktop.
Save AlexArchive/71e549152221b553f77e to your computer and use it in GitHub Desktop.
USE Radio1;
DROP TABLE dbo.Records;
DROP TABLE dbo.Artists;
-- Create table dbo.Artists
CREATE TABLE dbo.Artists
(
id INT NOT NULL IDENTITY,
firstname NVARCHAR(20) NOT NULL,
lastname NVARCHAR(20) NOT NULL,
description NVARCHAR(2000) NULl,
nationality NVARCHAR(30) NULL,
dob DATETIME NULL,
CONSTRAINT Pk_Artists PRIMARY KEY(id)
);
-- Create table dbo.Records
CREATE TABLE dbo.Records
(
id INT NOT NULL IDENTITY,
name NVARCHAR(100) NOT NULL,
artistId INT NOT NULL,
CONSTRAINT Pk_Records PRIMARY KEY (id),
CONSTRAINT Fk_Records FOREIGN KEY (artistId)
REFERENCES dbo.Artists(id)
);
-- Populate table dbo.Artists
SET IDENTITY_INSERT dbo.Artists ON;
INSERT INTO dbo.Artists(id, firstname, lastname, description, nationality, dob)
VALUES (1, 'Ellie', 'Goulding', 'Elena Jane "Ellie" Goulding is an English singer, songwriter and multi-instrumentalist from Lyonshall, Herefordshire.', 'British', '19620219 00:00:00.000');
INSERT INTO dbo.Artists(id, firstname, lastname, description, nationality, dob)
VALUES (2, 'Mark', 'Ronson', 'Mark Daniel Ronson is an English musician, DJ, singer and music producer. ', 'British', '19800820 00:00:00.000')
-- Populate table dbo.Records
INSERT INTO dbo.Records(name, artistId)
VALUES ('Burn', 1);
INSERT INTO dbo.Records(name, artistId)
VALUES ('Lights', 1);
INSERT INTO dbo.Records(name, artistId)
VALUES ('Starry Eyed', 1);
INSERT INTO dbo.Records(name, artistId)
VALUES ('Hanging On', 1);
INSERT INTO dbo.Records(name, artistId)
VALUES ('Uptown Funk', 2);
INSERT INTO dbo.Records(name, artistId)
VALUES ('Bang Bang Bang', 2);
INSERT INTO dbo.Records(name, artistId)
VALUES ('Bang Bang Bang', 2);
SELECT *
FROM dbo.Records
SELECT *
FROM dbo.Artists
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment