How to: Edit Complex Data in "Quadrant"

[This content is no longer valid. For the latest information on "M", "Quadrant", SQL Server Modeling Services, and the Repository, see the Model Citizen blog.]

In this topic, you will edit three related tables (Orders, OrderStatus, LineItems) that have foreign key relationships by creating a new order and adding line items.

This is the sixth topic in the "Quadrant" Pet Shop Tutorial.

Ee698867.note(en-us,VS.85).gifNote:
This topic requires that you use SQL Server Management Studio.

To create the MSPetShop4Orders database

  1. In “Quadrant”, on the File menu, click New, and then click M File.

  2. Copy the following code into the window.

    
    module dbo2
    {
        type Order
        {
            Id : Integer64 => AutoNumber;
            Name : Text?;
        } where identity Id;
        
        type LineItem
        {
            Id : Integer64 => AutoNumber;
            Name : Text?;
            Quantity : Integer32?;
            UnitPrice : Integer32?;
            OrderId : Orders;
        } where identity Id;
        
        type OrderStatusType
        {
            Id : Integer64 => AutoNumber;
            Status : Text?;
            OrderId : Orders;
        } where unique OrderId, identity Id;
        
        Orders : {Order*}
        {
            Order1 {Name => "Order 1"},
            Order2 {Name => "Order 2"},
            Order3 {Name => "Order 3"}
        }
    
        LineItems : {LineItem*}
        {
            {Name => "Line Item 1", Quantity => 10, UnitPrice => 5, OrderId => Orders.Order1},
            {Name => "Line Item 2", Quantity => 15, UnitPrice => 15, OrderId => Orders.Order2},
            {Name => "Line Item 3", Quantity => 20, UnitPrice => 30, OrderId => Orders.Order3}
        }
    
        OrderStatus : {OrderStatusType*}
        {
            {Status => "Ordered", OrderId => Orders.Order1},
            {Status => "Shipped", OrderId => Orders.Order2},
            {Status => "Ordered", OrderId => Orders.Order3}
        }
    }
    
  3. Save the file as MSPetshop4Orders.m.

  4. Right-click the code in the window and click Deploy. When the Success dialog appears, the new extents are created in the database.

  5. Close the file.

To create a new order

  1. On the View menu, click Explorer, and then click MSPetshop4Orders.

  2. Expand Database, and then expand dbo2. Three tables appear: LineItems, Orders, and OrderStatus.

  3. Drag Orders to the workspace.

  4. Switch the Orders workpad to tree view.

  5. Expand Order1. Note that an order can have one or more line items and an OrderStatus.

  6. Switch the Orders workpad to Table view.

  7. On the Data menu, click Insert Item. A New Orders Record workpad appears.

  8. In the Name field, type New Order.

  9. Expand the References section. Note that there are no LineItems for the new order.

  10. In the MSPetshop4Orders workpad, under the dbo2 node, drag OrderStatus to the workspace.

  11. On the Data menu, click Insert Item. A New OrderStatus Record workpad appears.

  12. In the Status box, type Ordered.

  13. In the OrderId box, open the drop-down list of orders and click New Order.

  14. Select New Order from the list.

  15. Create a new LineItems entry.

    1. From the MSPetshop4Orders, drag LineItems to the workspace.

    2. On the Data menu, click Insert Item.

    3. Set the following values for each field.

      Field Value

      UnitPrice

      10

      Quantity

      10

      Name

      New Item

      OrderId

      New Order

  16. On the View menu, click Changes to see a summary of all impending changes.

  17. Press CTRL+S to commit the changes to the database.

In this tutorial you used “Quadrant” to perform the following tasks:

  • Built a database.

  • Created a new record of an order with line items.

  • Previewed the new data changes.

See Also


Show: