PlantUml . Placing classes on canvas page - plantuml

I have the ER Diagram with classes and connections placed inappropriately. Connections and multiplicity are overlaped and the diagram seem a little bit streched.
#startuml
' hide the spot
hide circle
' avoid problems with angled crows feet
skinparam linetype ortho
entity Воронка{
ID <<PK>>
Наименование
}
entity Должность{
ID <<PK>>
Код должности
Наименование
ID Воронки <<FK, UNIQUE>>
}
entity Гражданство{
ID <<PK>>
Наименование
}
entity Регион{
ID <<PK>>
Наименование
}
entity Образование{
ID <<PK>>
Наименование
}
entity Языки{
ID <<PK>>
Наименование
}
entity "Опыт работы"{
ID <<PK>>
Наименование
}
entity "Тип занятости"{
ID <<PK>>
Наименование
}
entity Похожие_должности{
ID Должности
ID Похожей должности
}
entity Должность_Гражданство{
ID Должности <<FK>>
ID Гражданства <<FK>>
}
entity Должность_Регион{
ID Должности <<FK>>
ID Региона <<FK>>
}
entity Должность_Языки{
ID Должности <<FK>>
ID Языка <<FK>>
}
entity Должность_Опыт_работы{
ID Должности <<FK>>
ID Опыт работы <<FK>>
}
entity Должность_Тип_занятости{
ID Должности <<FK>>
ID Типа занятости <<FK>>
}
entity Должность_Образование{
ID Должности <<FK>>
ID Образования <<FK>>
}
Должность }|..|| Воронка
Должность ||..|{ Похожие_должности
Должность ||..o{ Должность_Гражданство
Гражданство ||..o{ Должность_Гражданство
Должность ||..o{ Должность_Регион
Регион ||..o{ Должность_Регион
Должность ||..o{ Должность_Образование
Образование ||..o{ Должность_Образование
Должность ||..o{ Должность_Языки
Языки ||..o{ Должность_Языки
Должность ||..o{ Должность_Опыт_работы
"Опыт работы" ||..o{ Должность_Опыт_работы
Должность ||..o{ Должность_Тип_занятости
"Тип занятости" ||..o{ Должность_Тип_занятости
#enduml
How can I control the placement of classes on the canvas? How can I set the padding between notations?
I don't know what the detailes I need to add to submit post

With complicated diagrams, there are not a lot of options.
I tried adding some Padding with polylines and hiding the empty members. Then I forced some associations to be up direction to avoid overlapping:
#startuml
skinparam Padding 5
' hide the spot
hide circle
hide empty members
skinparam linetype polyline
entity Воронка{
ID <<PK>>
Наименование
}
entity Должность{
ID <<PK>>
Код должности
Наименование
ID Воронки <<FK, UNIQUE>>
}
entity Гражданство{
ID <<PK>>
Наименование
}
entity Регион{
ID <<PK>>
Наименование
}
entity Образование{
ID <<PK>>
Наименование
}
entity Языки{
ID <<PK>>
Наименование
}
entity "Опыт работы"{
ID <<PK>>
Наименование
}
entity "Тип занятости"{
ID <<PK>>
Наименование
}
entity Похожие_должности{
ID Должности
ID Похожей должности
}
entity Должность_Гражданство{
ID Должности <<FK>>
ID Гражданства <<FK>>
}
entity Должность_Регион{
ID Должности <<FK>>
ID Региона <<FK>>
}
entity Должность_Языки{
ID Должности <<FK>>
ID Языка <<FK>>
}
entity Должность_Опыт_работы{
ID Должности <<FK>>
ID Опыт работы <<FK>>
}
entity Должность_Тип_занятости{
ID Должности <<FK>>
ID Типа занятости <<FK>>
}
entity Должность_Образование{
ID Должности <<FK>>
ID Образования <<FK>>
}
Должность }|..|| Воронка
Должность ||..|{ Похожие_должности
Должность ||..o{ Должность_Гражданство
Гражданство ||.up.o{ Должность_Гражданство
Должность ||..o{ Должность_Регион
Регион ||.up.o{ Должность_Регион
Должность ||..o{ Должность_Образование
Образование ||.up.o{ Должность_Образование
Должность ||..o{ Должность_Языки
Языки ||.up.o{ Должность_Языки
Должность ||..o{ Должность_Опыт_работы
"Опыт работы" ||.up.o{ Должность_Опыт_работы
Должность ||..o{ Должность_Тип_занятости
"Тип занятости" ||.up.o{ Должность_Тип_занятости
#enduml

Related

How to auto count Current Employees for department in CREATE TABLE statement?

The employee has a default department that company workers will associate with, also the system will track which department the worker is currently working in.
How to count CurrentEmployeesCount?
CREATE TABLE Departments
(
DepartmentID INT PRIMARY KEY,
DepartmentName NVARCHAR(100),
CurrentEmployeesCount INT --???
);
CREATE TABLE Employees
(
EmployeeID INT PRIMARY KEY,
DepartmentID INT DEFAULT '???',
FOREIGN KEY(DepartmentID)
REFERENCES Departments (DepartmentID)
);

custom object lookup relationship soql query to get sobject

I have 2 custom object.
1 - namespace__object1__c
2 - namespace__object2__c
I have lookup relationship in custom object namespace__object2__c.
Now i want to query id record from object2 where object1 id = (provided parameter)
String s = 'a6T3k0000LMJcEAO';
string query = 'select ID, (select ID from namespace__object1__c where ID = :s ) from namespace__object2__c';
SObject rObject = database.query(query);
system.debug(rObject);
object2 has lookup to object1, right? What's the field name?
SELECT Id, Name
FROM namespace__object2__c
WHERE namespace__object1__c = 'a6T3k0000LMJcEAO'
should work. Put the right field name in (lookup field typically is but doesn't have to be identical).
Some other things you can do with this (but let's use std. objects in example)
SELECT Id, Name
FROM Contact
WHERE AccountId = '001...'
SELECT Id, Name, Account.Name
FROM Contact
WHERE Account.Name LIKE 'Acme%'
And even
SELECT Id, Name
FROM Account
WHERE Id IN (SELECT AccountId FROM Contact WHERE LastName = 'Smith')

Parse a simple JSON string

I have the following JSON String stored in table
create table #t1 (Caseno int, CaseText text)
insert into #t1 values
(1,'[{"RowType":"KV","s1":0,"s2":0,"s3":0,"TableNo":0,"FieldName":"PCNForEnrollmentCreationDesc","DisplayName":"Header","FieldSchemaName":null,"FieldValue":"","IsDynamic":true,"IsDependent":false,"DependentKey":null,"IsRecurrence":false,"RecurrenceKey":null,"Section":null,"Table":null,"DataType":null,"UIOrder":2,"LookupSelectField":null,"LookupFilterField":null,"col3":null,"col4":null,"col5":null,"col6":null,"col7":null,"col8":null,"col9":null,"col10":null,"col11":null,"col12":null,"col13":null,"FieldType":null,"IsRequired":null},{"RowType":"H2","s1":0,"s2":0,"s3":0,"TableNo":0,"FieldName":"PrimaryEntityInformation","DisplayName":"Primary Entity Information","FieldSchemaName":null,"FieldValue":"","IsDynamic":false,"IsDependent":false,"DependentKey":null,"IsRecurrence":false,"RecurrenceKey":null,"Section":null,"Table":null,"DataType":null,"UIOrder":2,"LookupSelectField":null,"LookupFilterField":null,"col3":null,"col4":null,"col5":null,"col6":null,"col7":null,"col8":null,"col9":null,"col10":null,"col11":null,"col12":null,"col13":null,"FieldType":null,"IsRequired":null},{"RowType":"KV","s1":0,"s2":0,"s3":0,"TableNo":0,"FieldName":"EnrollPrimaryEntityName","DisplayName":"Primary Entity Name","FieldSchemaName":null,"FieldValue":"Mau \"Informatsionnye tekhnologii\"","IsDynamic":true,"IsDependent":false,"DependentKey":null,"IsRecurrence":false,"RecurrenceKey":null,"Section":null,"Table":null,"DataType":null,"UIOrder":2,"LookupSelectField":null,"LookupFilterField":null,"col3":null,"col4":null,"col5":null,"col6":null,"col7":null,"col8":null,"col9":null,"col10":null,"col11":null,"col12":null,"col13":null,"FieldType":null,"IsRequired":null},{"RowType":"KV","s1":0,"s2":0,"s3":0,"TableNo":0,"FieldName":"EnrollPrimaryEntityAddress","DisplayName":"Primary Entity Address","FieldSchemaName":null,"FieldValue":"123 Main St, ","IsDynamic":true,"IsDependent":false,"DependentKey":null,"IsRecurrence":false,"RecurrenceKey":null,"Section":null,"Table":null,"DataType":null,"UIOrder":2,"LookupSelectField":null,"LookupFilterField":null,"col3":null,"col4":null,"col5":null,"col6":null,"col7":null,"col8":null,"col9":null,"col10":null,"col11":null,"col12":null,"col13":null,"FieldType":null,"IsRequired":null},{"RowType":"KV","s1":0,"s2":0,"s3":0,"TableNo":0,"FieldName":"EnrollPrimaryEntityCity","DisplayName":"Primary Entity City","FieldSchemaName":null,"FieldValue":"Kaliningrad","IsDynamic":true,"IsDependent":false,"DependentKey":null,"IsRecurrence":false,"RecurrenceKey":null,"Section":null,"Table":null,"DataType":null,"UIOrder":2,"LookupSelectField":null,"LookupFilterField":null,"col3":null,"col4":null,"col5":null,"col6":null,"col7":null,"col8":null,"col9":null,"col10":null,"col11":null,"col12":null,"col13":null,"FieldType":null,"IsRequired":null},{"RowType":"KV","s1":0,"s2":0,"s3":0,"TableNo":0,"FieldName":"EnrollPrimaryEntityPhone","DisplayName":"Primary Entity Phone","FieldSchemaName":null,"FieldValue":"772 322-977","IsDynamic":true,"IsDependent":false,"DependentKey":null,"IsRecurrence":false,"RecurrenceKey":null,"Section":null,"Table":null,"DataType":null,"UIOrder":2,"LookupSelectField":null,"LookupFilterField":null,"col3":null,"col4":null,"col5":null,"col6":null,"col7":null,"col8":null,"col9":null,"col10":null,"col11":null,"col12":null,"col13":null,"FieldType":null,"IsRequired":null},{"RowType":"KV","s1":0,"s2":0,"s3":0,"TableNo":0,"FieldName":"EnrollPrimaryEntityPostalCode","DisplayName":"Primary Entity Postal Code","FieldSchemaName":null,"FieldValue":"236029","IsDynamic":true,"IsDependent":false,"DependentKey":null,"IsRecurrence":false,"RecurrenceKey":null,"Section":null,"Table":null,"DataType":null,"UIOrder":2,"LookupSelectField":null,"LookupFilterField":null,"col3":null,"col4":null,"col5":null,"col6":null,"col7":null,"col8":null,"col9":null,"col10":null,"col11":null,"col12":null,"col13":null,"FieldType":null,"IsRequired":null},{"RowType":"KV","s1":0,"s2":0,"s3":0,"TableNo":0,"FieldName":"EnrollPrimaryEntityCountry","DisplayName":"Primary Entity Country","FieldSchemaName":null,"FieldValue":"Russia","IsDynamic":true,"IsDependent":false,"DependentKey":null,"IsRecurrence":false,"RecurrenceKey":null,"Section":null,"Table":null,"DataType":null,"UIOrder":2,"LookupSelectField":null,"LookupFilterField":null,"col3":null,"col4":null,"col5":null,"col6":null,"col7":null,"col8":null,"col9":null,"col10":null,"col11":null,"col12":null,"col13":null,"FieldType":null,"IsRequired":null},{"RowType":"H2","s1":0,"s2":0,"s3":0,"TableNo":0,"FieldName":"PrimaryContactInformation","DisplayName":"Primary Contact Information","FieldSchemaName":null,"FieldValue":"","IsDynamic":false,"IsDependent":false,"DependentKey":null,"IsRecurrence":false,"RecurrenceKey":null,"Section":null,"Table":null,"DataType":null,"UIOrder":2,"LookupSelectField":null,"LookupFilterField":null,"col3":null,"col4":null,"col5":null,"col6":null,"col7":null,"col8":null,"col9":null,"col10":null,"col11":null,"col12":null,"col13":null,"FieldType":null,"IsRequired":null},{"RowType":"KV","s1":0,"s2":0,"s3":0,"TableNo":0,"FieldName":"EnrollContactTypeIndividual","DisplayName":"Contact Type","FieldSchemaName":null,"FieldValue":"Individual","IsDynamic":false,"IsDependent":false,"DependentKey":null,"IsRecurrence":false,"RecurrenceKey":null,"Section":null,"Table":null,"DataType":null,"UIOrder":2,"LookupSelectField":null,"LookupFilterField":null,"col3":null,"col4":null,"col5":null,"col6":null,"col7":null,"col8":null,"col9":null,"col10":null,"col11":null,"col12":null,"col13":null,"FieldType":null,"IsRequired":null},{"RowType":"KV","s1":0,"s2":0,"s3":0,"TableNo":0,"FieldName":"EnrollPriContactFirstName","DisplayName":"Given Name: ","FieldSchemaName":null,"FieldValue":"Elena","IsDynamic":true,"IsDependent":false,"DependentKey":null,"IsRecurrence":false,"RecurrenceKey":null,"Section":null,"Table":null,"DataType":null,"UIOrder":2,"LookupSelectField":null,"LookupFilterField":null,"col3":null,"col4":null,"col5":null,"col6":null,"col7":null,"col8":null,"col9":null,"col10":null,"col11":null,"col12":null,"col13":null,"FieldType":null,"IsRequired":null},{"RowType":"KV","s1":0,"s2":0,"s3":0,"TableNo":0,"FieldName":"EnrollPriContactLastName","DisplayName":"Family Name: ","FieldSchemaName":null,"FieldValue":"Andre","IsDynamic":true,"IsDependent":false,"DependentKey":null,"IsRecurrence":false,"RecurrenceKey":null,"Section":null,"Table":null,"DataType":null,"UIOrder":2,"LookupSelectField":null,"LookupFilterField":null,"col3":null,"col4":null,"col5":null,"col6":null,"col7":null,"col8":null,"col9":null,"col10":null,"col11":null,"col12":null,"col13":null,"FieldType":null,"IsRequired":null},{"RowType":"KV","s1":0,"s2":0,"s3":0,"TableNo":0,"FieldName":"EnrollPriContPrimaryEntityCountry","DisplayName":"Primary Entity Country","FieldSchemaName":null,"FieldValue":"Russia","IsDynamic":true,"IsDependent":false,"DependentKey":null,"IsRecurrence":false,"RecurrenceKey":null,"Section":null,"Table":null,"DataType":null,"UIOrder":2,"LookupSelectField":null,"LookupFilterField":null,"col3":null,"col4":null,"col5":null,"col6":null,"col7":null,"col8":null,"col9":null,"col10":null,"col11":null,"col12":null,"col13":null,"FieldType":null,"IsRequired":null},{"RowType":"KV","s1":0,"s2":0,"s3":0,"TableNo":0,"FieldName":"EnrollPriContPrimaryEntityAddress","DisplayName":"Primary Entity Address","FieldSchemaName":null,"FieldValue":"123 Main St, ","IsDynamic":true,"IsDependent":false,"DependentKey":null,"IsRecurrence":false,"RecurrenceKey":null,"Section":null,"Table":null,"DataType":null,"UIOrder":2,"LookupSelectField":null,"LookupFilterField":null,"col3":null,"col4":null,"col5":null,"col6":null,"col7":null,"col8":null,"col9":null,"col10":null,"col11":null,"col12":null,"col13":null,"FieldType":null,"IsRequired":null},{"RowType":"KV","s1":0,"s2":0,"s3":0,"TableNo":0,"FieldName":"EnrollPriContPrimaryEntityCity","DisplayName":"Primary Entity City","FieldSchemaName":null,"FieldValue":"Kaliningrad","IsDynamic":true,"IsDependent":false,"DependentKey":null,"IsRecurrence":false,"RecurrenceKey":null,"Section":null,"Table":null,"DataType":null,"UIOrder":2,"LookupSelectField":null,"LookupFilterField":null,"col3":null,"col4":null,"col5":null,"col6":null,"col7":null,"col8":null,"col9":null,"col10":null,"col11":null,"col12":null,"col13":null,"FieldType":null,"IsRequired":null},{"RowType":"KV","s1":0,"s2":0,"s3":0,"TableNo":0,"FieldName":"EnrollPriContPrimaryEntityPhone","DisplayName":"Primary Entity Phone","FieldSchemaName":null,"FieldValue":"772 322-977","IsDynamic":true,"IsDependent":false,"DependentKey":null,"IsRecurrence":false,"RecurrenceKey":null,"Section":null,"Table":null,"DataType":null,"UIOrder":2,"LookupSelectField":null,"LookupFilterField":null,"col3":null,"col4":null,"col5":null,"col6":null,"col7":null,"col8":null,"col9":null,"col10":null,"col11":null,"col12":null,"col13":null,"FieldType":null,"IsRequired":null},{"RowType":"KV","s1":0,"s2":0,"s3":0,"TableNo":0,"FieldName":"EnrollPriContEmailAddress","DisplayName":"Email Address","FieldSchemaName":null,"FieldValue":"info#us.me","IsDynamic":true,"IsDependent":false,"DependentKey":null,"IsRecurrence":false,"RecurrenceKey":null,"Section":null,"Table":null,"DataType":null,"UIOrder":2,"LookupSelectField":null,"LookupFilterField":null,"col3":null,"col4":null,"col5":null,"col6":null,"col7":null,"col8":null,"col9":null,"col10":null,"col11":null,"col12":null,"col13":null,"FieldType":null,"IsRequired":null},{"RowType":"KV","s1":0,"s2":0,"s3":0,"TableNo":0,"FieldName":"EnrollPriContDataLanguage","DisplayName":"Data Language","FieldSchemaName":null,"FieldValue":"Russkij","IsDynamic":true,"IsDependent":false,"DependentKey":null,"IsRecurrence":false,"RecurrenceKey":null,"Section":null,"Table":null,"DataType":null,"UIOrder":2,"LookupSelectField":null,"LookupFilterField":null,"col3":null,"col4":null,"col5":null,"col6":null,"col7":null,"col8":null,"col9":null,"col10":null,"col11":null,"col12":null,"col13":null,"FieldType":null,"IsRequired":null},{"RowType":"KV","s1":0,"s2":0,"s3":0,"TableNo":0,"FieldName":"PCNforEnrollPrimaryEntity","DisplayName":"PCN for Enrollment Primary Entity","FieldSchemaName":null,"FieldValue":"123455","IsDynamic":false,"IsDependent":false,"DependentKey":null,"IsRecurrence":false,"RecurrenceKey":null,"Section":null,"Table":null,"DataType":null,"UIOrder":2,"LookupSelectField":null,"LookupFilterField":null,"col3":null,"col4":null,"col5":null,"col6":null,"col7":null,"col8":null,"col9":null,"col10":null,"col11":null,"col12":null,"col13":null,"FieldType":"FreeText","IsRequired":"true"},{"RowType":"H2","s1":0,"s2":0,"s3":0,"TableNo":0,"FieldName":"NoticesEntityInformation"')
I want to extract the value from the string and present this way:
Caseno FieldName FieldValue
1 Header
1 Primary Entity Information
1 Primary Entity Name Mau \"Informatsionnye tekhnologii
1 Primary Entity Address 123 Main St,
1 Primary Entity City Kaliningrad
1 Primary Entity Phone 772 322-977
1 Primary Entity Postal Code 236029
1 Primary Entity Country Russia
1 Primary Contact Information
1 Contact Type Individual
1 Given Name: Elena
1 Family Name: Andre
1 Primary Entity Country Russia
1 Primary Entity Address 123 Main St,
1 Primary Entity City Kaliningrad
1 Primary Entity Phone 772 322-977
1 Email Address info#us.me
1 Data Language Russkij
1 PCN for Enrollment Primary Entity 123455
Basically I want to extract DisplayName and FieldValues.
Example String: "DisplayName":"Primary Entity Name","FieldSchemaName":null,"FieldValue":"Mau \"Informatsionnye tekhnologii\""
If you use SQL Server 2016+, just parse the JSON with OPENJSON() using explicit schema (WITH clause). The data in the question is truncated (and the JSON is not valid), but the following example is a working solution:
Table and JSON (fixed and simplified):
create table #t1 (Caseno int, CaseText text)
insert into #t1 values
(1,'[
{
"RowType":"KV",
"s1":0,
"s2":0,
"s3":0,
"TableNo":0,
"FieldName":"PCNForEnrollmentCreationDesc",
"DisplayName":"Header",
"FieldSchemaName":null,
"FieldValue":"",
"IsDynamic":true,
"IsDependent":false,
"DependentKey":null,
"IsRecurrence":false,
"RecurrenceKey":null,
"Section":null,
"Table":null,
"DataType":null,
"UIOrder":2,
"LookupSelectField":null,
"LookupFilterField":null,
"col3":null,
"col4":null,
"col5":null,
"col6":null,
"col7":null,
"col8":null,
"col9":null,
"col10":null,
"col11":null,
"col12":null,
"col13":null,
"FieldType":null,
"IsRequired":null
},
{
"RowType":"H2",
"s1":0,
"s2":0,
"s3":0,
"TableNo":0,
"FieldName":"PrimaryEntityInformation",
"DisplayName":"Primary Entity Information",
"FieldSchemaName":null,
"FieldValue":"",
"IsDynamic":false,
"IsDependent":false,
"DependentKey":null,
"IsRecurrence":false,
"RecurrenceKey":null,
"Section":null,
"Table":null,
"DataType":null,
"UIOrder":2,
"LookupSelectField":null,
"LookupFilterField":null,
"col3":null,
"col4":null,
"col5":null,
"col6":null,
"col7":null,
"col8":null,
"col9":null,
"col10":null,
"col11":null,
"col12":null,
"col13":null,
"FieldType":null,
"IsRequired":null
},
{
"RowType":"KV",
"s1":0,
"s2":0,
"s3":0,
"TableNo":0,
"FieldName":"EnrollPrimaryEntityName",
"DisplayName":"Primary Entity Name",
"FieldSchemaName":null,
"FieldValue":"Mau \"Informatsionnye tekhnologii\"",
"IsDynamic":true,
"IsDependent":false,
"DependentKey":null,
"IsRecurrence":false,
"RecurrenceKey":null,
"Section":null,
"Table":null,
"DataType":null,
"UIOrder":2,
"LookupSelectField":null,
"LookupFilterField":null,
"col3":null,
"col4":null,
"col5":null,
"col6":null,
"col7":null,
"col8":null,
"col9":null,
"col10":null,
"col11":null,
"col12":null,
"col13":null,
"FieldType":null,
"IsRequired":null
}
]')
Statement:
SELECT t.CaseNo, j.*
FROM #t1 t
CROSS APPLY OPENJSON(t.CaseText) WITH (
DisplaydName varchar(100) '$.DisplayName',
FieldValue varchar(100) '$.FieldValue'
) j
Result:
CaseNo DisplaydName FieldValue
1 Header
1 Primary Entity Information
1 Primary Entity Name Mau "Informatsionnye tekhnologii"
1 Primary Entity Address 123 Main St,
1 Primary Entity City Kaliningrad
1 Primary Entity Phone 772 322-977
1 Primary Entity Postal Code 236029
1 Primary Entity Country Russia
1 Primary Contact Information
1 Contact Type Individual
1 Given Name: Elena
1 Family Name: Andre
1 Primary Entity Country Russia
1 Primary Entity Address 123 Main St,
1 Primary Entity City Kaliningrad
1 Primary Entity Phone 772 322-977
1 Email Address info#us.me
1 Data Language Russkij
1 PCN for Enrollment Primary Entity 123455

How to model many to many relationships without circles

Note: Because my original question wasn't understood clearly I'm writing it completely new!
I have two tables in my database, plus a junction/join table:
Recipes:
CREATE TABLE Recipes(
id INT(11) NOT NULL AUTO_INCREMENT,
name VARCHAR(100) NOT NULL,
PRIMARY KEY (id)
)
Ingredients:
CREATE TABLE Ingredients(
id INT(11) NOT NULL AUTO_INCREMENT,
name VARCHAR(100) NOT NULL,
PRIMARY KEY (id)
)
IngredientsRecipes:
CREATE TABLE IngredientsRecipes(
id INT(11) NOT NULL AUTO_INCREMENT,
recipeId INT(11) NOT NULL,
ingredientId INT(11) NOT NULL,
PRIMARY KEY (id)
)
My Ingredient class in php code looks like this:
class Ingredient{
private $id;
private $name;
private $recipes; //In which recipes this ingredient is used
}
And this is my Recipes class:
class Recipe{
private $id;
private $name;
private $ingredients; //Ingredients used in this Recipe
}
Now when I want to populate the two lists I have the follwing problem:
The Recipe class has many Ingredients, and the Ingredients class has many Recipes. Each class contains contains the other, I hope this litte picture can illustrate the situation.
Recipe | Ingredients | Recipes using |
|used in Recipe | this Ingredient |
----------------+---------------+-----------------+
|--Noodles------|Spaghetti
|
Spaghetti-------|--Sauce--------|--Spaghetti
|
|--Cheese-------|--Spaghetti
|
|--Mac n Cheese
|--Macaroni-----|Mac n Cheese
|
Mac n Cheese----|--Cheese-------|--Spaghetti
|
|--Mac n Cheese
What is the prefered way of writing the model class for a many to many relationship?
This is usually done by a join or mapping table to hold the relationship between the two, e.g.:
CREATE TABLE recipe (
recipe_id NUMERIC PRIMARY KEY
recipe_name VARCHAR (100)
-- etc...
);
CREATE TABLE ingredient (
ingredient_id NUMERIC PRIMARY KEY
ingredient_name VARCHAR (10),
-- etc...
);
CREATE TABLE recipe_ingredient (
recipe_id NUMERIC REFERENCES recipe (recipe_id),
ingredient_id NUMERIC REFERENCES ingredient (ingredient_id),
PRIMARY KEY (recipe_id, ingredient_id)
);

How to dynamically set up TreeView

Using WPF I would like to have a TreeView that displays data from a Compact Database variably. That means I would like to change the view based on how the user would like it sorted.
Assuming that the database has the following tables and schema, how can I set up my views? As I said, they should be variable, but I would consider multiple HierarchialDataTemplates if that is possible. A few potential views that come to mind are listed below.
Thanks for any help offered!
Employee
ID - Int primary Unique AutoIncrement
Name – string
Department - int (foreign relation to Department. ID)
Supervisor - int (ID of Employee in this table)
Division
ID - Int primary Unique AutoIncrement
Name – Unique string
DivisionLeader - int (foreign relation to Employee. ID)
Department
ID - Int primary Unique AutoIncrement
Name – Unique string
DepartmentLeader - int (foreign relation to Employee. ID)
Division – int (foreign relation to Division. ID)
CustomerSupportDepartments
ID - Int primary Unique AutoIncrement
Name – string
Department - int (foreign relation to Department. ID)
Continent - int (foreign relation to Continent. ID)
Country - int (foreign relation to Country. ID)
State - int (foreign relation to State. ID)
City - int (foreign relation to City. ID)
Customer
ID - Int primary Unique AutoIncrement
Name – string
SalesRep - (foreign relation to Employee. ID)
Revenue . int
Continent - int (foreign relation to Continent. ID)
Country - int (foreign relation to Country. ID)
State - int (foreign relation to State. ID)
City - int (foreign relation to City. ID)
Continent
ID - Int primary Unique AutoIncrement
Name – Unique string
Country
ID - Int primary Unique AutoIncrement
Name – Unique string
State
ID - Int primary Unique AutoIncrement
Name – Unique string
City
ID - Int primary Unique AutoIncrement
Name – Unique string
Potential Views
View 1
Employees
Employee Name 1
Supervisor
Name
Department
Name
Customers
Name 1
Name 2
Name 3
Employee Name 2
Supervisor
Name
Department
Name
Customers
Name 1
Name 2
Name 3
View 2
Departments
Department Name 1
Division
Name
Supervisor
Name
Employees
Employee Name 1
Employee Name 2
Department Name 2
Division
Name
Supervisor
Name
Employees
Employee Name 1
Employee Name 2
View 3
Divisions
Division Name 1
Departments
Department Name 1
Department Name 2
Division Name 2
Departments
Department Name 1
Department Name 2
View 4
Continents
Continent Name 1
Country Name 1
City Name 1
Customers
Customer Name 1
Sales Representative
Employee Name
Revenue
Sum
Customer Name 2
Sales Representative
Employee Name
Revenue
Sum
Country Name 2
City Name 1
Customers
Customer Name 1
Sales Representative
Employee Name 1
Revenue
Sum
City Name 2
Customers
Customer Name 1
Sales Representative
Employee Name 1
Revenue
Sum
Customer Name 2
Sales Representative
Employee Name
Revenue
Sum
View 5
Customers
Customer Name 1
Sales Representative
Employee Name
Sales Representative’s Supervisor
Employee Name
Location
Continent
Country
State
City
Revenue
Sum
Customer Name 2
Sales Representative
Employee Name
Sales Representative’s Supervisor
Employee Name
Location
Continent
Country
State
City
Revenue
Sum
I wound up using a generic object.

Resources