Strong relationship and weak in database

How to identify a strong vs weak relationship on ERD? - Stack Overflow

strong relationship and weak in database

The Entity Relationship Model At a basic level, databases store information about A weak entity is uniquely identified in the context of its regular (or strong). In a relational database, a weak entity is an entity that cannot be uniquely identified by its In entity relationship diagrams (ER diagrams), a weak entity set is indicated by a bold (or double-lined) rectangle (the entity) connected by a bold (or. We draw a solid line if and only if we have an ID-dependent relationship; otherwise it would be a dashed line. Consider a weak but not ID-dependent.

The collection of similar weak entities is called Weak Entity Set. The relationship between a weak entity and a strong entity is always denoted with an Identifying Relationship i. We have Loan as our weak entity, and as I said above for each loan there must be at least one borrower.

strong relationship and weak in database

You can observe in the loan entity set, no customer has borrowed a car loan and hence, it has totally vanished from loan entity set. For the presence of car loan in loan entity set, it must have been borrowed by a customer. In this way, the weak Loan entity is dependent on the strong Customer entity. The second thing, we know is a weak entity does not have a primary key. In the Loan entity set, we have two exactly same entities i.

So, it will be determined that one home loan is borrowed by Customer Jhon and other by Customer Ruby. This is how the composed primary key of weak entity identify each entity in weak entity set.

strong relationship and weak in database

Key Differences Between Strong Entity and Weak Entity The basic difference between strong entity and a weak entity is that the strong entity has a primary key whereas, a weak entity has the partial key which acts as a discriminator between the entities of a weak entity set.

A strong entity is denoted with a single rectangle and a weak entity is denoted with a double rectangle. The relationship between two strong entities is denoted with single diamond whereas, a relationship between a weak and a strong entity is denoted with double diamond called Identifying Relationship.

strong relationship and weak in database

The database would contain a table identifying customers by a customer number primary key ; another identifying the products that can be sold by a product number primary key ; and it would contain a pair of tables describing orders. One of the tables could be called Orders and it would have an order number primary key to identify this order uniquely, and would contain a customer number foreign key to identify who the products are being sold to, plus other information such as the date and time when the order was placed, how it will be paid for, where it is to be shipped to, and so on.

The other table could be called OrderItem; it would be identified by a compound key consisting of both the order number foreign key and an item line number; with other non-primary key attributes such as the product number foreign key that was ordered, the quantity, the price, any discount, any special options, and so on. There may be zero, one or many OrderItem entries corresponding to an Order entry, but no OrderItem entry can exist unless the corresponding Order entry exists.

The zero OrderItem case normally only applies transiently, when the order is first entered and before the first ordered item has been recorded. The OrderItem table stores weak entities precisely because an OrderItem has no meaning independent of the Order.

Learning MySQL by Hugh E. Williams, Saied M.M. Tahaghoghi

Some might argue that an OrderItem does have some meaning on its own; it records that at some time not identified by the record, somebody not identified by the record ordered a certain quantity of a certain product.

This information might be of some use on its own, but it is of limited use. For example, as soon as you want to find seasonal or geographical trends in the sales of the item, you need information from the related Order record.

Some attributes can have multiple values for a given entity. For example, a customer could provide several telephone numbers, so the telephone number attribute is multivalued. Attributes help distinguish one entity from other entities of the same type.

We could use the name attribute to distinguish between customers, but this could be an inadequate solution because several customers could have identical names.

strong entity vs weak entity in dbms

To be able to tell them apart, we need an attribute or a minimal combination of attributes guaranteed to be unique to each individual customer. The identifying attribute or attributes form a key. In our example, we can assume that no two customers have the same email address, so the email address can be the key.

However, we need to think carefully about the implications of our choices.

strong relationship and weak in database

For example, if we decide to identify customers by their email address, it would be hard to allow a customer to have multiple email addresses. Any applications we build to use this database might treat each email address as a separate person, and it might be hard to adapt everything to allow people to have multiple email addresses.

Clearly, there may be several possible keys that could be used to identify an entity; we choose one of the alternative, or candidate, keys to be our main, or primary, key. You usually make this choice based on how confident you are that the attribute will be non-empty and unique for each individual entity, and on how small the key is shorter keys are faster to maintain and use.

  • Difference Between Strong and Weak Entity

Attributes comprising the primary key are shown underlined. The parts of any composite attributes are drawn connected to the oval of the composite attribute, and multivalued attributes are shown as double-lined ovals.

Similarly, a product price could be a positive rational number. Attributes can be empty; for example, some customers may not provide their telephone numbers. You should think carefully when classifying an attribute as multivalued: The sales database requirements may specify that a product has a name and a price. To distinguish between products, we can assign a unique product ID number to each item we stock; this would be the primary key.

Each product entity would have name, price, and product ID attributes.

The Entity Relationship Model - Learning MySQL [Book]

The ER diagram representation of the product entity Representing Relationships Entities can participate in relationships with other entities. For example, a customer can buy a product, a student can take a course, an artist can record an album, and so on. Like entities, relationships can have attributes: Our database could then record each sale and tell us, for example, that at 3: For example, each customer can buy any number of products, and each product can be bought by any number of customers.

This is known as a many-to-many relationship. We can also have one-to-many relationships. For example, one person can have several credit cards, but each credit card belongs to just one person.

Weak entity

Looking at it the other way, a one-to-many relationship becomes a many-to-one relationship; for example, many credit cards belong to a single person. Finally, the serial number on a car engine is an example of a one-to-one relationship; each engine has just one serial number, and each serial number belongs to just one engine.

We often use the shorthand terms 1:

strong relationship and weak in database