Customer city account number somebody mirpur road

Info icon This preview shows pages 6–8. Sign up to view the full content.

View Full Document Right Arrow Icon
customer-city account-number Somebody Mirpur Road Dhaka A-101 Somebody Mirpur Road Dhaka A-102 Somebody Mirpur Road Dhaka A-103 To solve both the problems, let’s split up the table into two tables as below: account-number customer-name customer-name customer-street customer-city A-101 Somebody Somebody Mirpur Road Dhaka A-102 Somebody A-103 Somebody customer account Now, when we query for the details of the customer who has an account number of A-103 , the account table will be queried first. From the account table, it will be found that a customer named Somebody holds that account number. Next, the details of the customer will be queried from the customer table using that customer name ‘ Somebody ’. Thus, we’ll be able to easily and successfully retrieve all the necessary data using a DBMS. In the two tables, the field customer-name is acting as a link between records. 2 There are some rules for designing efficient databases, one of which is “each field must contain atomic data” – i.e., data which represents only one thing, not several things. customer-name customer-street customer-city account-number Figure 1: Relationships among the attributes of customer table. Legend One-to-one One-to-many Duplicate data
Image of page 6

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
3 What we’ve learnt from here is that, when a one-to-many relationship exists – suppose – from field A to field B , we’ll create two tables: in the first one, we’ll keep the field A , and in the second one, we’ll place the field B and also the field A . This is the reason why we need to define relationships among the attributes – so that we can distribute the attributes among different tables when designing and implementing a database. Well, if you haven’t figured out yet, there is a problem with the above solution. We all know that it is possible that any two customers might have the same name. Consider the following situation: customer-name customer-street customer-city account-number customer-name Somebody Mirpur Road Dhaka A-101 Anybody Somebody Aga Kha Road Bogra A-102 Anybody Anybody XYZ Road Khagrachhori A-103 Somebody customer account From account table, we find that account A-103 is owned by Somebody . Now, from customer table, how can we determine whether this Somebody is the one living in Dhaka , or the one in Bogra ? It seems that we need to use such a linking field in account table, which can uniquely identify a record in the customer table. So, which field in customer table uniquely indentifies a record therein? There might be several customers who have the same name or live at the same street or even in the same city. Therefore, a value may appear more than once in any of the fields. In such cases where none of the attributes uniquely identifies a record in the table, we have to use a field – usually named id – in which unique integer values are assigned for each record. Thus, the above two tables become: customer-id customer-name customer-street customer-city account-number customer-id 1 Somebody Mirpur Road Dhaka A-101 3 2 Somebody Aga Kha Road Bogra A-102 3 3 Anybody
Image of page 7
Image of page 8
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern