USE [master]
GO
/****** Object:  Database [amarillas]    Script Date: 12/11/2014 16:01:18 ******/
CREATE DATABASE [amarillas]
GO
ALTER DATABASE [amarillas] SET COMPATIBILITY_LEVEL = 100
GO
IF (1 = FULLTEXTSERVICEPROPERTY('IsFullTextInstalled'))
begin
EXEC [amarillas].[dbo].[sp_fulltext_database] @action = 'enable'
end
GO
ALTER DATABASE [amarillas] SET ANSI_NULL_DEFAULT OFF
GO
ALTER DATABASE [amarillas] SET ANSI_NULLS OFF
GO
ALTER DATABASE [amarillas] SET ANSI_PADDING OFF
GO
ALTER DATABASE [amarillas] SET ANSI_WARNINGS OFF
GO
ALTER DATABASE [amarillas] SET ARITHABORT OFF
GO
ALTER DATABASE [amarillas] SET AUTO_CLOSE OFF
GO
ALTER DATABASE [amarillas] SET AUTO_CREATE_STATISTICS ON
GO
ALTER DATABASE [amarillas] SET AUTO_SHRINK OFF
GO
ALTER DATABASE [amarillas] SET AUTO_UPDATE_STATISTICS ON
GO
ALTER DATABASE [amarillas] SET CURSOR_CLOSE_ON_COMMIT OFF
GO
ALTER DATABASE [amarillas] SET CURSOR_DEFAULT  GLOBAL
GO
ALTER DATABASE [amarillas] SET CONCAT_NULL_YIELDS_NULL OFF
GO
ALTER DATABASE [amarillas] SET NUMERIC_ROUNDABORT OFF
GO
ALTER DATABASE [amarillas] SET QUOTED_IDENTIFIER OFF
GO
ALTER DATABASE [amarillas] SET RECURSIVE_TRIGGERS OFF
GO
ALTER DATABASE [amarillas] SET  DISABLE_BROKER
GO
ALTER DATABASE [amarillas] SET AUTO_UPDATE_STATISTICS_ASYNC OFF
GO
ALTER DATABASE [amarillas] SET DATE_CORRELATION_OPTIMIZATION OFF
GO
ALTER DATABASE [amarillas] SET TRUSTWORTHY OFF
GO
ALTER DATABASE [amarillas] SET ALLOW_SNAPSHOT_ISOLATION OFF
GO
ALTER DATABASE [amarillas] SET PARAMETERIZATION SIMPLE
GO
ALTER DATABASE [amarillas] SET READ_COMMITTED_SNAPSHOT OFF
GO
ALTER DATABASE [amarillas] SET HONOR_BROKER_PRIORITY OFF
GO
ALTER DATABASE [amarillas] SET  READ_WRITE
GO
ALTER DATABASE [amarillas] SET RECOVERY FULL
GO
ALTER DATABASE [amarillas] SET  MULTI_USER
GO
ALTER DATABASE [amarillas] SET PAGE_VERIFY CHECKSUM
GO
ALTER DATABASE [amarillas] SET DB_CHAINING OFF
GO
USE [amarillas]
GO
/****** Object:  Table [dbo].[tipo_direccion]    Script Date: 12/11/2014 16:01:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[tipo_direccion](
	[codigo] [int] IDENTITY(1,1) NOT NULL,
	[descripcion] [varchar](255) NULL,
PRIMARY KEY CLUSTERED 
(
	[codigo] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[telefono]    Script Date: 12/11/2014 16:01:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[telefono](
	[codigo] [int] IDENTITY(1,1) NOT NULL,
	[codigo_area] [char](8) NULL,
	[telefono] [char](15) NOT NULL,
 CONSTRAINT [PK_telefono] PRIMARY KEY CLUSTERED 
(
	[codigo] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[cobertura]    Script Date: 12/11/2014 16:01:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[cobertura](
	[codigo] [int] IDENTITY(1,1) NOT NULL,
	[nombre] [varchar](100) NOT NULL,
	[tipo] [varchar](50) NOT NULL,
	[localizacion] [geography] NOT NULL,
	[superior] [int] NULL,
 CONSTRAINT [PK_cobertura] PRIMARY KEY CLUSTERED 
(
	[codigo] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[cliente]    Script Date: 12/11/2014 16:01:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[cliente](
	[rut] [char](12) NOT NULL,
	[nombre] [varchar](300) NULL,
	[razon_social] [varchar](300) NULL,
 CONSTRAINT [PK_cliente] PRIMARY KEY CLUSTERED 
(
	[rut] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[categoria]    Script Date: 12/11/2014 16:01:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[categoria](
	[codigo] [int] IDENTITY(1,1) NOT NULL,
	[nombre] [varchar](150) NULL,
 CONSTRAINT [PK_categoria] PRIMARY KEY CLUSTERED 
(
	[codigo] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[anunciador]    Script Date: 12/11/2014 16:01:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[anunciador](
	[codigo] [int] IDENTITY(1,1) NOT NULL,
	[rut_cliente] [char](12) NOT NULL,
	[rut] [char](12) NOT NULL,
	[nombre] [varchar](300) NULL,
	[razon_social] [varchar](300) NULL,
 CONSTRAINT [PK_anunciador] PRIMARY KEY CLUSTERED 
(
	[codigo] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[calle]    Script Date: 12/11/2014 16:01:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[calle](
	[codigo] [int] IDENTITY(1,1) NOT NULL,
	[codigo_cobertura] [int] NULL,
	[nombre] [varchar](100) NOT NULL,
	[localizacion] [geography] NULL,
 CONSTRAINT [PK_calle] PRIMARY KEY CLUSTERED 
(
	[codigo] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
CREATE NONCLUSTERED INDEX [IDX_nombre] ON [dbo].[calle] 
(
	[nombre] ASC
)
INCLUDE ( [codigo_cobertura]) WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[anuncio]    Script Date: 18/02/2015 16:01:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[anuncio](
	[codigo] [int] IDENTITY(1,1) NOT NULL,
	[codigo_anunciador] [int] NOT NULL,
	[titulo] [varchar](2500) NULL,
	[descripcion] [varchar](5000) NULL,
	[meco] [varchar](15) NOT NULL,
	[fin_vigencia] [datetime] NULL,
 CONSTRAINT [PK_anuncio] PRIMARY KEY CLUSTERED 
(
	[codigo] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[direccion]    Script Date: 12/11/2014 16:01:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[direccion](
	[codigo] [int] IDENTITY(1,1) NOT NULL,
	[codigo_calle] [int] NOT NULL,
	[linea1] [varchar](100) NULL,
	[linea2] [varchar](100) NULL,
	[localizacion] [geography] NULL,
 CONSTRAINT [PK_direccion] PRIMARY KEY CLUSTERED 
(
	[codigo] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
CREATE NONCLUSTERED INDEX [IDX_publicacion] ON [dbo].[direccion] 
(
	[codigo_calle] ASC
)
INCLUDE ( [codigo],
[linea1],
[localizacion]) WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[media]    Script Date: 12/11/2014 16:01:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[media](
	[codigo] [int] IDENTITY(1,1) NOT NULL,
	[codigo_anuncio] [int] NOT NULL,
	[tipo_item] [char](8) NOT NULL,
	[titulo] [varchar](200) NULL,
	[url_contenido] [varchar](500) NULL,
 CONSTRAINT [PK_media] PRIMARY KEY CLUSTERED 
(
	[codigo] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
CREATE NONCLUSTERED INDEX [IDX_cati] ON [dbo].[media] 
(
	[codigo_anuncio] ASC,
	[tipo_item] ASC
)
INCLUDE ( [titulo],
[url_contenido]) WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IDX_full] ON [dbo].[media] 
(
	[codigo_anuncio] ASC,
	[tipo_item] ASC,
	[titulo] ASC,
	[url_contenido] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[marca]    Script Date: 12/11/2014 16:01:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[marca](
	[codigo] [int] IDENTITY(1,1) NOT NULL,
	[codigo_anuncio] [int] NOT NULL,
	[glosa] [varchar](2500) NOT NULL,
 CONSTRAINT [PK_marca] PRIMARY KEY CLUSTERED 
(
	[codigo] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[punto_contacto]    Script Date: 12/11/2014 16:01:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[punto_contacto](
	[codigo] [int] IDENTITY(1,1) NOT NULL,
	[codigo_anuncio] [int] NOT NULL,
	[codigo_direccion] [int] NULL,
	[descripcion] [varchar](100) NOT NULL,
 CONSTRAINT [PK_punto_contacto] PRIMARY KEY CLUSTERED 
(
	[codigo] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[productos_servicios]    Script Date: 12/11/2014 16:01:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[productos_servicios](
	[codigo] [int] IDENTITY(1,1) NOT NULL,
	[codigo_anuncio] [int] NOT NULL,
	[glosa] [varchar](8000) NULL,
 CONSTRAINT [PK_productos_servicios] PRIMARY KEY CLUSTERED 
(
	[codigo] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[uso_direccion]    Script Date: 12/11/2014 16:01:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[uso_direccion](
	[codigo_direccion] [int] NOT NULL,
	[codigo_tipo_direccion] [int] NOT NULL
) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IDX_cd] ON [dbo].[uso_direccion] 
(
	[codigo_direccion] ASC
)
INCLUDE ( [codigo_tipo_direccion]) WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[formas_pago]    Script Date: 12/11/2014 16:01:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[formas_pago](
	[codigo] [int] IDENTITY(1,1) NOT NULL,
	[codigo_anuncio] [int] NULL,
	[glosa] [varchar](2500) NULL,
 CONSTRAINT [PK_formas_pago] PRIMARY KEY CLUSTERED 
(
	[codigo] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[telefono_punto_contacto]    Script Date: 12/11/2014 16:01:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[telefono_punto_contacto](
	[codigo_telefono] [int] NOT NULL,
	[codigo_punto_contacto] [int] NOT NULL
) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IDX_cpc] ON [dbo].[telefono_punto_contacto] 
(
	[codigo_punto_contacto] ASC
)
INCLUDE ( [codigo_telefono]) WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[posicion]    Script Date: 12/11/2014 16:01:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[posicion](
	[codigo] [int] IDENTITY(1,1) NOT NULL,
	[codigo_punto_contacto] [int] NOT NULL,
	[codigo_categoria] [int] NOT NULL,
	[codigo_cobertura] [int] NOT NULL,
	[prioridad] [smallint] NOT NULL,
 CONSTRAINT [PK_posicion] PRIMARY KEY CLUSTERED 
(
	[codigo] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IDX_cpdc] ON [dbo].[posicion] 
(
	[codigo_punto_contacto] ASC
)
INCLUDE ( [codigo],
[codigo_categoria],
[codigo_cobertura],
[prioridad]) WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[horario]    Script Date: 12/11/2014 16:01:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[horario](
	[codigo] [int] IDENTITY(1,1) NOT NULL,
	[codigo_punto_contacto] [int] NOT NULL,
	[glosa] [varchar](5000) NOT NULL,
 CONSTRAINT [PK_horario] PRIMARY KEY CLUSTERED 
(
	[codigo] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[horario_rango]    Script Date: 12/11/2014 16:01:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[horario_rango](
	[codigo_horario] [int] NOT NULL,
	[dia] [varchar](200) NULL,
	[desde] [char](8) NULL,
	[hasta] [char](8) NULL
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
CREATE NONCLUSTERED INDEX [IDX_ch] ON [dbo].[horario_rango] 
(
	[codigo_horario] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
GO
/****** Object:  ForeignKey [FK_cobertura_cobertura]    Script Date: 12/11/2014 16:01:19 ******/
ALTER TABLE [dbo].[cobertura]  WITH CHECK ADD  CONSTRAINT [FK_cobertura_cobertura] FOREIGN KEY([superior])
REFERENCES [dbo].[cobertura] ([codigo])
GO
ALTER TABLE [dbo].[cobertura] CHECK CONSTRAINT [FK_cobertura_cobertura]
GO
/****** Object:  ForeignKey [FK_anunciador_cliente]    Script Date: 12/11/2014 16:01:19 ******/
ALTER TABLE [dbo].[anunciador]  WITH CHECK ADD  CONSTRAINT [FK_anunciador_cliente] FOREIGN KEY([rut_cliente])
REFERENCES [dbo].[cliente] ([rut])
GO
ALTER TABLE [dbo].[anunciador] CHECK CONSTRAINT [FK_anunciador_cliente]
GO
/****** Object:  ForeignKey [FK_calle_cobertura]    Script Date: 12/11/2014 16:01:19 ******/
ALTER TABLE [dbo].[calle]  WITH CHECK ADD  CONSTRAINT [FK_calle_cobertura] FOREIGN KEY([codigo_cobertura])
REFERENCES [dbo].[cobertura] ([codigo])
GO
ALTER TABLE [dbo].[calle] CHECK CONSTRAINT [FK_calle_cobertura]
GO
/****** Object:  ForeignKey [FK_anuncio_anunciador]    Script Date: 12/11/2014 16:01:19 ******/
ALTER TABLE [dbo].[anuncio]  WITH CHECK ADD  CONSTRAINT [FK_anuncio_anunciador] FOREIGN KEY([codigo_anunciador])
REFERENCES [dbo].[anunciador] ([codigo])
GO
ALTER TABLE [dbo].[anuncio] CHECK CONSTRAINT [FK_anuncio_anunciador]
GO
/****** Object:  ForeignKey [FK_direccion_calle]    Script Date: 12/11/2014 16:01:19 ******/
ALTER TABLE [dbo].[direccion]  WITH CHECK ADD  CONSTRAINT [FK_direccion_calle] FOREIGN KEY([codigo_calle])
REFERENCES [dbo].[calle] ([codigo])
GO
ALTER TABLE [dbo].[direccion] CHECK CONSTRAINT [FK_direccion_calle]
GO
/****** Object:  ForeignKey [FK_media_anuncio]    Script Date: 12/11/2014 16:01:19 ******/
ALTER TABLE [dbo].[media]  WITH CHECK ADD  CONSTRAINT [FK_media_anuncio] FOREIGN KEY([codigo_anuncio])
REFERENCES [dbo].[anuncio] ([codigo])
GO
ALTER TABLE [dbo].[media] CHECK CONSTRAINT [FK_media_anuncio]
GO
/****** Object:  ForeignKey [FK_marca_anuncio]    Script Date: 12/11/2014 16:01:19 ******/
ALTER TABLE [dbo].[marca]  WITH CHECK ADD  CONSTRAINT [FK_marca_anuncio] FOREIGN KEY([codigo_anuncio])
REFERENCES [dbo].[anuncio] ([codigo])
GO
ALTER TABLE [dbo].[marca] CHECK CONSTRAINT [FK_marca_anuncio]
GO
/****** Object:  ForeignKey [FK_punto_contacto_anuncio]    Script Date: 12/11/2014 16:01:19 ******/
ALTER TABLE [dbo].[punto_contacto]  WITH CHECK ADD  CONSTRAINT [FK_punto_contacto_anuncio] FOREIGN KEY([codigo_anuncio])
REFERENCES [dbo].[anuncio] ([codigo])
GO
ALTER TABLE [dbo].[punto_contacto] CHECK CONSTRAINT [FK_punto_contacto_anuncio]
GO
/****** Object:  ForeignKey [FK_punto_contacto_direccion]    Script Date: 12/11/2014 16:01:19 ******/
ALTER TABLE [dbo].[punto_contacto]  WITH CHECK ADD  CONSTRAINT [FK_punto_contacto_direccion] FOREIGN KEY([codigo_direccion])
REFERENCES [dbo].[direccion] ([codigo])
GO
ALTER TABLE [dbo].[punto_contacto] CHECK CONSTRAINT [FK_punto_contacto_direccion]
GO
/****** Object:  ForeignKey [FK_productos_servicios_anuncio]    Script Date: 12/11/2014 16:01:19 ******/
ALTER TABLE [dbo].[productos_servicios]  WITH CHECK ADD  CONSTRAINT [FK_productos_servicios_anuncio] FOREIGN KEY([codigo_anuncio])
REFERENCES [dbo].[anuncio] ([codigo])
GO
ALTER TABLE [dbo].[productos_servicios] CHECK CONSTRAINT [FK_productos_servicios_anuncio]
GO
/****** Object:  ForeignKey [FK_uso_direccion_direccion]    Script Date: 12/11/2014 16:01:19 ******/
ALTER TABLE [dbo].[uso_direccion]  WITH CHECK ADD  CONSTRAINT [FK_uso_direccion_direccion] FOREIGN KEY([codigo_direccion])
REFERENCES [dbo].[direccion] ([codigo])
GO
ALTER TABLE [dbo].[uso_direccion] CHECK CONSTRAINT [FK_uso_direccion_direccion]
GO
/****** Object:  ForeignKey [FK_uso_direccion_tipo_direccion]    Script Date: 12/11/2014 16:01:19 ******/
ALTER TABLE [dbo].[uso_direccion]  WITH CHECK ADD  CONSTRAINT [FK_uso_direccion_tipo_direccion] FOREIGN KEY([codigo_tipo_direccion])
REFERENCES [dbo].[tipo_direccion] ([codigo])
GO
ALTER TABLE [dbo].[uso_direccion] CHECK CONSTRAINT [FK_uso_direccion_tipo_direccion]
GO
/****** Object:  ForeignKey [FK_formas_pago_anuncio]    Script Date: 12/11/2014 16:01:19 ******/
ALTER TABLE [dbo].[formas_pago]  WITH CHECK ADD  CONSTRAINT [FK_formas_pago_anuncio] FOREIGN KEY([codigo_anuncio])
REFERENCES [dbo].[anuncio] ([codigo])
GO
ALTER TABLE [dbo].[formas_pago] CHECK CONSTRAINT [FK_formas_pago_anuncio]
GO
/****** Object:  ForeignKey [FK_telefono_punto_contacto_punto_contacto]    Script Date: 12/11/2014 16:01:19 ******/
ALTER TABLE [dbo].[telefono_punto_contacto]  WITH CHECK ADD  CONSTRAINT [FK_telefono_punto_contacto_punto_contacto] FOREIGN KEY([codigo_punto_contacto])
REFERENCES [dbo].[punto_contacto] ([codigo])
GO
ALTER TABLE [dbo].[telefono_punto_contacto] CHECK CONSTRAINT [FK_telefono_punto_contacto_punto_contacto]
GO
/****** Object:  ForeignKey [FK_telefono_punto_contacto_telefono]    Script Date: 12/11/2014 16:01:19 ******/
ALTER TABLE [dbo].[telefono_punto_contacto]  WITH CHECK ADD  CONSTRAINT [FK_telefono_punto_contacto_telefono] FOREIGN KEY([codigo_telefono])
REFERENCES [dbo].[telefono] ([codigo])
GO
ALTER TABLE [dbo].[telefono_punto_contacto] CHECK CONSTRAINT [FK_telefono_punto_contacto_telefono]
GO
/****** Object:  ForeignKey [FK_posicion_categoria]    Script Date: 12/11/2014 16:01:19 ******/
ALTER TABLE [dbo].[posicion]  WITH CHECK ADD  CONSTRAINT [FK_posicion_categoria] FOREIGN KEY([codigo_categoria])
REFERENCES [dbo].[categoria] ([codigo])
GO
ALTER TABLE [dbo].[posicion] CHECK CONSTRAINT [FK_posicion_categoria]
GO
/****** Object:  ForeignKey [FK_posicion_cobertura]    Script Date: 12/11/2014 16:01:19 ******/
ALTER TABLE [dbo].[posicion]  WITH CHECK ADD  CONSTRAINT [FK_posicion_cobertura] FOREIGN KEY([codigo_cobertura])
REFERENCES [dbo].[cobertura] ([codigo])
GO
ALTER TABLE [dbo].[posicion] CHECK CONSTRAINT [FK_posicion_cobertura]
GO
/****** Object:  ForeignKey [FK_posicion_punto_contacto]    Script Date: 12/11/2014 16:01:19 ******/
ALTER TABLE [dbo].[posicion]  WITH CHECK ADD  CONSTRAINT [FK_posicion_punto_contacto] FOREIGN KEY([codigo_punto_contacto])
REFERENCES [dbo].[punto_contacto] ([codigo])
GO
ALTER TABLE [dbo].[posicion] CHECK CONSTRAINT [FK_posicion_punto_contacto]
GO
/****** Object:  ForeignKey [FK_horario_punto_contacto]    Script Date: 12/11/2014 16:01:19 ******/
ALTER TABLE [dbo].[horario]  WITH CHECK ADD  CONSTRAINT [FK_horario_punto_contacto] FOREIGN KEY([codigo_punto_contacto])
REFERENCES [dbo].[punto_contacto] ([codigo])
GO
ALTER TABLE [dbo].[horario] CHECK CONSTRAINT [FK_horario_punto_contacto]
GO
/****** Object:  ForeignKey [FK_horario_rango_horario]    Script Date: 12/11/2014 16:01:19 ******/
ALTER TABLE [dbo].[horario_rango]  WITH CHECK ADD  CONSTRAINT [FK_horario_rango_horario] FOREIGN KEY([codigo_horario])
REFERENCES [dbo].[horario] ([codigo])
GO
ALTER TABLE [dbo].[horario_rango] CHECK CONSTRAINT [FK_horario_rango_horario]
GO
