Describing one-to-many relationships in M

by Admin 1/27/2010 7:52:00 AM

In M you can describe values and use MGraph to infer a data model.  for instance, I can tell it a little data, like this:

module TheStates
{
  States  => { "Ohio", "Indiana", "Kentucky" };
}

… and get back the SQL code for my inferred table:

set xact_abort on;
go

begin transaction;
go

set ansi_nulls on;
go

if not exists 
(
    select *
    from [sys].[schemas]
    where [name] = N'TheStates'
)
    execute [sp_executesql] N'create schema [TheStates]';
go

create table [TheStates].[States]
(
    [Item] nvarchar(max) not null
);
go

insert into [TheStates].[States] ([Item])
    values (N'Ohio'),
        (N'Indiana'),
        (N'Kentucky');
go

commit transaction;
go

The problem is with a real world model, say a collection of states that represents a route.  if you try to model that with an extent, like this:

module Proto
{
  Representative =>
  {
    Id => "4";
    Name => "Bill";
    States  => { "Ohio", "Indiana", "Kentucky" };
  } where identity Id;
}

Well, at least it is a Not Yet Implemented error.

untitled3  4,3-8,22    Error   M3999   Not yet implemented: Initializing a collection with an expression that yields a collection (Microsoft.M.SemanticGraph.FromExpressionSymbol)

Still, without something that straightforward implemented, it is tough to call this a modeling language for data.  Hopefully it is in the works soon.

Tags:

Biz | M

About the author

Bill Sempf Bill Sempf
Author of C# All In One for Dummies (among other things)

E-mail me Send mail

Calendar

<<  January 2010  >>
MoTuWeThFrSaSu
28293031123
45678910
11121314151617
18192021222324
25262728293031
1234567

View posts in large calendar

Pages

Recent comments

Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2010

Sign in