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.
Note
This topic requires that you use SQL Server Management Studio.
To create the MSPetShop4Orders database
In “Quadrant”, on the File menu, click New, and then click M File.
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} } }
Save the file as MSPetshop4Orders.m.
Right-click the code in the window and click Deploy. When the Success dialog appears, the new extents are created in the database.
Close the file.
To create a new order
On the View menu, click Explorer, and then click MSPetshop4Orders.
Expand Database, and then expand dbo2. Three tables appear: LineItems, Orders, and OrderStatus.
Drag Orders to the workspace.
Switch the Orders workpad to tree view.
Expand Order1. Note that an order can have one or more line items and an OrderStatus.
Switch the Orders workpad to Table view.
On the Data menu, click Insert Item. A New Orders Record workpad appears.
In the Name field, type New Order.
Expand the References section. Note that there are no LineItems for the new order.
In the MSPetshop4Orders workpad, under the dbo2 node, drag OrderStatus to the workspace.
On the Data menu, click Insert Item. A New OrderStatus Record workpad appears.
In the Status box, type Ordered.
In the OrderId box, open the drop-down list of orders and click New Order.
Select New Order from the list.
Create a new LineItems entry.
From the MSPetshop4Orders, drag LineItems to the workspace.
On the Data menu, click Insert Item.
Set the following values for each field.
Field Value UnitPrice
10
Quantity
10
Name
New Item
OrderId
New Order
On the View menu, click Changes to see a summary of all impending changes.
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
Tasks
How to: Create a Database from "M" in "Quadrant"
How to: Explore Data In "Quadrant"
How to: Edit Data in "Quadrant"
How to: Edit Stale Data in "Quadrant"
How to: Resolve Change Conflicts in "Quadrant"