--------------------------------------------------------------------------------

    Fun with Legal Information in SQL Server: Determining the Law to Be Used

                                 Demo materials

                     (c) 2015, Mi Lambda, Matija Lah, s.p.

             NT Konferenca 2018, Portoro, Slovenia, 22 May 2018

--------------------------------------------------------------------------------

I. Establishing the environment

  1. Create a new database, with the name "Legal".

  2. Create a new folder, for instance in the C: drive of your machine, with the
  name "SQLCLR".

  3. Copy the "Legal.Utility.SqlClr.dll" SQL CLR assembly file to the folder
  created in step 2. If you've used a different folder, you will have to adjust
  the script in step 5 (that is, the command used to create the assembly).

  4. Copy the rest of the sample files to a folder of your choice.

  5. In SSMS, connect to the newly created database, carefully review, and then
  execute, the following script to create the database objects:

    - "01_Legal_Objects_Script.sql".
    
  6. In SSMS, while connected to the Legal database, carefully review, and then
  execute, the following script to load the sample data:
  
    - "02_Legal_Data_Script.sql".

  7. In SSMS, while connected to the Legal database, carefully review, and then
  execute, the following script to create the stored procedure:

    - "03_Legal_Document_RelevantLaw_Get_byCase_Proc.sql".

--------------------------------------------------------------------------------

II. Running the queries

  1. Use the following script to perform the queries:

    - "04_Legal_Demo01_Complete_Script.sql".

  2. Make changes to the script used in step I.6 to make changes to the data;
  for instance, you could add additional rules, additional facts, or simply
  modify the existing data. Observe how these changes affect query results.
  
--------------------------------------------------------------------------------
