An API for grid elements with apps using the API
- The table columns are id, name, description, sil, stability_limit, thermal_limit, voltages_id, elements_type_id, created-at, updated_at
-
The columns are End-1 S/S, End-2 S/S, Id, Line Owner, End-1 Owner, End-2 Owner, Km, Conductor Type, SIL, End1 LR MVAR, End1 LR is_switchable, End2 LR MVAR, End2 LR is_switchable
-
For End Substations, Line owners, conductor types we will query substations table for the name and get the foreign key and if not present, we will create one and use that id for foreign key
-
The substation owners can be recorded later while creating the substations table
-
We will fill in the element_id, line number, voltage level, mvar, is_switchable values from this excel table to the line reactors table
-
Use the statement
SET default_storage_engine=InnoDB;in the creation sql so that all tables have the same engine -
A short guide to use sql variables in statements - https://www.safaribooksonline.com/library/view/mysql-cookbook-2nd/059652708X/ch01s27.html
-
Use
multipleStatements: truein the mysql connection arguments to execute multiple statements -
MySQL transaction example using connection pooling link
-
General SQL clause
SELECT column1, column2
FROM table_name
WHERE [ conditions ]
GROUP BY column1, column2
ORDER BY column1, column2
LIMIT offset, num_rows- To convert multi line sql string for variable, paste the sql in notepad++ and replace
[\r\n]+with\\\r\n - Element get url
http://localhost:3000/api/elements?cols[0]=elements_ss_table.name&operators[0]=LIKE&values[0]=akola&cols[1]=element_types.type&operators[1]==&values[1]=line&cols[2]=voltages.level&operators[2]==&values[2]=400
INSERT IGNORE INTO tags (tags,...) VALUES (the_new_tags, ...);
SELECT tag_id FROM tags WHERE tags=the_new_tags;Creation Strategies for states, region, voltages, element_types, conductor_types tables rows - normal
- Start a transaction
- Find the region_id by owner region name using the insert_if_absent_and_get_id_strategy
- Create an entry in the owners table
- Commit the transaction
- Return the created owner id
- Start a transaction
- Find volatage level and element type. If not present create them and reatain the id using insert_if_absent_and_get_id_strategy
- Create an entry in the elements table
- Find owner id by name and create if necessary by the insert_if_absent_and_get_id_strategy. Do the same for region and state
- Create an entry in the elements_has_regions, elements_has_owners, elements_has_states tables
- Find the substation id or create if required and get the id
- Create an entry in the elements_has_substations table
- Commit the transaction
- Return the created element id
- Start a transaction
- Create an element in the elements table and get the id
- Create an entry in the substations table
- Commit the transaction
- Return the created substation id
- Start a transaction
- Find the conductor type. If not present create them and reatain the id using insert_if_absent_and_get_id_strategy
- Create an element in the elements table and get the id
- Create an entry in the lines table
- Commit the transaction
- Return the created line id
- Start a transaction
- Create an element in the elements table and get the id
- Find the line id or create if necessary
- Create an entry in the line_reactors table
- Commit the transaction
- Return the created line reactor id
- Start a transaction
- Create an element in the elements table and get the id
- Create an entry in the bus_reactors table
- Commit the transaction
- Return the created bus reactor id
- The goal is not to depend on the name attribute of the elements table since the names are hard coded and will not update themselves according to changes in substation names which can be a serious bug (A-B, B-A bug also will be present)
- So the ideal strategy would be assign a GUID for line while it is created
- To get a line element from elements table, we would first do a left outer join of lines with substations table and concatenate substations with '|||'
- Then will call a select statement on the above table which has substations as 'SUB1|||SUB2' or 'SUB2|||SUB1' instead of using name as the search attribute
- The ideal way to implement this strategy would be to write a pre-insertion trigger routine so that the insertion would be server agnostic
- Otherwise we will have to implement this strategy in the server application program
- While displaying line elements, we will derive the line name from doing the table join just as the step 3 but keep the concatenate character as '-'
- That means the derived name of the element would be 'SUB1-SUB2'
- The strategy will be similar to getting_the_Line_elements_from_elements_table
- So while creation we should ideally give GUID in name
- To get the element use the substation name instead of name from the joined table for querying
- While displaying the name of the element, use the substation name from joined table
- The strategy will be similar to getting_the_Line_elements_from_elements_table
- So while creation we should ideally give GUID in name
- To get the element use the substation name and line element derived from the line reactor information instead of name from the joined table for querying
- While displaying the name of the element, use the substation name from joined table
- Get Substations info by name, voltage
- Get lines info by name, voltage, conductor type, terminal substations
- Get busReactors info by voltage, terminal substation, mvar
- Get lineReactors, fsc, tcsc info by voltage, terminal substation
- Get ict info by voltage ratio, terminal substation names/voltages
- Get elements by name, voltage level, terminal substation, type
- Add end substation_id attribute to line reactor table -- done
- Modify element creation sql to handle zero to multiple owners -- done
- Modify element creation sql to handle zero to multiple substations -- done
- Create line creation code -- important
- Create functions for get id by creation if required, for states, region, owners, voltages, element_types, conductor_types -- done
- Complete element creation by completing element substations in the function -- done
- Complete Bus reactor creation -- done
- Complete Line creation -- done
- Complete Line Reactor creation -- done
- Decide about the data duplication happening in elements_has_substations for substations
- Regions, States, Voltages, ElementTypes, ConductorTypes, Owners, Substations, Lines, Line Reactors, Bus reactors, ICTs csv UI -- done
- Create UI for FSCs and TCSCs
- Solve the line name bug (trying to insert B-A if A-B is already present) -- done
- Make all names either capital/small/sentence case, preferably capital
- Google Docs page ---> https://docs.google.com/document/d/1xqxND1KHwLpGc3jCcYlq9GWiVnqFbHW_GvWrCmRioVY/edit?usp=sharing
- Github page ---> https://github.com/POSOCO/grid_elements_api
- UX Design present in the google slides page at ---> https://docs.google.com/presentation/d/1-8ZsxXvcw5Jf0lq-ZPb9ANdfun1_eSllwTq-7s_o04U/edit?usp=sharing