IT tutorials
 
Database
 

SQL Server 2012 : Data Design Patterns (part 1) - One-to-Many Pattern, One-to-One Pattern

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

Design is all about building something new by combining existing concepts or items using patterns. The same is true for database design. The building blocks are tables, rows, and columns, and the patterns are one-to-many, many-to-many, and others. This section explains these patterns.

When the entities — nouns and verbs — are organized, the next step is to determine the relationships among the objects. Each relationship connects two entities using their primary and foreign keys.

Clients or business analysts should describe the common relationships between the objects using terms such as includes, has, or contains. For example, a customer may place (has) many orders. An order may include (contains) many items. An item may be on many orders.

Based on these relationship descriptions, you can choose the best data design pattern.

1. One-to-Many Pattern

By far the most common relationship is a one-to-many relationship; this is the classic parent-child relationship. Several tuples (rows) in the secondary entity relate to a single tuple in the primary entity. The relationship is between the primary entity's primary key and the secondary entity's foreign key, as illustrated in the following examples:

  • In the AdventureWorks2012 sample database, each productsubcategory may contain several products. Each product belongs to only one productsubcategory, so the relationship is modeled as one productsubcategory relating to multiple products. The relationship is made between the ProductSubCategories primary key and the Products entity's ProductSubcategoryID foreign key, as diagrammed in Figure 1. Each Product's foreign key attribute contains a copy of its SubCategories's primary key.
  • Each customer may place multiple orders. Although each order has its own unique SalesOrderID primary key, the SalesOrder Header entity also has a foreign key attribute that contains the CustomerID of the customer who placed the order. The SalesOrderHeader entity may have several tuples with the same CustomerID that defines the relationship as one-to-many.

Figure 1 The one-to-many relationship relates zero to many tuples (rows) in the secondary entity to a single tuple in the primary entity.

7.4

2. One-to-One Pattern

At the conceptual diagram layer, one-to-one relationships are quite rare. Typically, one-to-one relationships are used in the SQL physical layer to partition the data for some performance or security reason.

One-to-one relationships connect two entities with primary keys at both entities. Because a primary key must be unique, each side of the relationship is restricted to one tuple.

For example, a Contact entity can store general information about various contacts at a company. However, additional employee information may be stored in a separate entity, as shown in Figure 2. Although security can be applied on a per-attribute basis, or a view can project selected attributes, many organizations choose to model sensitive information as two one-to-one entities.

Figure 2 This one-to-one relationship partitions contact data, segmenting additional employee information into a separate entity.

7.5
 
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