Base de datos de spotify
Codigo para las tablas
CREATE DATABASE Spotify
go
use Spotify
create table Musicas(
Musica_ID int IDENTITY (1,1) PRIMARY KEY,
Apellidos varchar(50),
Nombre varchar (50),
Fec_Nacimientos nvarchar(20),
Lugar_nacimiento varchar(50),
--
create table Grup_Miembros(
Musica_ID INT,
Atista_ID INT IDENTITY (1,1) PRIMARY KEY,
Unido varchar(50),
Izquierdo Varchar(50),
--
create table Artistas (
Artista_ID int IDENTITY (1,1) PRIMARY KEY ,
Nombre varchar (50),
)
--
create table Etiquetas(
Etiqueta_ID int IDENTITY (1,1) PRIMARY KEY ,
Nombre varchar (50),
--
create table Albunes(
Album_ID int IDENTITY (1,1) PRIMARY KEY,
Titulo varchar(50),
Artista_ID int,
Año int,
Etiqueta_ID int,
--
create table Pistas(
Album_ID int,
Num_Pista int IDENTITY (1,1) PRIMARY KEY,
Titulo varchar (50),
Genero_ID int,
Duracion varchar(50),
--
create table Generos(
Genero_ID int IDENTITY (1,1) PRIMARY KEY,
Nombre Varchar(50),
--
create table Album_Reseñas(
Reseña_ID int IDENTITY (1,1) PRIMARY KEY ,
Album_ID int,
Clasificacion varchar(50),
Comentario varchar(50),
--
create table Reseñas(
Reseña_ID int IDENTITY (1,1) PRIMARY KEY ,
unido varchar (50),
--
create table Reseñas_Pistas(
Reseña_ID int,
Album_ID int,
Num_Pista varchar(50),
Clasificacion varchar(50),
Comentario varchar(50),
Scritpts
USE [master]
GO
/****** Object: Database [Spotify] Script Date: 13/2/2024 23:26:57 ******/
CREATE DATABASE [Spotify]
CONTAINMENT = NONE
ON PRIMARY
( NAME = N'Spotify', FILENAME = N'C:\Program Files\Microsoft SQL
Server\MSSQL16.MSSQLSERVER\MSSQL\DATA\Spotify.mdf' , SIZE = 8192KB , MAXSIZE = UNLIMITED,
FILEGROWTH = 65536KB )
LOG ON
( NAME = N'Spotify_log', FILENAME = N'C:\Program Files\Microsoft SQL
Server\MSSQL16.MSSQLSERVER\MSSQL\DATA\Spotify_log.ldf' , SIZE = 8192KB , MAXSIZE = 2048GB ,
FILEGROWTH = 65536KB )
WITH CATALOG_COLLATION = DATABASE_DEFAULT, LEDGER = OFF
GO
ALTER DATABASE [Spotify] SET COMPATIBILITY_LEVEL = 160
GO
IF (1 = FULLTEXTSERVICEPROPERTY('IsFullTextInstalled'))
begin
EXEC [Spotify].[dbo].[sp_fulltext_database] @action = 'enable'
end
GO
ALTER DATABASE [Spotify] SET ANSI_NULL_DEFAULT OFF
GO
ALTER DATABASE [Spotify] SET ANSI_NULLS OFF
GO
ALTER DATABASE [Spotify] SET ANSI_PADDING OFF
GO
ALTER DATABASE [Spotify] SET ANSI_WARNINGS OFF
GO
ALTER DATABASE [Spotify] SET ARITHABORT OFF
GO
ALTER DATABASE [Spotify] SET AUTO_CLOSE OFF
GO
ALTER DATABASE [Spotify] SET AUTO_SHRINK OFF
GO
ALTER DATABASE [Spotify] SET AUTO_UPDATE_STATISTICS ON
GO
ALTER DATABASE [Spotify] SET CURSOR_CLOSE_ON_COMMIT OFF
GO
ALTER DATABASE [Spotify] SET CURSOR_DEFAULT GLOBAL
GO
ALTER DATABASE [Spotify] SET CONCAT_NULL_YIELDS_NULL OFF
GO
ALTER DATABASE [Spotify] SET NUMERIC_ROUNDABORT OFF
GO
ALTER DATABASE [Spotify] SET QUOTED_IDENTIFIER OFF
GO
ALTER DATABASE [Spotify] SET RECURSIVE_TRIGGERS OFF
GO
ALTER DATABASE [Spotify] SET ENABLE_BROKER
GO
ALTER DATABASE [Spotify] SET AUTO_UPDATE_STATISTICS_ASYNC OFF
GO
ALTER DATABASE [Spotify] SET DATE_CORRELATION_OPTIMIZATION OFF
GO
ALTER DATABASE [Spotify] SET TRUSTWORTHY OFF
GO
ALTER DATABASE [Spotify] SET ALLOW_SNAPSHOT_ISOLATION OFF
GO
ALTER DATABASE [Spotify] SET PARAMETERIZATION SIMPLE
GO
ALTER DATABASE [Spotify] SET READ_COMMITTED_SNAPSHOT OFF
GO
ALTER DATABASE [Spotify] SET HONOR_BROKER_PRIORITY OFF
GO
ALTER DATABASE [Spotify] SET RECOVERY FULL
GO
ALTER DATABASE [Spotify] SET MULTI_USER
GO
ALTER DATABASE [Spotify] SET PAGE_VERIFY CHECKSUM
GO
ALTER DATABASE [Spotify] SET DB_CHAINING OFF
GO
ALTER DATABASE [Spotify] SET FILESTREAM( NON_TRANSACTED_ACCESS = OFF )
GO
ALTER DATABASE [Spotify] SET TARGET_RECOVERY_TIME = 60 SECONDS
GO
ALTER DATABASE [Spotify] SET DELAYED_DURABILITY = DISABLED
GO
ALTER DATABASE [Spotify] SET ACCELERATED_DATABASE_RECOVERY = OFF
GO
EXEC sys.sp_db_vardecimal_storage_format N'Spotify', N'ON'
GO
ALTER DATABASE [Spotify] SET QUERY_STORE = ON
GO
ALTER DATABASE [Spotify] SET QUERY_STORE (OPERATION_MODE = READ_WRITE,
CLEANUP_POLICY = (STALE_QUERY_THRESHOLD_DAYS = 30), DATA_FLUSH_INTERVAL_SECONDS =
900, INTERVAL_LENGTH_MINUTES = 60, MAX_STORAGE_SIZE_MB = 1000, QUERY_CAPTURE_MODE
= AUTO, SIZE_BASED_CLEANUP_MODE = AUTO, MAX_PLANS_PER_QUERY = 200,
WAIT_STATS_CAPTURE_MODE = ON)
GO
USE [Spotify]
GO
/****** Object: Table [dbo].[Album_Reseñas] Script Date: 13/2/2024 23:26:57 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Album_Reseñas](
[Reseña_ID] [int] IDENTITY(1,1) NOT NULL,
[Album_ID] [int] NULL,
[Clasificacion] [varchar](50) NULL,
[Comentario] [varchar](50) NULL,
CONSTRAINT [PK_Album_Reseñas] PRIMARY KEY CLUSTERED
[Reseña_ID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF,
ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF)
ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object: Table [dbo].[Albunes] Script Date: 13/2/2024 23:26:57 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Albunes](
[Album_ID] [int] IDENTITY(1,1) NOT NULL,
[Titulo] [varchar](50) NULL,
[Artista_ID] [int] NULL,
[Año] [int] NULL,
[Etiqueta_ID] [int] NULL,
PRIMARY KEY CLUSTERED
[Album_ID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF,
ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF)
ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object: Table [dbo].[Artistas] Script Date: 13/2/2024 23:26:57 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Artistas](
[Artista_ID] [int] IDENTITY(1,1) NOT NULL,
[Nombre] [varchar](50) NULL,
PRIMARY KEY CLUSTERED
[Artista_ID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF,
ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF)
ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object: Table [dbo].[Etiquetas] Script Date: 13/2/2024 23:26:57 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Etiquetas](
[Etiqueta_ID] [int] IDENTITY(1,1) NOT NULL,
[Nombre] [varchar](50) NULL,
PRIMARY KEY CLUSTERED
[Etiqueta_ID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF,
ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF)
ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object: Table [dbo].[Generos] Script Date: 13/2/2024 23:26:57 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Generos](
[Genero_ID] [int] IDENTITY(1,1) NOT NULL,
[Nombre] [varchar](50) NULL,
PRIMARY KEY CLUSTERED
[Genero_ID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF,
ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF)
ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object: Table [dbo].[Grup_Miembros] Script Date: 13/2/2024 23:26:57 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Grup_Miembros](
[Musica_ID] [int] NULL,
[Atista_ID] [int] IDENTITY(1,1) NOT NULL,
[Unido] [varchar](50) NULL,
[Izquierdo] [varchar](50) NULL,
PRIMARY KEY CLUSTERED
[Atista_ID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF,
ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF)
ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object: Table [dbo].[Muiscas] Script Date: 13/2/2024 23:26:57 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Muiscas](
[Musica_ID] [int] IDENTITY(1,1) NOT NULL,
[Apellidos] [varchar](50) NULL,
[Nombre] [varchar](50) NULL,
[Fec_Nacimientos] [nvarchar](20) NULL,
[Lugar_nacimiento] [varchar](50) NULL,
PRIMARY KEY CLUSTERED
[Musica_ID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF,
ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF)
ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object: Table [dbo].[Pistas] Script Date: 13/2/2024 23:26:57 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Pistas](
[Album_ID] [int] NULL,
[Num_Pista] [int] IDENTITY(1,1) NOT NULL,
[Titulo] [varchar](50) NULL,
[Genero_ID] [int] NULL,
[Duracion] [varchar](50) NULL,
PRIMARY KEY CLUSTERED
[Num_Pista] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF,
ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF)
ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object: Table [dbo].[Reseñas] Script Date: 13/2/2024 23:26:57 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Reseñas](
[Reseña_ID] [int] IDENTITY(1,1) NOT NULL,
[unido] [varchar](50) NULL,
PRIMARY KEY CLUSTERED
[Reseña_ID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF,
ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF)
ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object: Table [dbo].[Reseñas_Pistas] Script Date: 13/2/2024 23:26:57 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Reseñas_Pistas](
[Reseña_ID] [int] NULL,
[Album_ID] [int] NULL,
[Num_Pista] [varchar](50) NULL,
[Clasificacion] [varchar](50) NULL,
[Comentario] [varchar](50) NULL
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[Albunes] WITH CHECK ADD CONSTRAINT [FK_Albunes_Artistas1] FOREIGN
KEY([Artista_ID])
REFERENCES [dbo].[Artistas] ([Artista_ID])
GO
ALTER TABLE [dbo].[Albunes] CHECK CONSTRAINT [FK_Albunes_Artistas1]
GO
ALTER TABLE [dbo].[Albunes] WITH CHECK ADD CONSTRAINT [FK_Albunes_Etiquetas1] FOREIGN
KEY([Etiqueta_ID])
REFERENCES [dbo].[Etiquetas] ([Etiqueta_ID])
GO
ALTER TABLE [dbo].[Albunes] CHECK CONSTRAINT [FK_Albunes_Etiquetas1]
GO
ALTER TABLE [dbo].[Artistas] WITH CHECK ADD CONSTRAINT [FK_Artistas_Grup_Miembros1]
FOREIGN KEY([Artista_ID])
REFERENCES [dbo].[Grup_Miembros] ([Atista_ID])
GO
ALTER TABLE [dbo].[Artistas] CHECK CONSTRAINT [FK_Artistas_Grup_Miembros1]
GO
ALTER TABLE [dbo].[Grup_Miembros] WITH CHECK ADD CONSTRAINT
[FK_Grup_Miembros_Muiscas] FOREIGN KEY([Musica_ID])
REFERENCES [dbo].[Muiscas] ([Musica_ID])
GO
ALTER TABLE [dbo].[Grup_Miembros] CHECK CONSTRAINT [FK_Grup_Miembros_Muiscas]
GO
ALTER TABLE [dbo].[Grup_Miembros] WITH CHECK ADD CONSTRAINT
[FK_Grup_Miembros_Muiscas1] FOREIGN KEY([Musica_ID])
REFERENCES [dbo].[Muiscas] ([Musica_ID])
GO
ALTER TABLE [dbo].[Grup_Miembros] CHECK CONSTRAINT [FK_Grup_Miembros_Muiscas1]
GO
ALTER TABLE [dbo].[Pistas] WITH CHECK ADD CONSTRAINT [FK_Pistas_Albunes1] FOREIGN
KEY([Album_ID])
REFERENCES [dbo].[Albunes] ([Album_ID])
GO
ALTER TABLE [dbo].[Pistas] CHECK CONSTRAINT [FK_Pistas_Albunes1]
GO
ALTER TABLE [dbo].[Pistas] WITH CHECK ADD CONSTRAINT [FK_Pistas_Generos1] FOREIGN
KEY([Genero_ID])
REFERENCES [dbo].[Generos] ([Genero_ID])
GO
ALTER TABLE [dbo].[Pistas] CHECK CONSTRAINT [FK_Pistas_Generos1]
GO
ALTER TABLE [dbo].[Reseñas] WITH CHECK ADD CONSTRAINT [FK_Reseñas_Album_Reseñas1]
FOREIGN KEY([Reseña_ID])
REFERENCES [dbo].[Album_Reseñas] ([Reseña_ID])
GO
ALTER TABLE [dbo].[Reseñas] CHECK CONSTRAINT [FK_Reseñas_Album_Reseñas1]
GO
ALTER TABLE [dbo].[Reseñas_Pistas] WITH CHECK ADD CONSTRAINT [FK_Reseñas_Pistas_Pistas1]
FOREIGN KEY([Album_ID])
REFERENCES [dbo].[Pistas] ([Num_Pista])
GO
ALTER TABLE [dbo].[Reseñas_Pistas] CHECK CONSTRAINT [FK_Reseñas_Pistas_Pistas1]
GO
ALTER TABLE [dbo].[Reseñas_Pistas] WITH CHECK ADD CONSTRAINT [FK_Reseñas_Pistas_Reseñas1]
FOREIGN KEY([Reseña_ID])
REFERENCES [dbo].[Reseñas] ([Reseña_ID])
GO
ALTER TABLE [dbo].[Reseñas_Pistas] CHECK CONSTRAINT [FK_Reseñas_Pistas_Reseñas1]
GO
USE [master]
GO
ALTER DATABASE [Spotify] SET READ_WRITE
GO
DIAGRAMA