
15 May 2019
Exam OOP SQL
Exam OOP SQL
Solution to Pesah

Training-day OOP-CIA SQL-FBI
Entity-Framework LINQ NoSQL FireBase Json-To-String

We used Entity Framework in Data-base-first strategy in order to practice LINQ to DB using more complicated commands. we updated the database tables using Entity Model methods (without using SQL queries!). we saw a fast way to print an object using JsonConverter (instead of overriding ToString method), from the Newtonsoft library. then we explored NoSQL using Google’s Firebase free cloud storage. we connected to the Firebase using FireSharp library (nugget) and retrieved data from the FireBase using a C# program.


More topics covered:
Links:
App.Config SKU-version Entity-Framework

We learned about App.Config file and the benefits of using a configuration file in our application. we saw how to read data from the App.Config using ConfigurationManager class. we explored the location of the super config file (machine.config) in the computer’s .NET framework folder. Then we stored our ConnectionString in the App.Config file. Later, we discussed about Entity Framework: DataBase first, Code first, Model first methodology. then we implemented a DataBase first approach in a C# console application which uses the Entity Framework to interact with the MSSQL data base.

More topics covered:
Links:
MSSQL T-SQL stored-procedures ADO.NET winform-MSSQL

We learned about T-SQL and the benefits from using T-SQL. We used the Sql Server Management Studio (SSMS) to generate Stored-Procedures. then we executed the stored procedures from within the SSMS and from C# code. we generated store-procedures with parameters and without parameters. later on, we created a Winform application and used ADO.NET to create a GridView and ComboBox which retrieves data from the MSSQL automatically using queries and stored-procedures.


More topics covered:
Links:
MSSQL Join inner left right full cross union

We used the Sql Server Management Studio (SSMS) in MSSQL and explored the different kind of joins: inner-join, left-join, right-join, full-join, cross-join and union. inner join selects records that have matching values in both tables, left join returns all records from the left table (“left” means the left table name in the query. the first table name appearing in the query), and the matched records from the right table (right table name in the query). The result is NULL from the right side, if there is no match. right-join returns all records from the right table , and the matched records from the left table. The result is NULL from the left side, when there is no match. full-join return all records when there is a match in either left or right table records. Union operator is used to combine the result-set of two or more SELECT statements. Cross-join produces a result set which is the number of rows in the first table multiplied by the number of rows in the second table (This kind of result is called as Cartesian Product). and finally we saw how to insert multiple rows to a table using single query of insert + select

More topics covered:
Links:
SQLITE many : many nested-query MSSQL

We explored the many : many table relationship architecture using Primary Key (PK) in one table (for example Customers table) and using Primary Key (PK) in a second table (for example Products table) and using a set of 2xPrimary Keys (PK) in a third table (for example Orders table). both of these primary keys are also defined as Foreign Keys (FK) to the first two tables. so what did we gain? we got customers which could buy many products. and products which could be bought buy many customers, so there we have- many : many. each purchase is a new row in Orders table. we saw how to combine all of these three tables in a join query. we also saw how to create a DB using Sql Server Management Studio (SSMS) in MSSQL. and how to read the tables from c#.

More topics covered:
Links:
DATA-ACCESS-OBJECT SQLITE 1:many

We explored the 1:many table relationship architecture using Primary Key (PK) in one table (for example Department table) and using Primary Key (PK) + Foreign Key (FK) in the second table (for example Employee table). so what did we gain? we got a department which could include many employees (1:many). then we saw how to retrieve an employee with his department name using join query. we also saw how to perform a count in SQL query, i.e. “how many employees belong to each department?”: we wrote an SQL query which updates the count column for each row in the Department table using a nested Update query. then we wrote a C# program which executes a join query on these two tables, and stores the result in an anonymous object (for a new view). we also saw how to modify a query result column name in order to avoid ambiguity in the C# reader result

More topics covered:
Links:
DATA-ACCESS-OBJECT SQLITE 1:1 1:many many:many

We discussed the separation between Graphic User Interface (GUI), Business Logic (BL) and Data Access Layer (DAL) – which includes the Data Access Object (DAO). We explored the table relationship flavors 1:1 , 1:many , many:many. we created two SQLite tables containing 1:1 relationship using Primary Key (PK) and Foreign Key (FK) references. then we wrote a C# program which executes a join query on these two tables, and stored the result in an anonymous object (for a new view)

More topics covered:
Links: