Data Relationship in LightSwitch


Visual Studio LightSwitch is a Microsoft tool for building business applications. There are many possible relationships in LightSwitch. A relationship is a structure of data consisting of an unordered set of tuples which share the same type. A relation has zero or more values. There are three types of relations in LightSwitch, which are as follows.

One to one

One-to-one relationships is a small type of relationship. This relationship is also known as point to point communication. A one-to-one relationship is a table that contains fields that are only used for a certain subset of the records in that table.

One to many

The one-to-many relationship is the common type of relationship in database. This relationship is also known as point to multipoint communication. A one-to-many relationship allows records in the first table to be connected to an arbitrary number of records in a second table. This relationship decrease the size of the database and increases the flexibility.

Many to many

This relationship is more complex than a one to many relationship because in addition to the two tables of data we need another table to join the two tables. This relationship is created by defining the third table.

Step by step solution for create data relationship in LightSwitch

Step 1 : Open Visual Studio LightSwitch->Create new table.

1st.png

Step 2 : Create a table such as a Contact table.

2nd..png

Step 3 : Go to gender property->Click on choice list->Write the value and display name->Ok.

2nd.png

Step 4 : Now we create the second table. Right click on data sources->Add table.

image2.png

Step 5 : Create a table such as an EmailAddress table.

3rd..png

Step 6 : Go to emailtype property->Click on choice list->Write value and display name->Ok.

3rd.png

Step 7 : Now we add another table same as in above. This name is PhoneNumber.

4th..png

Step 8 : Go to phone type property->Click on choice list->Write value and display name->Ok.

4th.png

Step 9 : Click on relationship in EmailAddress table->Select table name (contact)->Select delete behavior (Cascade delete)->Ok.

5th.png

Step 10 : Now the result is as in the following image.

6th.png

Step 11 : Click on relationship in PhoneNumber table->Select table name (contact)->Select delete behavior (Cascade delete)->Ok.

7th.png

Step 12 : Now the result is as in the following image.

8th.png

Step 13 : Now the Contact table looks as in the following image.

middle.png

Step 14 : Now we add a screen. Right click on screens->Add screen.

9th.png

Step 15 : Select list and details screen->Select screen data (contact)->Mark all checkboxes->Ok.

10th.png

Step 16 : Run application (Press F5). Click + sign then fill data.

last.png

Up Next
    Ebook Download
    View all
    Learn
    View all