Documents

Dbms Notes

Description
Database Management System
Categories
Published
of 56
All materials on our website are shared by users. If you have any questions about copyright issues, please report us to resolve them. We are always happy to assist you.
Related Documents
Share
Transcript
          C) Relational model   The relational model was introduced by E.F. Codd in 1970[1] as a   way to make database management systems more independent of any particular application. It is a mathematical model defined in terms of  predicate logic and set theory.     The products that are generally referred to as relational databases in fact implement a model that is only an approximation to the mathematical model defined by Codd. Three key terms are used extensively in relational database models: relations, attributes, and domains. A relation is a table with columns and rows. The named columns of the relation are called attributes, and the domain is the set of values the attributes are allowed to take.   The basic data structure of the relational model is the table, where information about a particular entity (say, an employee) is represented in rows (also called tuples) and columns. Thus, the   relation in relational database refers to the various tables in the database; a relation is a set of tuples. The columns enumerate the various attributes of the entity (the employee's name, address or phone number, for example), and a row is an actual instance of the entity (a specific employee) that is represented by the relation. As a result, each tuple of the employee table represents various attributes of a single employee.   All relations (and, thus, tables) in a relational database have to adhere to some basic rules to qualify as relations. First, the ordering of columns is immaterial in a table. Second, there can't be identical tuples or rows in a table. And third, each tuple will contain a single value for each of its attributes.   A relational database contains multiple tables, each similar to the one in the flat database model. One of the strengths of the relational model is that, in principle, any value occurring in two different records (belonging to the same table or to different tables), implies a relationship among those two records. Yet, in  order to enforce explicit integrity constraints, relationships   between records in tables can also be defined explicitly, by identifying or non-identifying parent-child relationships characterized by assigning cardinality (1:1, (0)1:M, M:M). Tables can also have a designated single attribute or a set of attributes that can act as a key , which can be used to uniquely identify each tuple in the table.   Q. Describe Entity Types, Entity Sets, Attributes and Keys? Entity Types & Sets:-  An entity is a term from the entity-relationship model .A relational model  (your database schema) is one of the ways to implement the ER model.Relational tables represent relations  between simple types like integers and strings, which, in their turn, can represent everything: entities, attributes, relationships.      An entity is any object in the system that we want to model and store information about    Individual objects are called entities    Groups of the same type of objects are called entity types or entity sets    Entities are represented by rectangles (either with round or square corners)   Attribute:-      All the data relating to an entity is held in its attributes.    An attribute is a property of an entity.    Each attribute can have any value from its domain.    Each entity within an entity type: o   May have any number of attributes. o   Can have different attribute values than that in any other entity. o   Have the same number of attributes.    Attributes can be    simple or composite    single-valued or multi-valued    Attributes can be shown on ER models    They appear inside ovals and are attached to their entity.    Note that entity types can have a large number of attributes... If all are shown then the diagrams would be confusing. Only show an attribute if it adds information to the ER diagram, or clarifies a point.  Q. Describe the following concepts in the context of Joins? a. Keys :-  A key is an attribute (also known as column or field) or a combination of attribute that is used to identify records. The purpose of the key is to bind data together across tables without repeating all of the data in every table.   (I) Super Key  –  An attribute or a combination of attribute that is used to identify the records uniquely is known as Super Key. A table can have many Super Keys.   (II) Candidate Key  –  It can be defined as minimal Super Key or irreducible Super Key. In other words an attribute or a combination of attribute that identifies the record uniquely but none of its proper subsets can identify the records uniquely.   (III) Primary Key  –  A Candidate Key that is used by the database designer for unique identification of each row in a table is known as Primary Key. A Primary Key can consist of one or more attributes of a table.   (IV) Foreign Key  –  A foreign key is an attribute or combination of attribute in one base table that points to the candidate key (generally it is the primary key) of another table. The purpose of the foreign key is to ensure referential integrity of the data i.e. only values that are supposed to appear in the database are permitted.   (V) Composite Key  –   If we use multiple attributes to create a Primary Key then that Primary Key is called Composite Key.   (VI) Alternate Key  –  Alternate Key can be any of the Candidate Keys except  for the Primary Key.   (VII) Secondary Key  –   The attributes that are not even the Super Key but can be still used for identification of records (not unique) are known as Secondary Key.   b. Performing a Join :-  A SQL  JOIN  clause combines records from two or more tables in a database.   [1]  It creates a set that can be saved as a table or used as is. A JOIN  is a means for combining fields from two tables by using values common to each. ANSI standard SQL specifies four types of JOIN s: INNER , OUTER , LEFT , and RIGHT . In special cases, a table (base table, view, or  joined table) can JOIN  to itself in a self-join.A programmer writes a JOIN  predicate to identify the records for joining. If the evaluated predicate is true, the combined record is then produced in the expected format, a record set or a temporary table.    All subsequent explanations on join types in this article make use of the following two tables. The rows in these tables serve to illustrate the effect of different types of joins and join-predicates. In the following tables the DepartmentID  column of the Department  table (which can be designated as Department.DepartmentID ) is the primary key, while Employee.DepartmentID  is a foreign key.   c. Distinct and Eliminating Duplicates:-  every field in one record is identical to every field in a different record, i.e. a duplicate is where there is no way of telling two or more records apart. If you just need to remove records which are similar (i.e. one or more fields are identical but there are one or more fields which are different) then instead refer to how to delete similar records.   To check that you have duplicate records in your table do the following:   select count(*) from MyTable   and   select distinct * from MyTable   Unfortunately there is no way in SQL to delete one of these duplicates without deleting all of them. They are identical after all, so there is no SQL query that

Bhut Jolokia

Aug 2, 2017
We Need Your Support
Thank you for visiting our website and your interest in our free products and services. We are nonprofit website to share and download documents. To the running of this website, we need your help to support us.

Thanks to everyone for your continued support.

No, Thanks
SAVE OUR EARTH

We need your sign to support Project to invent "SMART AND CONTROLLABLE REFLECTIVE BALLOONS" to cover the Sun and Save Our Earth.

More details...

Sign Now!

We are very appreciated for your Prompt Action!

x