Mathematical basics – Set theory

Set

A Set is a collection of objects that are distinct. Assume the following Set A has the elements a, b, c and d, so we can say A = {a,b,c,d}.

In the example above, the element a is within Set A. You can write aA. Another element, let’s say m is not within A, therefore we can write mA.

Two sets have the same mightiness, if they can be imaged bijectively on each other, i.e. there is a one-to-one relationship between their elements.

Bijection:

  • Complete pair formation between the elements of the definition set and target set
  • Bijections thus treat their definition range and their value range symmetrically
  • definition set and target set have the same mightiness

Subsets

If all elements of a Set S are also within another Set B, we call S a subset of B, or SB.

  • all elements of A are also elements of B
  • expressed as SB
  • also S is contained in B
  • same BS, means B is a superset of S
  • all sets are subsets of themselves: SS and BB

The universal Set U includes all objects and additionally itself. So all sets are also subsets of the universal set BU and SU.

The empty set, expressed as ∅, is a subset of all other sets, like as example B and B

Power sets

The Power Set of a Set contains all subsets of the set and additionally also the empty set. The following example defines a set S with elements {1,2}. The Power Set P(S) contains als subsets and the empty set.

  • Power set of finite set contains 2^n elements

Isomorphism

  • bijective
  • also Homeomorphism

Homeomorphism

  • bijective
  • structure-preserving
  • weaker than Isomorphism

Diverse

Code generation with Slick code generator of PostgreSQL database in Scala project

If you automatically want to generate the Tables mapping of your database tables for the use within the Slick environment, you can use the Slick code generator to achieve this task.

The groundwork contains:

  • Database tables definitions within the database to generate the mappings
  • Slick code generator integration to your project
  • Execute the code generation from within the sbt console (or intgrate to your project)

Database tables

You can create your database evolutions by using e.g. PgAdmin or any other tool.

Integrate the Slick code generator to your project

You can integrate the generator within your build.sbt or the Build.scala. The following configuration could be an example project configured within the build.sbt.

libraryDependencies += "com.typesafe.slick" %% "slick-codegen" % "3.2.0"

Execute the generation of the code

Open your sbt.

> sbt

Open the console.

scala> console

Execute the generation of the code.

slick.codegen.SourceCodeGenerator.main(
  Array(
    "slick.jdbc.PostgresProfile",
    "org.postgresql.Driver",
    "jdbc:postgresql://localhost:5432/db",
    "./target/generatedSources",
    "com.my.db",
    "USERNAME",
    "PASSWORD"
  )
)

The SourceCodeGenerator can be configured depending on your needs. Additinoal information can be found at http://slick.lightbend.com/doc/3.2.0/code-generation.html.