Answered by:
What is the difference between a LightSwitch entity and a SQL table?

Question
-
What is the difference between a LightSwitch entity and a SQL table? Is it that an entity can be mapped to a non-SQL database like Azure or is there something more?Monday, September 27, 2010 1:27 AM
Answers
-
You got it right.
An entity in LightSwitch is used to describe and manage a data item. You are correct that such a data item can reside in various kinds of stores, including but not limited to SQL and SharePoint. LightSwitch ensures that certain core behaviors are true of an entity no matter where it is stored, such as the ability to attach business logic to it and have relationships between entities.
That's the short answer, but I'm going to use this as an opportunity to comment on a few related points.
SQL has a data model: a language used to describe data and its characteristics. We're all quite familiar with that data model: tables, views, columns, keys, constraints and so forth are all elements of that data model. There are other data models in the world as well. XML and the XML InfoSet are two (yes, they are related but distinct).
Microsoft produced another data model a few years ago called the Entity Data Model (EDM), which provides capabilities lacking in SQL but suitable for data that is accessed through a class-based system such as the .NET Framework. EDM is now used by Entity Framework, OData, and various other products.
(FYI, the term "entity" has a long history in relational database design, including the venerable entity-relationship (ER) diagrams used by many and captured in such standards as IDEF1X. I drew on the term when designing a precursor to EDM and it carried over when we designed EDM.)
MSDN describes EDM so I won't go into that. The key point is that LightSwitch provides entity behavior no matter where the entity data is stored: SQL, SharePoint or some custom data source.
You'll notice that LightSwitch gives the option to "add table," not "add entity." There are two reasons for that. First, when you add a new entity in LightSwitch it is stored in a table in the application's SQL database. (You can attach to SharePoint or use a custom data source and in that case entity data is not directly stored in a SQL table.) A side benefit is that most who lack experience with Microsoft data technology or data modeling are familiar with the term table but fewer with the term entity.
Steve
- Proposed as answer by Steve AnonsenMicrosoft employee, Moderator Monday, September 27, 2010 3:56 AM
- Marked as answer by Steve AnonsenMicrosoft employee, Moderator Monday, September 27, 2010 10:29 PM
Monday, September 27, 2010 3:56 AMModerator
All replies
-
Hi,
We have gone back and forth between calling what you see in the designer "entities" and "tables". For example, if you connect to a SharePoint list as a data source, is that really the same thing as a table? An entity in LightSwitch can come from many sources other than SQL.
In the docs we refer to them as entities, because in the strict sense of the word they are more than tables. What you see in the Entity Designer is represented as a table, but if you add a computed field it isn't really part of the attached table. Entity just seemed like a better term.
Hope this helps,
Steve Hoag Microsoft aka the V-BeeMonday, September 27, 2010 2:53 AMModerator -
Can we say 'entity' is to business object like table is to database object?
mysorianMonday, September 27, 2010 3:23 AM -
Yes, that would be a good analogy.
Steve Hoag Microsoft aka the V-BeeMonday, September 27, 2010 3:46 AMModerator -
You got it right.
An entity in LightSwitch is used to describe and manage a data item. You are correct that such a data item can reside in various kinds of stores, including but not limited to SQL and SharePoint. LightSwitch ensures that certain core behaviors are true of an entity no matter where it is stored, such as the ability to attach business logic to it and have relationships between entities.
That's the short answer, but I'm going to use this as an opportunity to comment on a few related points.
SQL has a data model: a language used to describe data and its characteristics. We're all quite familiar with that data model: tables, views, columns, keys, constraints and so forth are all elements of that data model. There are other data models in the world as well. XML and the XML InfoSet are two (yes, they are related but distinct).
Microsoft produced another data model a few years ago called the Entity Data Model (EDM), which provides capabilities lacking in SQL but suitable for data that is accessed through a class-based system such as the .NET Framework. EDM is now used by Entity Framework, OData, and various other products.
(FYI, the term "entity" has a long history in relational database design, including the venerable entity-relationship (ER) diagrams used by many and captured in such standards as IDEF1X. I drew on the term when designing a precursor to EDM and it carried over when we designed EDM.)
MSDN describes EDM so I won't go into that. The key point is that LightSwitch provides entity behavior no matter where the entity data is stored: SQL, SharePoint or some custom data source.
You'll notice that LightSwitch gives the option to "add table," not "add entity." There are two reasons for that. First, when you add a new entity in LightSwitch it is stored in a table in the application's SQL database. (You can attach to SharePoint or use a custom data source and in that case entity data is not directly stored in a SQL table.) A side benefit is that most who lack experience with Microsoft data technology or data modeling are familiar with the term table but fewer with the term entity.
Steve
- Proposed as answer by Steve AnonsenMicrosoft employee, Moderator Monday, September 27, 2010 3:56 AM
- Marked as answer by Steve AnonsenMicrosoft employee, Moderator Monday, September 27, 2010 10:29 PM
Monday, September 27, 2010 3:56 AMModerator -
Thank you Steve Anonsen for that splendid explanation
Regards
Wednesday, October 6, 2010 7:26 PM