tags:

views:

49

answers:

2

alt text

Here's what I have so far:

create table rubro (
  id_rubro int primary key,
  nombre_rubro nvarchar(150)
)
go

create table cliente (
  id_cliente int primary key,
  direccion nvarchar(400),
  telefono int,
  nit int
)
+1  A: 

If I understand the diagram correctly it is a object oriented diagram and not a relational diagram. natural and juridico are subclasses of the superclass cliente.

There is no such concept as inheritance in relational databases. When mapping a clas hierarchy there are a few common patterns to use:

All of them have their separate pros and cons. I would suggest you start to read up on those.

Anders Abel
-1: Object oriented diagrams don't include "PK", which stands for "Primary Key". Inheritance in a data model is demonstrated via foreign key relationships, and they can be self referencing.
OMG Ponies
@OMG Ponies, you're right about the PK indicating a relational diagram, but they usually don't have inheritance markers, just FK relations with a cardinality. To me it looks like some kind of mix between a relational diagram and an object diagram.
Anders Abel
@Anders Abel: ERD convention is to model child relations to the left and/or down. The arrow is only indicating the parent table where the foreign key is coming from. I prefer crows feet for ERDs myself...
OMG Ponies
+2  A: 

You just need to create the missing two tables and link them to the cliente table:

create table natural (
  id_cliente int primary key,
  nombre nvarchar(50),
  app nvarchar(50),
  apm nvarchar(50),
  ....
)

alter table dbo.natural
  add constraint fk_natural_cliente
      foreign key(id_cliente) references dbo.cliente(id_cliente)

and the same for the juridico table, too.

In SQL Server, those are just three regular tables, linked by foreign key constraints. Using an OR mapper such as Entity Framework gives you the ability to map those as descendant classes in your .NET domain model - but on the database level, those are just three regular tables - nothing "magic" about them...

marc_s