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
)
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...
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:
- single table inheritance
- class table inheritance
- concrete table inheritance
All of them have their separate pros and cons. I would suggest you start to read up on those.
精彩评论