Skip to content

Instantly share code, notes, and snippets.

@Injac
Created March 17, 2014 20:24
Show Gist options
  • Save Injac/9607583 to your computer and use it in GitHub Desktop.
Save Injac/9607583 to your computer and use it in GitHub Desktop.
Twitter Entitiy Model for SQL Server - to be used with Linq2Twitter (unofficial)
-- --------------------------------------------------
-- Entity Designer DDL Script for SQL Server 2005, 2008, 2012 and Azure
-- --------------------------------------------------
-- Date Created: 03/17/2014 21:20:43
SET QUOTED_IDENTIFIER OFF;
GO
USE [AdvancedTweeps];
GO
IF SCHEMA_ID(N'dbo') IS NULL EXECUTE(N'CREATE SCHEMA [dbo]');
GO
-- --------------------------------------------------
-- Dropping existing FOREIGN KEY constraints
-- --------------------------------------------------
IF OBJECT_ID(N'[dbo].[FK_Contributors_Coordinates]', 'F') IS NOT NULL
ALTER TABLE [dbo].[Contributors] DROP CONSTRAINT [FK_Contributors_Coordinates];
GO
IF OBJECT_ID(N'[dbo].[FK_Entities_Media]', 'F') IS NOT NULL
ALTER TABLE [dbo].[Entities] DROP CONSTRAINT [FK_Entities_Media];
GO
IF OBJECT_ID(N'[dbo].[FK_EntityHashtags_Entities]', 'F') IS NOT NULL
ALTER TABLE [dbo].[EntityHashtags] DROP CONSTRAINT [FK_EntityHashtags_Entities];
GO
IF OBJECT_ID(N'[dbo].[FK_EntityHashtags_Hashtags]', 'F') IS NOT NULL
ALTER TABLE [dbo].[EntityHashtags] DROP CONSTRAINT [FK_EntityHashtags_Hashtags];
GO
IF OBJECT_ID(N'[dbo].[FK_EntityUrls_Entities]', 'F') IS NOT NULL
ALTER TABLE [dbo].[EntityUrls] DROP CONSTRAINT [FK_EntityUrls_Entities];
GO
IF OBJECT_ID(N'[dbo].[FK_EntityUrls_Url]', 'F') IS NOT NULL
ALTER TABLE [dbo].[EntityUrls] DROP CONSTRAINT [FK_EntityUrls_Url];
GO
IF OBJECT_ID(N'[dbo].[FK_EntityUsermentions_Entities]', 'F') IS NOT NULL
ALTER TABLE [dbo].[EntityUsermentions] DROP CONSTRAINT [FK_EntityUsermentions_Entities];
GO
IF OBJECT_ID(N'[dbo].[FK_EntityUsermentions_Usermentions]', 'F') IS NOT NULL
ALTER TABLE [dbo].[EntityUsermentions] DROP CONSTRAINT [FK_EntityUsermentions_Usermentions];
GO
IF OBJECT_ID(N'[dbo].[FK_Media_Sizes]', 'F') IS NOT NULL
ALTER TABLE [dbo].[Media] DROP CONSTRAINT [FK_Media_Sizes];
GO
IF OBJECT_ID(N'[dbo].[FK_Sizes_Size]', 'F') IS NOT NULL
ALTER TABLE [dbo].[Sizes] DROP CONSTRAINT [FK_Sizes_Size];
GO
IF OBJECT_ID(N'[dbo].[FK_Sizes_Size1]', 'F') IS NOT NULL
ALTER TABLE [dbo].[Sizes] DROP CONSTRAINT [FK_Sizes_Size1];
GO
IF OBJECT_ID(N'[dbo].[FK_Sizes_Size2]', 'F') IS NOT NULL
ALTER TABLE [dbo].[Sizes] DROP CONSTRAINT [FK_Sizes_Size2];
GO
IF OBJECT_ID(N'[dbo].[FK_Sizes_Size3]', 'F') IS NOT NULL
ALTER TABLE [dbo].[Sizes] DROP CONSTRAINT [FK_Sizes_Size3];
GO
IF OBJECT_ID(N'[dbo].[FK_Tweets_Contributors]', 'F') IS NOT NULL
ALTER TABLE [dbo].[Tweets] DROP CONSTRAINT [FK_Tweets_Contributors];
GO
IF OBJECT_ID(N'[dbo].[FK_Tweets_Coordinates]', 'F') IS NOT NULL
ALTER TABLE [dbo].[Tweets] DROP CONSTRAINT [FK_Tweets_Coordinates];
GO
IF OBJECT_ID(N'[dbo].[FK_Tweets_Entities]', 'F') IS NOT NULL
ALTER TABLE [dbo].[Tweets] DROP CONSTRAINT [FK_Tweets_Entities];
GO
IF OBJECT_ID(N'[dbo].[FK_Tweets_Users]', 'F') IS NOT NULL
ALTER TABLE [dbo].[Tweets] DROP CONSTRAINT [FK_Tweets_Users];
GO
-- --------------------------------------------------
-- Dropping existing tables
-- --------------------------------------------------
IF OBJECT_ID(N'[dbo].[Contributors]', 'U') IS NOT NULL
DROP TABLE [dbo].[Contributors];
GO
IF OBJECT_ID(N'[dbo].[Coordinates]', 'U') IS NOT NULL
DROP TABLE [dbo].[Coordinates];
GO
IF OBJECT_ID(N'[dbo].[Entities]', 'U') IS NOT NULL
DROP TABLE [dbo].[Entities];
GO
IF OBJECT_ID(N'[dbo].[EntityHashtags]', 'U') IS NOT NULL
DROP TABLE [dbo].[EntityHashtags];
GO
IF OBJECT_ID(N'[dbo].[EntityUrls]', 'U') IS NOT NULL
DROP TABLE [dbo].[EntityUrls];
GO
IF OBJECT_ID(N'[dbo].[EntityUsermentions]', 'U') IS NOT NULL
DROP TABLE [dbo].[EntityUsermentions];
GO
IF OBJECT_ID(N'[dbo].[Hashtags]', 'U') IS NOT NULL
DROP TABLE [dbo].[Hashtags];
GO
IF OBJECT_ID(N'[dbo].[Media]', 'U') IS NOT NULL
DROP TABLE [dbo].[Media];
GO
IF OBJECT_ID(N'[dbo].[Size]', 'U') IS NOT NULL
DROP TABLE [dbo].[Size];
GO
IF OBJECT_ID(N'[dbo].[Sizes]', 'U') IS NOT NULL
DROP TABLE [dbo].[Sizes];
GO
IF OBJECT_ID(N'[dbo].[sysdiagrams]', 'U') IS NOT NULL
DROP TABLE [dbo].[sysdiagrams];
GO
IF OBJECT_ID(N'[dbo].[Tweets]', 'U') IS NOT NULL
DROP TABLE [dbo].[Tweets];
GO
IF OBJECT_ID(N'[dbo].[Url]', 'U') IS NOT NULL
DROP TABLE [dbo].[Url];
GO
IF OBJECT_ID(N'[dbo].[Usermentions]', 'U') IS NOT NULL
DROP TABLE [dbo].[Usermentions];
GO
IF OBJECT_ID(N'[dbo].[Users]', 'U') IS NOT NULL
DROP TABLE [dbo].[Users];
GO
-- --------------------------------------------------
-- Creating all tables
-- --------------------------------------------------
-- Creating table 'Contributors'
CREATE TABLE [dbo].[Contributors] (
[record_id] bigint IDENTITY(1,1) NOT NULL,
[id] bigint NOT NULL,
[ld_str] nvarchar(50) NOT NULL,
[screen_name] nvarchar(50) NOT NULL,
[coordinates] bigint NULL
);
GO
-- Creating table 'Coordinates'
CREATE TABLE [dbo].[Coordinates] (
[record_id] bigint IDENTITY(1,1) NOT NULL,
[coordinates] geography NOT NULL,
[type] nvarchar(50) NOT NULL
);
GO
-- Creating table 'Entities'
CREATE TABLE [dbo].[Entities] (
[record_id] bigint NOT NULL,
[media] bigint NULL,
[ID] int IDENTITY(1,1) NOT NULL
);
GO
-- Creating table 'EntityHashtags'
CREATE TABLE [dbo].[EntityHashtags] (
[record_id] bigint IDENTITY(1,1) NOT NULL,
[hashtag_id] bigint NOT NULL,
[entity_id] bigint NOT NULL
);
GO
-- Creating table 'EntityUrls'
CREATE TABLE [dbo].[EntityUrls] (
[record_id] bigint IDENTITY(1,1) NOT NULL,
[url_id] bigint NOT NULL,
[entity_id] bigint NOT NULL
);
GO
-- Creating table 'EntityUsermentions'
CREATE TABLE [dbo].[EntityUsermentions] (
[record_id] bigint IDENTITY(1,1) NOT NULL,
[entity_id] bigint NOT NULL,
[usermention_id] bigint NOT NULL
);
GO
-- Creating table 'Hashtags'
CREATE TABLE [dbo].[Hashtags] (
[record_id] bigint IDENTITY(1,1) NOT NULL,
[text] nvarchar(140) NOT NULL,
[index_start] smallint NOT NULL,
[index_end] smallint NOT NULL
);
GO
-- Creating table 'Media'
CREATE TABLE [dbo].[Media] (
[record_id] bigint IDENTITY(1,1) NOT NULL,
[display_url] nvarchar(500) NOT NULL,
[expanded_url] nvarchar(500) NOT NULL,
[id] bigint NOT NULL,
[id_str] nvarchar(50) NOT NULL,
[index_start] smallint NOT NULL,
[index_end] smallint NOT NULL,
[medial_url] nvarchar(500) NOT NULL,
[media_url_https] nvarchar(500) NOT NULL,
[sizes] bigint NOT NULL,
[source_status_id] bigint NOT NULL,
[source_status_id_str] nvarchar(50) NOT NULL,
[type] nvarchar(50) NOT NULL,
[url] nvarchar(500) NOT NULL
);
GO
-- Creating table 'Sizes'
CREATE TABLE [dbo].[Sizes] (
[record_id] bigint IDENTITY(1,1) NOT NULL,
[h] int NOT NULL,
[resize] nvarchar(50) NOT NULL,
[w] int NOT NULL
);
GO
-- Creating table 'Sizes1'
CREATE TABLE [dbo].[Sizes1] (
[record_id] bigint IDENTITY(1,1) NOT NULL,
[thumb] bigint NOT NULL,
[large] bigint NOT NULL,
[medium] bigint NOT NULL,
[small] bigint NOT NULL
);
GO
-- Creating table 'sysdiagrams'
CREATE TABLE [dbo].[sysdiagrams] (
[name] nvarchar(128) NOT NULL,
[principal_id] int NOT NULL,
[diagram_id] int IDENTITY(1,1) NOT NULL,
[version] int NULL,
[definition] varbinary(max) NULL
);
GO
-- Creating table 'Tweets'
CREATE TABLE [dbo].[Tweets] (
[record_id] bigint IDENTITY(1,1) NOT NULL,
[contributors] bigint NULL,
[coordinates] bigint NULL,
[created_at] datetimeoffset NOT NULL,
[current_user_retweet] bigint NULL,
[entities] bigint NULL,
[favourited] bit NOT NULL,
[id] bigint NOT NULL,
[id_str] nvarchar(50) NOT NULL,
[in_reply_to_screen_name] nvarchar(50) NOT NULL,
[in_reply_to_status_id] bigint NOT NULL,
[in_reply_to_status_id_str] nvarchar(50) NOT NULL,
[places] bigint NOT NULL,
[possibly_sensible] bit NULL,
[scopes] bigint NULL,
[retweet_count] bigint NOT NULL,
[source] varchar(max) NOT NULL,
[text] varchar(140) NOT NULL,
[tweet_user] bigint NOT NULL,
[withheld_copyright] bit NULL,
[whitheld_in_countries] int NULL,
[whitheld_scope] varchar(50) NULL
);
GO
-- Creating table 'Urls'
CREATE TABLE [dbo].[Urls] (
[record_id] bigint IDENTITY(1,1) NOT NULL,
[display_url] nvarchar(500) NOT NULL,
[expanded_url] nvarchar(500) NOT NULL,
[index_start] smallint NOT NULL,
[index_end] smallint NOT NULL,
[url1] nvarchar(500) NOT NULL
);
GO
-- Creating table 'Usermentions'
CREATE TABLE [dbo].[Usermentions] (
[record_id] bigint IDENTITY(1,1) NOT NULL,
[id] bigint NOT NULL,
[id_str] nvarchar(50) NOT NULL,
[index_start] smallint NOT NULL,
[index_end] smallint NOT NULL,
[name] nvarchar(50) NOT NULL,
[screen_Name] nvarchar(50) NOT NULL
);
GO
-- Creating table 'Users'
CREATE TABLE [dbo].[Users] (
[record_id] bigint IDENTITY(1,1) NOT NULL,
[contributors_enabled] bit NOT NULL,
[created_at] datetimeoffset NOT NULL,
[default_profile] bit NOT NULL,
[default_profile_image] bit NOT NULL,
[description] nvarchar(50) NULL,
[favourites_count] int NOT NULL,
[follow_request] bit NULL,
[following] bit NULL,
[followers_count] int NOT NULL,
[friends_count] int NULL,
[geo_enabled] bit NOT NULL,
[id] bigint NOT NULL,
[id_str] nvarchar(50) NOT NULL,
[is_translator] bit NOT NULL,
[location] nvarchar(200) NOT NULL,
[name] nvarchar(500) NOT NULL,
[profile_background_color] nvarchar(50) NOT NULL,
[profile_background_url] nvarchar(300) NOT NULL,
[profile_background_image_url_https] nvarchar(300) NOT NULL,
[profile_background_tile] bit NOT NULL,
[profile_image_url] nvarchar(300) NOT NULL,
[profile_image_url_https] nvarchar(300) NOT NULL,
[provile_link_color] nvarchar(50) NOT NULL,
[profile_sidebar_border_color] nvarchar(50) NOT NULL,
[profile_sidebar_fill_color] nvarchar(50) NOT NULL,
[profile_text_color] nvarchar(50) NOT NULL,
[profile_use_background_image] bit NOT NULL,
[protected] bit NOT NULL,
[screen_name] nvarchar(50) NOT NULL,
[show_all_inline_media] bit NOT NULL,
[status] bigint NOT NULL,
[statuses_count] bigint NOT NULL,
[time_zone] varchar(200) NOT NULL,
[utc_offset] int NOT NULL,
[verified] bit NOT NULL,
[withheld_in_countries] nvarchar(500) NOT NULL,
[whitheld_scope] nvarchar(50) NOT NULL,
[follows] bigint NOT NULL
);
GO
-- --------------------------------------------------
-- Creating all PRIMARY KEY constraints
-- --------------------------------------------------
-- Creating primary key on [record_id] in table 'Contributors'
ALTER TABLE [dbo].[Contributors]
ADD CONSTRAINT [PK_Contributors]
PRIMARY KEY CLUSTERED ([record_id] ASC);
GO
-- Creating primary key on [record_id] in table 'Coordinates'
ALTER TABLE [dbo].[Coordinates]
ADD CONSTRAINT [PK_Coordinates]
PRIMARY KEY CLUSTERED ([record_id] ASC);
GO
-- Creating primary key on [record_id] in table 'Entities'
ALTER TABLE [dbo].[Entities]
ADD CONSTRAINT [PK_Entities]
PRIMARY KEY CLUSTERED ([record_id] ASC);
GO
-- Creating primary key on [record_id] in table 'EntityHashtags'
ALTER TABLE [dbo].[EntityHashtags]
ADD CONSTRAINT [PK_EntityHashtags]
PRIMARY KEY CLUSTERED ([record_id] ASC);
GO
-- Creating primary key on [record_id] in table 'EntityUrls'
ALTER TABLE [dbo].[EntityUrls]
ADD CONSTRAINT [PK_EntityUrls]
PRIMARY KEY CLUSTERED ([record_id] ASC);
GO
-- Creating primary key on [record_id] in table 'EntityUsermentions'
ALTER TABLE [dbo].[EntityUsermentions]
ADD CONSTRAINT [PK_EntityUsermentions]
PRIMARY KEY CLUSTERED ([record_id] ASC);
GO
-- Creating primary key on [record_id] in table 'Hashtags'
ALTER TABLE [dbo].[Hashtags]
ADD CONSTRAINT [PK_Hashtags]
PRIMARY KEY CLUSTERED ([record_id] ASC);
GO
-- Creating primary key on [record_id] in table 'Media'
ALTER TABLE [dbo].[Media]
ADD CONSTRAINT [PK_Media]
PRIMARY KEY CLUSTERED ([record_id] ASC);
GO
-- Creating primary key on [record_id] in table 'Sizes'
ALTER TABLE [dbo].[Sizes]
ADD CONSTRAINT [PK_Sizes]
PRIMARY KEY CLUSTERED ([record_id] ASC);
GO
-- Creating primary key on [record_id] in table 'Sizes1'
ALTER TABLE [dbo].[Sizes1]
ADD CONSTRAINT [PK_Sizes1]
PRIMARY KEY CLUSTERED ([record_id] ASC);
GO
-- Creating primary key on [diagram_id] in table 'sysdiagrams'
ALTER TABLE [dbo].[sysdiagrams]
ADD CONSTRAINT [PK_sysdiagrams]
PRIMARY KEY CLUSTERED ([diagram_id] ASC);
GO
-- Creating primary key on [record_id] in table 'Tweets'
ALTER TABLE [dbo].[Tweets]
ADD CONSTRAINT [PK_Tweets]
PRIMARY KEY CLUSTERED ([record_id] ASC);
GO
-- Creating primary key on [record_id] in table 'Urls'
ALTER TABLE [dbo].[Urls]
ADD CONSTRAINT [PK_Urls]
PRIMARY KEY CLUSTERED ([record_id] ASC);
GO
-- Creating primary key on [record_id] in table 'Usermentions'
ALTER TABLE [dbo].[Usermentions]
ADD CONSTRAINT [PK_Usermentions]
PRIMARY KEY CLUSTERED ([record_id] ASC);
GO
-- Creating primary key on [record_id] in table 'Users'
ALTER TABLE [dbo].[Users]
ADD CONSTRAINT [PK_Users]
PRIMARY KEY CLUSTERED ([record_id] ASC);
GO
-- --------------------------------------------------
-- Creating all FOREIGN KEY constraints
-- --------------------------------------------------
-- Creating foreign key on [coordinates] in table 'Contributors'
ALTER TABLE [dbo].[Contributors]
ADD CONSTRAINT [FK_Contributors_Coordinates]
FOREIGN KEY ([coordinates])
REFERENCES [dbo].[Coordinates]
([record_id])
ON DELETE NO ACTION ON UPDATE NO ACTION;
-- Creating non-clustered index for FOREIGN KEY 'FK_Contributors_Coordinates'
CREATE INDEX [IX_FK_Contributors_Coordinates]
ON [dbo].[Contributors]
([coordinates]);
GO
-- Creating foreign key on [contributors] in table 'Tweets'
ALTER TABLE [dbo].[Tweets]
ADD CONSTRAINT [FK_Tweets_Contributors]
FOREIGN KEY ([contributors])
REFERENCES [dbo].[Contributors]
([record_id])
ON DELETE NO ACTION ON UPDATE NO ACTION;
-- Creating non-clustered index for FOREIGN KEY 'FK_Tweets_Contributors'
CREATE INDEX [IX_FK_Tweets_Contributors]
ON [dbo].[Tweets]
([contributors]);
GO
-- Creating foreign key on [coordinates] in table 'Tweets'
ALTER TABLE [dbo].[Tweets]
ADD CONSTRAINT [FK_Tweets_Coordinates]
FOREIGN KEY ([coordinates])
REFERENCES [dbo].[Coordinates]
([record_id])
ON DELETE NO ACTION ON UPDATE NO ACTION;
-- Creating non-clustered index for FOREIGN KEY 'FK_Tweets_Coordinates'
CREATE INDEX [IX_FK_Tweets_Coordinates]
ON [dbo].[Tweets]
([coordinates]);
GO
-- Creating foreign key on [media] in table 'Entities'
ALTER TABLE [dbo].[Entities]
ADD CONSTRAINT [FK_Entities_Media]
FOREIGN KEY ([media])
REFERENCES [dbo].[Media]
([record_id])
ON DELETE NO ACTION ON UPDATE NO ACTION;
-- Creating non-clustered index for FOREIGN KEY 'FK_Entities_Media'
CREATE INDEX [IX_FK_Entities_Media]
ON [dbo].[Entities]
([media]);
GO
-- Creating foreign key on [entity_id] in table 'EntityHashtags'
ALTER TABLE [dbo].[EntityHashtags]
ADD CONSTRAINT [FK_EntityHashtags_Entities]
FOREIGN KEY ([entity_id])
REFERENCES [dbo].[Entities]
([record_id])
ON DELETE CASCADE ON UPDATE NO ACTION;
-- Creating non-clustered index for FOREIGN KEY 'FK_EntityHashtags_Entities'
CREATE INDEX [IX_FK_EntityHashtags_Entities]
ON [dbo].[EntityHashtags]
([entity_id]);
GO
-- Creating foreign key on [entity_id] in table 'EntityUrls'
ALTER TABLE [dbo].[EntityUrls]
ADD CONSTRAINT [FK_EntityUrls_Entities]
FOREIGN KEY ([entity_id])
REFERENCES [dbo].[Entities]
([record_id])
ON DELETE NO ACTION ON UPDATE NO ACTION;
-- Creating non-clustered index for FOREIGN KEY 'FK_EntityUrls_Entities'
CREATE INDEX [IX_FK_EntityUrls_Entities]
ON [dbo].[EntityUrls]
([entity_id]);
GO
-- Creating foreign key on [entity_id] in table 'EntityUsermentions'
ALTER TABLE [dbo].[EntityUsermentions]
ADD CONSTRAINT [FK_EntityUsermentions_Entities]
FOREIGN KEY ([entity_id])
REFERENCES [dbo].[Entities]
([record_id])
ON DELETE NO ACTION ON UPDATE NO ACTION;
-- Creating non-clustered index for FOREIGN KEY 'FK_EntityUsermentions_Entities'
CREATE INDEX [IX_FK_EntityUsermentions_Entities]
ON [dbo].[EntityUsermentions]
([entity_id]);
GO
-- Creating foreign key on [entities] in table 'Tweets'
ALTER TABLE [dbo].[Tweets]
ADD CONSTRAINT [FK_Tweets_Entities]
FOREIGN KEY ([entities])
REFERENCES [dbo].[Entities]
([record_id])
ON DELETE NO ACTION ON UPDATE NO ACTION;
-- Creating non-clustered index for FOREIGN KEY 'FK_Tweets_Entities'
CREATE INDEX [IX_FK_Tweets_Entities]
ON [dbo].[Tweets]
([entities]);
GO
-- Creating foreign key on [hashtag_id] in table 'EntityHashtags'
ALTER TABLE [dbo].[EntityHashtags]
ADD CONSTRAINT [FK_EntityHashtags_Hashtags]
FOREIGN KEY ([hashtag_id])
REFERENCES [dbo].[Hashtags]
([record_id])
ON DELETE CASCADE ON UPDATE NO ACTION;
-- Creating non-clustered index for FOREIGN KEY 'FK_EntityHashtags_Hashtags'
CREATE INDEX [IX_FK_EntityHashtags_Hashtags]
ON [dbo].[EntityHashtags]
([hashtag_id]);
GO
-- Creating foreign key on [url_id] in table 'EntityUrls'
ALTER TABLE [dbo].[EntityUrls]
ADD CONSTRAINT [FK_EntityUrls_Url]
FOREIGN KEY ([url_id])
REFERENCES [dbo].[Urls]
([record_id])
ON DELETE NO ACTION ON UPDATE NO ACTION;
-- Creating non-clustered index for FOREIGN KEY 'FK_EntityUrls_Url'
CREATE INDEX [IX_FK_EntityUrls_Url]
ON [dbo].[EntityUrls]
([url_id]);
GO
-- Creating foreign key on [usermention_id] in table 'EntityUsermentions'
ALTER TABLE [dbo].[EntityUsermentions]
ADD CONSTRAINT [FK_EntityUsermentions_Usermentions]
FOREIGN KEY ([usermention_id])
REFERENCES [dbo].[Usermentions]
([record_id])
ON DELETE NO ACTION ON UPDATE NO ACTION;
-- Creating non-clustered index for FOREIGN KEY 'FK_EntityUsermentions_Usermentions'
CREATE INDEX [IX_FK_EntityUsermentions_Usermentions]
ON [dbo].[EntityUsermentions]
([usermention_id]);
GO
-- Creating foreign key on [sizes] in table 'Media'
ALTER TABLE [dbo].[Media]
ADD CONSTRAINT [FK_Media_Sizes]
FOREIGN KEY ([sizes])
REFERENCES [dbo].[Sizes1]
([record_id])
ON DELETE NO ACTION ON UPDATE NO ACTION;
-- Creating non-clustered index for FOREIGN KEY 'FK_Media_Sizes'
CREATE INDEX [IX_FK_Media_Sizes]
ON [dbo].[Media]
([sizes]);
GO
-- Creating foreign key on [thumb] in table 'Sizes1'
ALTER TABLE [dbo].[Sizes1]
ADD CONSTRAINT [FK_Sizes_Size]
FOREIGN KEY ([thumb])
REFERENCES [dbo].[Sizes]
([record_id])
ON DELETE NO ACTION ON UPDATE NO ACTION;
-- Creating non-clustered index for FOREIGN KEY 'FK_Sizes_Size'
CREATE INDEX [IX_FK_Sizes_Size]
ON [dbo].[Sizes1]
([thumb]);
GO
-- Creating foreign key on [large] in table 'Sizes1'
ALTER TABLE [dbo].[Sizes1]
ADD CONSTRAINT [FK_Sizes_Size1]
FOREIGN KEY ([large])
REFERENCES [dbo].[Sizes]
([record_id])
ON DELETE NO ACTION ON UPDATE NO ACTION;
-- Creating non-clustered index for FOREIGN KEY 'FK_Sizes_Size1'
CREATE INDEX [IX_FK_Sizes_Size1]
ON [dbo].[Sizes1]
([large]);
GO
-- Creating foreign key on [medium] in table 'Sizes1'
ALTER TABLE [dbo].[Sizes1]
ADD CONSTRAINT [FK_Sizes_Size2]
FOREIGN KEY ([medium])
REFERENCES [dbo].[Sizes]
([record_id])
ON DELETE NO ACTION ON UPDATE NO ACTION;
-- Creating non-clustered index for FOREIGN KEY 'FK_Sizes_Size2'
CREATE INDEX [IX_FK_Sizes_Size2]
ON [dbo].[Sizes1]
([medium]);
GO
-- Creating foreign key on [small] in table 'Sizes1'
ALTER TABLE [dbo].[Sizes1]
ADD CONSTRAINT [FK_Sizes_Size3]
FOREIGN KEY ([small])
REFERENCES [dbo].[Sizes]
([record_id])
ON DELETE NO ACTION ON UPDATE NO ACTION;
-- Creating non-clustered index for FOREIGN KEY 'FK_Sizes_Size3'
CREATE INDEX [IX_FK_Sizes_Size3]
ON [dbo].[Sizes1]
([small]);
GO
-- Creating foreign key on [tweet_user] in table 'Tweets'
ALTER TABLE [dbo].[Tweets]
ADD CONSTRAINT [FK_Tweets_Users]
FOREIGN KEY ([tweet_user])
REFERENCES [dbo].[Users]
([record_id])
ON DELETE NO ACTION ON UPDATE NO ACTION;
-- Creating non-clustered index for FOREIGN KEY 'FK_Tweets_Users'
CREATE INDEX [IX_FK_Tweets_Users]
ON [dbo].[Tweets]
([tweet_user]);
GO
-- --------------------------------------------------
-- Script has ended
-- --------------------------------------------------
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment