Database Basic for amatuers

6
D D D a a a t t t a a a b b b a a a s s s e e e M M M a a a n n n a a a g g g e e e m m m e e e n n n t t t S S S y y y s s s t t t e e e m m m s s s w w w i i i t t t h h h M M M S S S A A A c c c c c c e e e s s s s s s M M M o o o h h h a a a m m m m m m a a a d d d N N N a a a z z z m m m i i i N N N e e e w w w a a a z z z , , , A A A s s s s s s o o o c c c i i i a a a t t t e e e M M M a a a n n n a a a g g g e e e m m m e e e n n n t t t C C C o o o u u u n n n s s s e e e l l l l l l o o o r r r , , , B B B a a a n n n g g g l l l a a a d d d e e e s s s h h h I I I n n n s s s t t t i i i t t t u u u t t t e e e o o o f f f M M M a a a n n n a a a g g g e e e m m m e e e n n n t t t 1 D D D A A A T T T A A A B B B A A A S S S E E E M M M A A A N N N A A A G G G E E E M M M E E E N N N T T T S S S Y Y Y S S S T T T E E E M M M S S S T T T H H H E E E O O O R R R E E E T T T I I I C C C A A A L L L K K K N N N O O O W W W L L L E E E D D D G G G E E E B B B A A A S S S E E E P P P r r r e e e p p p a a a r r r e e e d d d b b b y y y M M M o o o h h h a a a m m m m m m a a a d d d N N N a a a z z z m m m i i i N N N e e e w w w a a a z z z

description

Excel Basics

Transcript of Database Basic for amatuers

Page 1: Database Basic for amatuers

DDDaaatttaaabbbaaassseee MMMaaannnaaagggeeemmmeeennnttt SSSyyysssttteeemmmsss wwwiiittthhh MMMSSS AAAcccccceeessssss

MMMooohhhaaammmmmmaaaddd NNNaaazzzmmmiii NNNeeewwwaaazzz,,, AAAssssssoooccciiiaaattteee MMMaaannnaaagggeeemmmeeennnttt CCCooouuunnnssseeellllllooorrr,,, BBBaaannnggglllaaadddeeessshhh IIInnnssstttiiitttuuuttteee ooofff MMMaaannnaaagggeeemmmeeennnttt

1

DDDAAATTTAAABBBAAASSSEEE MMMAAANNNAAAGGGEEEMMMEEENNNTTT SSSYYYSSSTTTEEEMMMSSS

TTTHHHEEEOOORRREEETTTIIICCCAAALLL KKKNNNOOOWWWLLLEEEDDDGGGEEE BBBAAASSSEEE

PPPrrreeepppaaarrreeeddd bbbyyy

MMMooohhhaaammmmmmaaaddd NNNaaazzzmmmiii NNNeeewwwaaazzz

Page 2: Database Basic for amatuers

DDDaaatttaaabbbaaassseee MMMaaannnaaagggeeemmmeeennnttt SSSyyysssttteeemmmsss wwwiiittthhh MMMSSS AAAcccccceeessssss

MMMooohhhaaammmmmmaaaddd NNNaaazzzmmmiii NNNeeewwwaaazzz,,, AAAssssssoooccciiiaaattteee MMMaaannnaaagggeeemmmeeennnttt CCCooouuunnnssseeellllllooorrr,,, BBBaaannnggglllaaadddeeessshhh IIInnnssstttiiitttuuuttteee ooofff MMMaaannnaaagggeeemmmeeennnttt

2

EEENNNTTTIIITTTYYY An entity is an object with a distinct set of properties that easily identified. Entities are the building blocks of a database. Some examples are Student, Course, Grade etc. An entity instance is a specific value of an entity. For example; Bipul, Aurko, and Ratul are students, they are instances of the entity Student. Similarly, Mathematics and Physics are instances of the entity Course. EEENNNTTTIIITTTYYY SSSEEETTT An entity set is a set of entities of the same type that share the same properties, or attributes. For example; the set of all persons who are students at a given department, can be defined as the entity set Student. The individual entities that constitute a set are said to be the extension of the entity set. Thus, all the individual department students are the extension of the Entity Set Student. AAATTTTTTRRRIIIBBBUUUTTTEEESSS An attribute is a property of an entity that differentiates it from other entities and provides information about the entity. An attribute is a property of an entity type. For example; the attributes of the entity Student are Student ID, Student Name, Student Roll, Student Course etc. In an E/R model, we express attributes as ellipses and label them with the name of the attributes.

Attributes mainly consists of values and domain or value set.

VVVAAALLLUUUEEE Each entity has a value for each of its attributes. For example; a particular Student Entity may have the value “019-320-286” for Student ID, “Bipul” for Student Name.

DDDOOOMMMAAAIIINNN There is a set of permitted values for each attribute, called The Domain or Value Set, of that attribute. The domain of attribute Student Name might be the set of all text strings of a certain length. Again in case of Employee Salary in the Employee entity set, the domain might be the set of numerical numbers.

Page 3: Database Basic for amatuers

DDDaaatttaaabbbaaassseee MMMaaannnaaagggeeemmmeeennnttt SSSyyysssttteeemmmsss wwwiiittthhh MMMSSS AAAcccccceeessssss

MMMooohhhaaammmmmmaaaddd NNNaaazzzmmmiii NNNeeewwwaaazzz,,, AAAssssssoooccciiiaaattteee MMMaaannnaaagggeeemmmeeennnttt CCCooouuunnnssseeellllllooorrr,,, BBBaaannnggglllaaadddeeessshhh IIInnnssstttiiitttuuuttteee ooofff MMMaaannnaaagggeeemmmeeennnttt

3

AAATTTTTTRRRIIIBBBUUUTTTEEESSS CCCAAANNN BBBEEE CCCHHHAAARRRAAACCCTTTEEERRRIIIZZZEEEDDD BBBYYY DDDIIIFFFFFFEEERRREEENNNTTT AAATTTTTTRRRIIIBBBUUUTTTEEE TTTYYYPPPEEESSS

SSSiiimmmpppllleee aaannnddd CCCooommmpppooosssiiittteee AAAttttttrrriiibbbuuuttteeesss When attributes are divided into only one part, then it is a single attribute(example of single attribute described earlier); and when into several subparts, it is a composite attribute(for example; an attribute Student Name could be structured as a composite attribute consisting of first-name, middle-name, and last-name.

SSSiiinnngggllleee---vvvaaallluuueeeddd aaannnddd MMMuuullltttiii---vvvaaallluuueeeddd AAAttttttrrriiibbbuuuttteeesss In all our examples, we have single – valued attributes. But in some cases, there may more than one value for an attribute; say for, an attribute Student Phone No. may have more than one number, or even no number.

DDDeeerrriiivvveeeddd AAAttttttrrriiibbbuuuttteeesss Sometimes, the value for an attribute can be derived from the values of other related attributes or entities. For example; the Student entity set has an attribute Age, which indicates the student’s age. If the Student entity set also has an attribute date-of-birth, we can calculate the age from the date-of-birth and the current date.

RRREEELLLAAATTTIIIOOONNNSSSHHHIIIPPP A relationship is an association among several entities. It is used to establish a connection between a pair of logical related entities. Separate entities can have relationships with each other. For example; if students study various courses, the entities Student and Course, while the relationship between them is Studies.

A relationship may associate an entity with itself. For example; in a company, one employee may marry another employee; then the relationship will be expressed as follows ::

Student Course Studies

Employee

Marriage

Page 4: Database Basic for amatuers

DDDaaatttaaabbbaaassseee MMMaaannnaaagggeeemmmeeennnttt SSSyyysssttteeemmmsss wwwiiittthhh MMMSSS AAAcccccceeessssss

MMMooohhhaaammmmmmaaaddd NNNaaazzzmmmiii NNNeeewwwaaazzz,,, AAAssssssoooccciiiaaattteee MMMaaannnaaagggeeemmmeeennnttt CCCooouuunnnssseeellllllooorrr,,, BBBaaannnggglllaaadddeeessshhh IIInnnssstttiiitttuuuttteee ooofff MMMaaannnaaagggeeemmmeeennnttt

4

TTTYYYPPPEEESSS OOOFFF RRREEELLLAAATTTIIIOOONNNSSSHHHIIIPPPSSS

There are three types of relationships that can exist between entities ::

One – To – One (1:1)

One – To – Many (1:m)

Many – To – Many (m:m)

Many – To – One (m:1)

DDDeeepppaaarrrtttmmmeeennnttt Faculty-MemberHeaded By1 1

SSStttuuudddeeennnttt DDDiiisssccciiipppllliiinnneee Register form 1

CCCuuussstttooommmeeerrr PPPrrroooddduuucccttt Purchasem m

PPPaaatttiiieeennntttsss DDDoooccctttooorrr Appointmentm 1

Page 5: Database Basic for amatuers

DDDaaatttaaabbbaaassseee MMMaaannnaaagggeeemmmeeennnttt SSSyyysssttteeemmmsss wwwiiittthhh MMMSSS AAAcccccceeessssss

MMMooohhhaaammmmmmaaaddd NNNaaazzzmmmiii NNNeeewwwaaazzz,,, AAAssssssoooccciiiaaattteee MMMaaannnaaagggeeemmmeeennnttt CCCooouuunnnssseeellllllooorrr,,, BBBaaannnggglllaaadddeeessshhh IIInnnssstttiiitttuuuttteee ooofff MMMaaannnaaagggeeemmmeeennnttt

5

KKKEEEYYYSSS

SSSUUUPPPEEERRRKKKEEEYYY

A superkey is a set of one or more attributes that taken collectively, allow us to identify uniquely an entity in the entity set. For example; the Customer ID attribute of the entity set Customer is sufficient to distinguish one customer entity from another. Thus, Customer ID is a superkey.

CCCAAANNNDDDIIIDDDAAATTTEEE KKKEEEYYY

An attribute or set of attributes that uniquely identifies a row is called a Candidate key. This attribute has values that are unique. Consider the following table ::

Table: Vehicle Serial Number Registration Number Description

0234510001 02 – 5879 Toyota 0234510991 03 – 3687 Hyundai

The value of the attributes Serial Number, Reg. Number, and Description are unique in every row. Therefore, all three are candidate keys.

PPPRRRIIIMMMAAARRRYYY KKKEEEYYY

The candidate key that is chosen to identify each row uniquely is called the Primary Key. In the table, Vehicle, if Serial Number is chosen to identify rows uniquely, then Serial Number is the Primary Key.

AAALLLTTTEEERRRNNNAAATTTEEE KKKEEEYYY

A candidate key that is not chosen as a Primary key is an Alternate Key. In the table Vehicle, Serial Number is chosen as the Primary Key, then Registration Number is the Alternate Key.

CCCOOOMMMPPPOOOSSSIIITTTEEE KKKEEEYYY In certain tables, a single attribute cannot be used to identify rows uniquely and a combination of two or more attributes is used as a Primary key. Such keys are called Composite Keys.

Page 6: Database Basic for amatuers

DDDaaatttaaabbbaaassseee MMMaaannnaaagggeeemmmeeennnttt SSSyyysssttteeemmmsss wwwiiittthhh MMMSSS AAAcccccceeessssss

MMMooohhhaaammmmmmaaaddd NNNaaazzzmmmiii NNNeeewwwaaazzz,,, AAAssssssoooccciiiaaattteee MMMaaannnaaagggeeemmmeeennnttt CCCooouuunnnssseeellllllooorrr,,, BBBaaannnggglllaaadddeeessshhh IIInnnssstttiiitttuuuttteee ooofff MMMaaannnaaagggeeemmmeeennnttt

6

Consider the following table, Purchase, which is used to maintain the purchases made by various customers.

Customer_Code Product_Code Quantity Purchased Purchase Date C0122 P0002 12 Feb – 02 – 2002 C0134 P0005 15 Feb – 02 – 2002 C0018 P0002 10 Feb – 04 – 2002 C0122 P0003 17 Feb – 04 – 2002 C0144 P0001 4 Feb – 07 – 2002 C0134 P0003 9 Feb – 07 – 2002

In the above table, all values are not unique for any of the attributes. However, a combination of Customer_Code and Product_Code results in all unique values. Hence, the combination can be used as a Composite Primary Key.

FFFOOORRREEEIIIGGGNNN KKKEEEYYY

When a Primary key of one table appears as an attribute in another table, it is called the Foreign Key, in the second table. A foreign key is used to relate two tables.

EEENNNTTTIIITTTYYY ––– RRREEELLLAAATTTIIIOOONNNSSSHHHIIIPPP DDDIIIAAAGGGRRRAAAMMM An entity – relation diagram or E/R diagram perceives the real world as consisting of basic objects, called entities, and relationships among these objects. It is a tool to build the logical database design of a system. An E/R diagram represents the following three elements ::

Entities Relationships Attributes

E/R diagrams are simple and clear. An E/R diagram consists of the following major components ::

Rectangles :: which represents entity sets. Ellipses :: which represents attributes. Diamonds :: which represents relationship sets. Lines :: which link attributes to entity sets and entity sets to relationship sets

Double Ellipses :: which represent multi-valued attributes. Dashed Ellipses :: which denote derived attributes. Double Lines :: which indicate total participation of an entity in a relationship set.

Double Rectangles :: which represent weak entity sets.