Describing one-to-many relationships in M

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.

Pingbacks and trackbacks (1)+

Comments are closed

Bill Sempf

Husband. Father. Pentester. Secure software composer. Brewer. Lockpicker. Ninja. Insurrectionist. Lumberjack. All words that have been used to describe me recently. I help people write more secure software.

profile for Bill Sempf on Stack Exchange, a network of free, community-driven Q&A sites

MonthList