IT tutorials
 
Database
 

SQL Server 2012 : Data Design Patterns (part 3) - Domain Integrity Lookup Pattern

11/26/2013 1:52:34 AM
- Free product key for windows 10
- Free Product Key for Microsoft office 365
- Malwarebytes Premium 3.7.1 Serial Keys (LifeTime) 2019

Supertype/Subtype Pattern

One design pattern that's not used often enough is the supertype/subtype pattern. The supertype/subtype pattern is also perfectly suited to modeling an object-oriented design in a relational database. For the application this model provides advantages that may not be realized with the traditional relational database design patters. However, because this model has the potential to increase the number of tables by several times, writing queries for reporting purposes could become an arduous task. Figure 6 provides a detail illustration of this method.

Figure 6 The supertype/subtype pattern uses an optional one-to-one relationship that relates a primary key to a primary key.

7.9

The supertype/subtype relationship leverages the one-to-one relationship to connect one supertype entity with one or more subtype entities. This extends the supertype entity with what appears to be flexible attributes.

The textbook example is a database that needs to store multiple types of contacts. All contacts have basic contact data such as name, location, phone number, and so on. Some contacts are customers with customer attributes (credit limits, loyalty programs, and so on). Some contacts are vendors with vendor-specific data.

Although you can use separate entities for customers and vendors, an alternative design is to use a single Contact entity (the supertype) to hold every contact, regardless of their type, and the attributes common to every type (probably just the name and contact attributes). Separate entities (the subtypes) hold the attributes unique to customers and vendors. A customer would have a tuple (row) in the contact and the customer entities. A vendor would have tuples in both the contact and vendor entities. All three entities share the same primary key (refer to Figure 6).

Sometime data modelers who use the supertype/subtype pattern add a type attribute in the supertype entity, so it's easy to quickly determine the type by searching the subtypes. This works well but it restricts the tuples to a single subtype.

Without the type attribute, you can allow tuples to belong to multiple subtypes. Sometimes, this is referred to as allowing the supertype to have multiple roles. In the contact example, multiple roles (for example, a contact who is both an employee and customer) could mean the tuple has data in the supertype entity (for example, contact entity) and each role subtype entity (for example, employee and customer entities).

5. Domain Integrity Lookup Pattern

The domain integrity lookup pattern, informally called the lookup table pattern, is common in production databases. This pattern serves to only limit the valid options for an attribute, as illustrated in Figure 7.

Figure 7 The domain integrity lookup pattern uses a foreign key to ensure that only valid data is entered into the attribute.

7.10

The classic example is the state, or region, lookup entity. Unless the organization regularly deals with several states as clients, the state lookup entity serves only to ensure that the state attributes in other entities are correctly entered. Its only purpose is data consistency.

 
Others
 
 
 
Top 10
 
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 2) - Wireframes,Legends
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 1) - Swimlanes
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Formatting and sizing lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Adding shapes to lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Sizing containers
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 3) - The Other Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 2) - The Data Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 1) - The Format Properties of a Control
- Microsoft Access 2010 : Form Properties and Why Should You Use Them - Working with the Properties Window
- Microsoft Visio 2013 : Using the Organization Chart Wizard with new data
Technology FAQ
- Is possible to just to use a wireless router to extend wireless access to wireless access points?
- Ruby - Insert Struct to MySql
- how to find my Symantec pcAnywhere serial number
- About direct X / Open GL issue
- How to determine eclipse version?
- What SAN cert Exchange 2010 for UM, OA?
- How do I populate a SQL Express table from Excel file?
- code for express check out with Paypal.
- Problem with Templated User Control
- ShellExecute SW_HIDE
programming4us programming4us