You are on page 1of 15

c   

  c  
  
    c     

  


 is a combination of attributes that can be uniquely used to identify a
database record without any extraneous data. Each table may have one or more
candidate keys. One of these candidate keys is selected as the table primary key.

A table may have more than one key,each key is called a 




E.g( 1) A table CUSTOMER consists of columns: Customer_Id,name,Address etc..


Customer_Id is the only key (unique),thus a candidate key.

E.g(2) consider a table CAR where we can have 2 keys namely license_no,serial_no
(which should be unique).
Both license_no and serial_no are candidate keys.


  
 
 !
!" 


 #!$ % & 

"! 
 is a field in a relational table that matches the primary key column of
another table. The foreign key can be used to cross-reference tables.
The foreign key identifies a column or a set of columns in one (referencing) table that
refers to a set of columns in another (referenced) table. The columns in the referencing
table must be the primary key or other candidate key in the referenced table. The values
in one row of the referencing columns must occur in a single row in the referenced
table. Thus, a row in the referencing table cannot contain values that don't exist in the
referenced table (except potentially NULL). This way references can be made to link
information together and it is an essential part of database normalization


% &  of a relational table uniquely identifies each record in the table. It can
either be a normal attribute that is guaranteed to be unique (such as Social Security
Number in a table with no more than one record per person) or it can be generated by
the DBMS (such as a globally unique identifier, or GUID, in Microsoft SQL Server).
Primary keys may consist of a single attribute or multiple attributes in combination

Example: primary key and foreign key in oracle


c   
  c  
  
    c     

CREATE TABLE table_name (
id number(4) c  ',
col2 varchar2(20),
col3 number(4));

CREATE TABLE table_name (


id number(4) "
 table_name(id));

x 

# 
: - A candidate keys that is not primary key, is called an alternate key

 ( ( )(*


( Î is a database computer language designed for RDBMS,
and originally based upon relational algebra and calculus. Its scope includes 

 +( (% 
 # , &  !

&! "  !

 
!
!#.

SQL was one of the first commercial languages fo  ,! -# !
#&! #
as described in his influential 1970 paper,. # !
#! #!" "!* 
   
. Despite not adhering to the relational model as described by
Codd, it became the most widely used database language.

SQL was developed at IBM by Donald D. Chamberlin and Raymond F. Boyce in the
early 1970s. This version initially called )/* (tructured nglish )(ry *anguage).
The acronym SEQUEL was later changed to SQL because "SEQUEL" was a trademark
of the UK-based Hawker Siddeley aircraft company.

After testing SQL at customer test sites to determine the usefulness and practicality of
the system, IBM began developing commercial products based on their System R
prototype including System/38, SQL/DS, and DB2, which were commercially available
in 1979, 1981, and 1983, respectively

)**
( #&

c   
  c  
  
    c     

The SQL language is sub-divided into several language elements, including:

ë # (, which are constituent components of statements and queries. (In some
cases, these are optional.)
ë 0% !
, which can produce either scalar values or tables consisting of
columns and rows of data.
ë c  , which specify conditions that can be evaluated to SQL three-valued
logic (3VL) or Boolean (true/false/unknown) truth values and which are used to
limit the effects of statements and queries, or to change program flow.

ë )( , which retrieve the data based on specific criteria. This is the most
important element of )*.
ë  &
, which may have a persistent effect on schemata and data, or which
may control transactions, program flow, connections, sessions, or diagnostics.
ë SQL statements also include the semicolon (";") statement terminator. Though
not required on every platform, it is defined as a standard part of the SQL
grammar.
ë 
 
" 
 %  is generally ignored in SQL statements and queries,
making it easier to format SQL code for readability.

% # 1 !
An entity set may include sub groupings of entities that are distinct in
some way from other entities in the set. For instance, a subset of entities within an entity
set may have attributes that are not shared by all the entities in the entity set. The E-R
model provides a means for representing these distinctive entity groupings. Consider an
entity set person, with attributes name, street, and city. A person may be further
classified as one of the following:
‡customer
‡ employee

Each of these person types is described by a set of attributes that includes all the
attributes of entity set person plus possibly additional attributes. For example, customer
entities may be described further by the attribute customer-id, whereas employee
entities may be described further by the attributes employee-id and salary. The process
of designating subgroupings within an entity set is called specialization. The
specialization of person allows us to distinguish among persons according to whether
they are employees or customers.

Specialization is a top down design process; we designate sub groupings within an


entity set that are distinctive from other entities in the set.
c   
  c  
  
    c     


2
 # 1 !
The design process may also proceed in a bottom-up manner, in which
multiple entity sets are synthesized into a higher-level entity set on the basis of common
features. The database designer may have first identified a customer entity set with the
attributes name, street, city, and customer-id, and an employee entity set with the
attributes name, street, city, employee-id, and salary. There are similarities between the
customer entity set and the employee entity set in the sense that they have several
attributes in common. This commonality can be expressed by generalization, which is a
containment relationship that exists between a higher-level entity set and one or more
lower-level entity sets. In our example, person is the higher-level entity set and
customer and employee are lower-level entity sets.

Higher- and lower-level entity sets also may be designated by the terms super class and
subclass, respectively. The person entity set is the super class of the customer and
employee sub classes. For all practical purposes, generalization is a simple inversion of
specialization. We will apply both processes, in combination, in the course of designing
the E-R schema for an enterprise. In terms of the E-R diagram itself, we do not
distinguish between specialization and generalization. New levels of entity
representation will be distinguished (specialization) or synthesized (generalization) as
the design schema comes to express fully the database application and the user
requirements of the database. Differences in the two approaches may be characterized
by their starting point and overall goal. Generalization proceeds from the recognition
c   
  c  
  
    c     

that a number of entity sets share some common features (namely, they are described
by the same attributes and participate in the same relationship sets).

 !

Aggregation is an abstraction in which relationship sets (along with their associated
entity sets) are treated as higher-level entity sets, and can participate in relationships.

,(
 !
# %



In a given table, an attribute D is said to have a functional dependency on a set


of attributes (written ĺ D) if and only if each value is associated with
precisely one D value. For example, in an "Employee" table that includes the
attributes "Employee ID" and "Employee Date of Birth", the functional
dependency {Employee ID} ĺ {Employee Date of Birth} would hold. It follows
from the previous two sentences that each {Employee ID} is associated with
precisely one {Employee Date of Birth}. In reality this would not be the case since
an {Employee Date of Birth} might be null and thus an {Employee ID} might be
associated with no {Employee Date of Birth}.
c   
  c  
  
    c     

  #"(
 !
# %



A trivial functional dependency is a functional dependency of an attribute on a


superset of itself. {Employee ID, Employee Address} ĺ {Employee Address} is
trivial, as is {Employee Address} ĺ {Employee Address}.

,(##"(
 !
# %



An attribute is fully functionally dependent on a set of attributes X if it is

ë functionally dependent on X, and


ë not functionally dependent on any proper subset of X. {Employee
Address} has a functional dependency on {Employee ID, Skill}, but not a
x  functional dependency, because it is also dependent on {Employee
ID}.


  %


A transitive dependency is an indirect functional dependency, one in which ĺ
only by virtue of ĺD and Dĺ.

(#  #(  %





A multivalued dependency is a constraint according to which the presence of


certain rows in a table implies the presence of certain other rows.

3!
 %



A table  is subject to a join dependency if  can always be recreated by joining


multiple tables each having a subset of the attributes of .

(%

A superkey is a combination of attributes that can be used to uniquely identify a


database record. A table might have many superkeys.

4  !& # 1 !
!& # 1 !

 %!5

Normalization is the process of efficiently organizing data in a database. There are two
goals of the normalization process: eliminating redundant data (for example, storing the
c   
  c  
  
    c     

same data in more than one table) and ensuring data dependencies make sense (only
storing related data in a table). Both of these are worthy goals as they reduce the
amount of space a database consumes and ensure that data is logically stored.

!& #,!&

The database community has developed a series of guidelines for ensuring that
databases are normalized. These are referred to as normal forms and are numbered
from one (the lowest form of normalization, referred to as first normal form or 1NF)
through five (fifth normal form or 5NF). In practical applications, you'll often see 1NF,
2NF, and 3NF along with the occasional 4NF and 5NF.

,  !& #,!&6,

First normal form (1NF) sets the very basic rules for an organized database:

ë Eliminate duplicative columns from the same table.


ë Create separate tables for each group of related data and identify each row with a
unique column or set of columns (the primary key).

!
!& #,!&,

Second normal form (2NF) further addresses the concept of removing duplicative data:

ë Meet all the requirements of the first normal form and every non-key attribute is fully
functionally dependent on the whole key or primary key.
ë Remove subsets of data that apply to multiple rows of a table and place them in
separate tables.
ë Create relationships between these new tables and their predecessors through the
use of foreign keys.

  !& #,!&7,

Third normal form (3NF) goes one large step further:


c   
  c  
  
    c     

ë Meet all the requirements of the second normal form.
ë Remove columns that are not dependent upon the primary key or there are no
transitive functional dependency.

!! !& #,!& ,!78,

The Boyce-Codd Normal Form, also referred to as the "third and half (3.5) normal form",
adds one more requirement:

ë Meet all the requirements of the third normal form.


ë Every determinant must be a candidate key.

,!( !& #,!&9,

Fourth normal form (4NF) has one additional requirement: 

ë Meet all the requirements of the third normal form.


ë A relation is in 4NF if it has no multi-valued dependencies.

, " !& #,!&8,

Finally, Fifth normal form (5NF) has one additional requirement:

ë Meet all the requirements of the fourth normal form.


ë A relation is said to be in the 5NF if and only if every join dependency in it is implied
by the candidate keys.

4 cc2   *2 

Wrapping is a process of hiding database constraint or disable constraints.

Constraints are valuable tools for maintaining data integrity in databases. However,
there are times when it is convenient to disable one or more of them to perform tasks
such as data synchronization with an offline database.

  $#
,! 
'
I do not advocate removing foreign key constraints from a relational database. However,
there are times when you may need to temporarily relieve the referential integrity
checks of one or more foreign keys, such as when you're performing a large number of
c   
  c  
  
    c     

inserts and updates on a series of tables and want more accurate results and better
performance. Of course, you should only use this technique when it is impractical to
perform massive amounts of data updates to an entire database in the proper relational
order

  $#
,! 
'
I do not advocate removing foreign key constraints from a relational database. However,
there are times when you may need to temporarily relieve the referential integrity
checks of one or more foreign keys, such as when you're performing a large number of
inserts and updates on a series of tables and want more accurate results and better
performance. Of course, you should only use this technique when it is impractical to
perform massive amounts of data updates to an entire database in the proper relational
order
-- Disable foreign key constraint
ALTER TABLE Orders
NOCHECK CONSTRAINT
FK_Orders_Customers

To re-enable the foreign key constraint, simply execute the following query:

-- Enable foreign key constraint


ALTER TABLE Orders
CHECK CONSTRAINT
FK_Orders_Customers

  $#
 
It's also possible to disable a trigger when necessary. Sometimes when synchronizing
data you do not want a trigger to fire. For instance, if you are updating an offline/mobile
database (as in the previous example), there may be triggers on several tables that you
c   
  c  
  
    c     

may not be aware of. These triggers may fire when a row is inserted into their table
causing the row to be reinserted into another table. But during a large data
synchronization, you might not want those types of inserts to be reinserted. To avoid
that eventuality, you can temporarily disable the trigger, like so:

DISABLE TRIGGER MyTriggerName ON MyTableName

To re-enable the trigger, simply execute the following query:

ENABLE TRIGGER MyTriggerName ON MyTableName



A domain is a pool of values from which one or more attributes [columns] draw their
actual values. For example, the domain for the attribute CODE would be the set of all
legal supplier codes. A set of values appearing in that column at any given time, would
be a subset of that column.

For example: (%%#  $#

  ( (!"
  
c   
  c  
  
    c     




ë A domain is a pool of values from which the actual attribute values are taken.

ë Domain Constraints
3 limit the range of domain values of an attribute
3 specify uniqueness and `nullness' of an attribute
3 specify a default value for an attribute when no value is provided.


c   
  c  
  
    c     

 


! ( !


Data : raw facts.

Data Processing : performing operations on the input data to generate output.

Database : collection of related information about a particular enterprise.

Database Management System : collection of interrelated data, set of programs to


access the data conveniently and efficiently.

, # &

Typically data is stored in files. 1.) Flat files contains one table at a time generally

2.) Flat files contains values at each row and separated with a special symbol so
to reach the data you have to parse each row and obtaining an array of values
and then you can query the data.

3.) To control the data in a file , you have to read it line by line and parse it and
because of it they are slow

4.) There is no control mechanism in files

5.) DBMS systems commonly has a special language called sql to modify and
reach the data easily

6.) DBMS systems has indexes to reach the data, not read it line by line

7.) There are much more control mechanisms that approves the correctness of
data

8.) You can reach the data across networks by using a dbms system easily and
safely

 "! $ 


&
 &

Data access through file systems suffers from the following problems.

ë minimal data redundancy


ë inconsistency
c   
  c  
  
    c     

ë concurrent access
ë data isolation
ë integrity
ë atomicity
ë security

A good database management system solves all the above mentioned problems which
a user generally faces in a file system.

 $ /

Following are the types of database users:

ë Database Administrator - a database administrator performs the following


activities:
3 Monitoring performance
3 Granting user authority to access the database
ë Application programmers
ë Data analysts
ë Naive users
ë Enforcing security and integrity rules
ë Strategizing backup & recovery


% %%#  !
  (
    (

Modern enterprise application architecture consists of the following layers

1. application client
2. application server
3. database system

c   


     
  


   x     x       
  
  

 $ !!#

ë query tools
ë administration tools
c   
  c  
  
    c     

 $   (

Following are the different database architecture types:

ë Centralized
ë Client-server
ë Parallel (multi-processor)
ë Distributed

c  
 

3 data
3 statistical data
3 meta data/dictionary
w integrity constraints
w domain constraints
w referential integrity
w assertions
w authorization
w data storage
3 indices

 $  $   !


ë physical abstraction
ë logical abstraction
ë view abstraction

To the design of complex data structure for the representation of data in the database,
however since database system are often used by non computer professionals, this
complexity must be hidden from database system users. This is done by defining level
of abstract as which the database may be viewed, There are logical view or external,
conceptual view and internal view or physical view.

Ê
 

This is the highest level of abstraction as seen by a user. This level of abstraction as
seen by user. This level of abstraction describe only part of entire database.

  
 

This is the next higher level of abstraction which is the sum total of user's views. This
level describe what data are actually stored in the database. This level contain
information about entire database in term of small number of relatively simple structure.
c   
  c  
  
    c     

Ô
 

This is the lowest level of abstraction at which one describes how the data are pysically
stored.

 $ & 

Definition : Overall design of data base. Schema contains 'No of records + Type of data
+ No of attributes'

ë External level or Sub schema

ë logical schema
ë physical schema

 $ 



Definition: The term instance is typically used to describe a complete database


environment, including the RDBMS software, table structure, stored procedures and
other functionality. It is most commonly used when administrators describe multiple
instances of the same database.

Definition: The information stored in database at the particular movement is called


instance. Also Known As: environment

Examples: An organization with an employee¶s database might have three different


instances: production (used to contain live data), pre-production (used to test new
functionality prior to release into production) and development (used by database
developers to create new functionality).

You might also like