-->

Explain about database and DBMS.




Explain about database and DBMS.

ans:-

Database: - Database is a collection of data for one or more multiple uses in very well organized format.
Or
Simply well organized collection of data is database.
One way of classifying databases involves the type of content, for example: bibliographic, full-text, numeric, and image. Databases consist of software-based "containers" that are structured to collect and store information so users can retrieve, add, update or remove such information in an automatic fashion. Database programs are designed for users so that they can add or delete any information needed. The structure of a database is tabular, consisting of rows and columns of information.


Advantages
  • Reduced data redundancy
  • Improved data security
  • Reduced data entry, storage, and retrieval costs
  • Facilitated development of new applications program
  • improved data integrity (integrity:data should be accurate & accurate; it is done by providing some checks
  • multiple users.
  Disadvantages
  • Database systems are complex, difficult, and time-consuming to design
  • Substantial hardware and software start-up costs
  • Initial training required for all programmers and users


Database Management System (DBMS):-It’s a set of computer programs that controls the creation, maintenance, and the use of the database with computer as a platform or of an organization and its end users.
            A DBMS is a system software package that helps the use of integrated collection of data records and files known as databases. It allows different user application programs to easily access the same database. DBMSs may use any of a variety of database models, such as the network model or relational model. In large systems, a DBMS allows users and other software to store and retrieve data in a structured way. Instead of having to write computer programs to extract information, user can ask simple questions in a query language.
             Its roles can be listed as given below.
1. provides an interface to the user as well as to application
2. lets user to create,maintain databases.
3. provides high integrity and security to its data.
4. provides sharing facility to many users.
5. provides relationships between tables.
6. provides access level to different users.
7. maintains integrity,consistency of data etc
Disadvantages:
1.initial setup is expensive
2. training to staffs has to be provided
3.database failures.

4.data conversion( computer file into database file which takes more time)

Explain E-R diagram with example.

Explain E-R diagram with example.

ans:-

The Entity-Relationship (E-R) data model is based on a perception of a real world that consists of a collection of basic objects, called entities, and of relationships among these objects. An entity is a “thing” or “object” in the real world that is distinguishable from other objects. For example, each person is an entity, and bank accounts can be considered as entities.
Entities are described in a database by a set of attributes. For example, the attributes account-number and balance may describe one particular account in a bank, and they form attributes of the account entity set. Similarly, attributes customer-name, customer-street address and customer-city may describe a customer entity.
A relationship is an association among several entities. For example, a depositor relationship associates a customer with each account that she has. The set of all entities of the same type and the set of all relationships of the same type are termed an entity set and relationship set, respectively.
The overall logical structure (schema) of a database can be expressed graphically by an E-R diagram, which is built up from the following components:
  • Rectangles, which represent entity sets
  • Ellipses, which represent attributes.
  • Diamonds, which represent relationships among entity sets.
  • Lines, which link attributes to entity sets and entity sets to relationships.

for example,

E-R can have following types.
one-to-one
one-to-many
many-to-many

Differentiate between centralized and distributed database system.



Differentiate between centralized and distributed database system.

ans:-

Following are differences between distributed and centralized database system.


Centralized system
Distributed System
1.Job is centralized.
1.Job is distributed.
2. Can not process if main server fails.
2. Can still be if a server fails;processing can be done by other servers.
3. Security is given to one machine.
3.Security is given to all.
4.No need to have network for communication.
4 Needs communication channel between all.
5.Not so expensive to set up.
5.It’s expensive to set up.
6.Data speed is comparatively fast.
6.Data speed is slow.
7.Low quality performance.

Diagrammatically it can be shown as



7.High quality performance.

Diagrammatically it can shown

Explain about data security.

Explain about data security.

ans:-
Data security:-
        It simply says protection of data /information contained in database against unauthorized access, modification or destruction. The main condition for database security is to have “database integrity’ which says about mechanism to keep data in consistent form. Besides these all, we can apply different level of securities like:
    1. Physical: - says about sites where data is stored must be physically secured.
    2. Human: - an authorization is given to user to reduce chance of any information leakage or manipulation.
    3. Operating system: must be taken a foolproof operating system regarding security such that no weakness in o.s.
    4. Network: - since database is shared in network so the software level security for database must be maintained.
    5. Database system: - the data in database needs final level of access control i.e. a user only should be allowed to read and issue queries but not should be allowed to modify data.

Etc.

Explain about data integrity.

q)Explain about data integrity.

ans:-
Database integrity:
It means the correctness and consistency of data. It is another form of database protection.
Put simply, data integrity is the assurance that data is consistent and correct.
Data integrity is normally enforced in a database system by a series of integrity constraints or rules.
         Three types of integrity constraints are an inherent part of the relational data model: entity integrity, referential integrity

Entity integrity concerns the concept of a primary key. Entity integrity is an integrity rule which states that every table must have a primary key and that the column or columns chosen to be the primary key should be unique and not null. It means the primary key’s data must not be missing in table/s.
   or
The entity integrity is a constraint on primary key value. It states that any attribute of a primary key cannot contain null value. If primary key contains null value, it is not possible to uniquely identify a record in a relation. Entity integrity ensures that it should be easy to identify each entity in the database.

Referential integrity concerns the concept of a foreign key. The referential integrity rule states that any foreign key value can only be in one of two states. The usual state of affairs is that the foreign key value refers to a primary key value of some table in the database. Occasionally, and this will depend on the rules of the business, a foreign key value can be null. In this case we are explicitly saying that either there is no relationship between the objects represented in the database or that this relationship is unknown.
Or
Referential Integrity
Referential integrity ensures that the relationship between the primary key (in a referenced table) and the foreign key (in each of the referencing tables) is always maintained. The maintenance of this relationship means that:
  • A row in a referenced table cannot be deleted, nor can the primary key be changed, if a foreign key refers to the row. For example, you cannot delete a customer that has placed one or more orders.
  • A row cannot be added to a referencing table if the foreign key does not match the primary key of an existing row in the referenced table. For example, you cannot create an order for a customer that does not exist.

Domain Integrity
Domain (or column) integrity specifies the set of data values that are valid for a column and determines whether null values are allowed. Domain integrity is enforced by validity checking and by restricting the data type, format, or range of possible values allowed in a column.

Explain different database models.



q)Explain different database models.

ans:-

Database model:-A database model or database schema is the structure or format of a database, described in a formal language supported by the database management system.

There are many database models. Let's understand some of the models.


Hierarchical model:-
Hierarchical database is a model in which data is organized into a tree-like structure. In this,
  • Data is organized like a family tree or organization chart
  • The parent record can have multiple child records – child records can only have one parent
  • Pointers link each parent record with each child record
  • Complex and difficult to maintain
This structure allows one 1:N relationship between two types of data. This structure is very efficient to describe many relationships in the real world; recipes, table of contents, ordering of paragraphs/verses,
       Example:

We can see here a parent node with many branches called children.Each child has their own record with furhher informations.In given diagram, the first record has name “Ram” with street “Baneshwor” and city named kathmandu. It is further linked to its balance id and amount. In same fashion all others records have, they all are related or linked to  their id and amount. We can see records’ arrangement in tree like format.
Advantages:-   1) easiest model of database.
                      2) Searching is fast if parent is known.
                      3) supports one to many relationship.
Disadvantages:        1) old and outdated one.
                            2) Can not handle many to many relationships.
                                3) More redundancy.
Network model:-The network model organizes data using two fundamental constructs, called records and sets.        The Network Model
  1. Data are represented by collections of records.
  2. Relationships among data are represented by links.
  3. Organization is that of an arbitrary graph.
  4. Figure  shows a sample network database that is the equivalent of the relational database of Figure ??
eg.


We have taken same example as mentioned above.but the records are arranged in graph like structure. In this we do not use concept of child /parent.In given diagram the records are linked to each other with a solid line as it is in hierarchical. Two records namely Ramesh and Hary are linked to two balance id and amounts.
Advantages:- 1) more flexible due to many to many relationship.
                    2) Reduction of redundancy.
                    3) Searching is very fast.
Disadvantages:-   1) very complex.
                                2) Needs long and complex programs.
                                3) Less security
Relational model: - 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 is represented in columns and rows. Thus, the "relation" in "relational database" refers to the various tables in the database; a relation is a set of tuples.So,

Relational databases
  • Data is organized into two-dimensional tables, or relations
  • Each row is a tuple (record) and each column is an attribute (field)
  • A common field appears in more than one table and is used to establish relationships
  • Because of its power and flexibility, the relational database model is the predominant design approach

name
street
city
id no.
balance
RAm
Thapagaun
KTm
00321
Rs. 900087
ekan
BAneshwor
Pokhara
008
Rs.45666
Hary
Kalanki
Ktm
9870
Rs. 65799
Sam
Koteshwor
Ktm
7890
Rs. 5600
Kale
Kalnki
Ktm
456
Rs. 65400

In this table we have used different concept like field (each column),record (each row). Each row gives us a complete information. If we have many tables then we relate them for data extractions,this is called relationship between tables.Apart from these, we also use other concept like,primary key,foreign key,Entity etc.