Techie: Sabarinathan Arthanari

Let's make a better world

We know getting the selected text from a HTML page is a basic thing. But I think the code is not widely available. The JavaScript code below fetches the value anywhere in a page including textarea, input and text fields of the forms.


function GetSelectedText()
{
  var selectedText=(
        window.getSelection
        ?
            window.getSelection()
        :
            document.getSelection
            ?
                document.getSelection()
            :
                document.selection.createRange().text
     );
 if(!selectedText || selectedText=="")
 {
    if(document.activeElement.selectionStart)
    {
     selectedText = document.activeElement.value.substring(
          document.activeElement.selectionStart
          . document.activeElement.selectionEnd);
    }
 }
 return selectedText;
}

 

Here are the bonus bookmarklets for the dictionaries for English and Tamil.

//English Dictionary
javascript:var%20newfunc=function%20a(){q=window.getSelection?window.getSelection():document.getSelection?document.getSelection():document.selection.createRange().text;if(!q||q==""){if(document.activeElement.selectionStart){q= document.activeElement.value.substring(document.activeElement.selectionStart,document.activeElement.selectionEnd)}}if(!q||q=="")q=prompt("Enter%20term:");if(q!=null)window.open("http://www.wordreference.com/definition/"+q)}()

//English to Tamil
javascript:var%20newfunc=function%20a(){q=window.getSelection?window.getSelection():document.getSelection?document.getSelection():document.selection.createRange().text;if(!q||q==""){if(document.activeElement.selectionStart){q= document.activeElement.value.substring(document.activeElement.selectionStart,document.activeElement.selectionEnd)}}if(!q||q=="")q=prompt("Enter%20word:");if(q!=null)window.open('http://www.eudict.com/index.php?lang=engtam&word='+q)}()

 

//Tamil to English
javascript:var%20newfunc=function%20a(){q=window.getSelection?window.getSelection():document.getSelection?document.getSelection():document.selection.createRange().text;if(!q||q==""){if(document.activeElement.selectionStart){q= document.activeElement.value.substring(document.activeElement.selectionStart,document.activeElement.selectionEnd)}}if(!q||q=="")q=prompt('Enter%20word%20in%20Tamil:');if(q!=null)window.open('http://www.eudict.com/index.php?lang=tameng&word='+q)}()

Share

The following script helps to identify the recently modified objects in a database.

The SQL Server 2005 and onwards keeps the object information in sys.objects.

  1. Types holds the type of object. The type “S” means system objects.
  2. create_date column holds the object creation date and time
  3. modify_date column holds the last modified date and time

 

The following script fetches the objects modified or created for last 25 days

SELECT name, create_date, modify_date,type
    FROM sys.objects
    WHERE 
         type != ‘S’
        AND
         ( DATEDIFF(D,modify_date, GETDATE()) < 25) OR
         ( DATEDIFF(D,create_date, GETDATE()) < 25)
    ORDER BY  create_date, modify_date

Share

The serious of articles in this blog is focused to provide queries to optimize the SQL Server design quickly.

The Original tips mentioned in following pages

http://sqlserverpedia.com/blog/sql-server-bloggers/sql-server-%E2%80%93-stored-procedure-optimization-tips-%E2%80%93-best-practices/

 

IMPACT : Slows down execution

If a stored procedure name begins with “SP_,” then SQL server looks for a stored procedure beginning with "sp_" in the following order:
    MASTER system database
    use FQN (Fully Qualified Name) to locate the SP
    if FQN is not supplied, current database is used with dbo as owner

Searching in the master database causes extra overhead and even a wrong result if another stored procedure with the same name is found in master database.

 

MITIGATION OR RESCUE PLAN:


Rename the stored procedures

 

Query To Identify the Stored Procedures

Execute following Query in your SQL Server database to list the names of procedures those starts with sp_.

SELECT ROUTINE_NAME, ROUTINE_DEFINITION
    FROM INFORMATION_SCHEMA.ROUTINES
    WHERE ROUTINE_NAME LIKE ‘sp_%’
    AND ROUTINE_TYPE=’PROCEDURE’    

 

If Database diagrams enabled in database use may need to use following query

SELECT ROUTINE_NAME, ROUTINE_DEFINITION
    FROM INFORMATION_SCHEMA.ROUTINES
    WHERE ROUTINE_NAME LIKE ‘sp_%’ AND ROUTINE_NAME NOT LIKE ‘%diagram%’
    AND ROUTINE_TYPE=’PROCEDURE’      

Share

The serious of articles in this blog is focused to provide queries to optimize the SQL Server design quickly.

The Original tips mentioned in following pages

http://sqlserverpedia.com/blog/sql-server-bloggers/sql-server-%E2%80%93-stored-procedure-optimization-tips-%E2%80%93-best-practices/

 

IMPACT : Slows down execution

With every SELECT and DML statement, the SQL server returns a message that indicates the number of affected rows by that statement. This information is mostly helpful in debugging the code, but it is useless after that.

 

MITIGATION OR RESCUE PLAN:


For stored procedures that contain several statements or contain Transact-SQL loops, setting SET NOCOUNT to ON can provide a significant performance boost because network traffic is greatly reduced.

 

Query To Identify the Stored Procedures

Execute following Query in your SQL Server database to list the names of procedures those doesn’t include SET NOCOUNT commands.

SELECT ROUTINE_NAME, ROUTINE_DEFINITION
    FROM INFORMATION_SCHEMA.ROUTINES
    WHERE ROUTINE_DEFINITION not LIKE ‘%NOCOUNT%’
    AND ROUTINE_TYPE=’PROCEDURE’

Share

The primary purpose of a Parameterized View lets you retrieve PL/SQL record collection structures in a SQL context. As there is nothing like parameterized view in Oracle, but you can use parameterize view in oracle following ways

  1. You can use the User Environment variable to manage a session variable (dbms_application_info package),

  2. another way is write a package to get and set value parameterize view in the global variable or sys_context, later on a view can use the value from, which called so called parameterized view.

http://tamimdba.wordpress.com/2010/04/10/parameterized-view-in-oracle/

Other options to implement parameterized view are as below.

3. Table Function

A table function is a piece of procedural code that can produce a result which can be understood by the SQL engine — that is, a relation! A table function can have a parameter, so that the output relation depends on it. For all practical purposes it looks like a Parameterized view, and it is even called this in the SQL Server world.

http://www.dba-oracle.com/t_sql_patterns_table_function.htm

Since Oracle 8.0, it has been possible to select from a collection of data (usually loaded via a function) as a "virtual table". This technique became popular in the 8i timeframe thanks to Tom Kyte and numerous web forums where "SELECT FROM TABLE(CAST(plsql_function AS collection_type))" became a common technique for binding user-generated lists of data. However, as a technique for processing large volumes of data, "table functions" of this sort are limited due to their potentially large memory footprints.

http://www.oracle-developer.net/display.php?id=207

4. Pipelined functions in oracle 9i

In 9i Release 1 (9.0), Oracle has introduced pipelined table functions (known simply as pipelined functions). These build on the table function principle but with some critical differences, three of which stand out in particular:

  • first, data is piped (or streamed) to the caller in small arrays of prepared data, rather than fully materialised as with original table functions;

  • second, pipelined functions can be parallelised by Oracle which means that PL/SQL can be executed by multiple slaves for the first time; and

  • third, pipelined functions make it easy to convert PL/SQL procedures into rowsources for bulk SQL operations, combining complex transformation logic with the benefits of SQL.

This article introduces the fundamentals of pipelined functions, starting with a simple example.

http://www.oracle-developer.net/display.php?id=207

Cons of PL/SQL Table & Pipelined table functions

There’s a nightmare of strong opinion about the term PL/SQL Table because their more aptly called index-by or Associative Array collections. Unfortunately, it was Oracle’s documentation that gave the community the term. Its unfortunate that it stuck because it can be misleading. A PL/SQL Table isn’t a table in any sense of the word because it doesn’t have a SQL context. A PL/SQL table, index-by table, or Associative Array is a two-dimensional memory structure in the SGA, and it is accessible in a PL/SQL scope or through external programming languages that use the OCI8 libraries.

Pipelined table functions are slower than other approaches, but they are easy to implement. That’s why a number of folks use them. The alternative to a pipelined function is typically a complex query.

 

We selected the method of using Session Variables in Package method after the analysis of the following,

  1. Variables in Package are DB session proof & concurrent proof.

  2. The output will be direct SQL query result

  3. We can use it both in SQL and PL/SQL

Here is How to Unpersist Your Persistent PL/SQL Package Data

How do I declare session variables ?

You create a package level variable. This is a minimal example:

CREATE OR REPLACE PACKAGE my_package
AS
    FUNCTION get_a RETURN NUMBER;
END my_package;
/
CREATE OR REPLACE PACKAGE BODY my_package
AS
    a  NUMBER(20);
    FUNCTION get_a
    RETURN NUMBER
    IS
    BEGIN
      RETURN a;
    END get_a;
END my_package;
/

If you do this you should read up on (and handle correctly) ORA-04068 errors. Each database session will have it’s own value for a. You can try this with:

SELECT my_package.get_a FROM DUAL;

http://stackoverflow.com/questions/301369/pl-sql-how-do-i-declare-session-variables

The scope of a db-package variable is per database-session. So different forms-session or even different DB-session inside one forms-session will not "overwrite" each other.

http://forums.oracle.com/forums/thread.jspa?threadID=1043252&tstart=270

 
Connection pool and Sessions

http://stackoverflow.com/questions/1039637/relation-between-oracle-session-and-connection-pool

Please check

  • Web Applications and connection related challenges section
  • OCI Connection pool section

http://books.google.com/books?id=9MsOpXrElhUC&pg=PA529&lpg=PA529&dq=oracle%2B%22sessions%2Bvs%2Bconnections%22&source=bl&ots=mBwnWKBDQl&sig=XPkoqteZ%5FB%5FC8NT1tHh4rS4UKwI&hl=en&ei=s2BCSoKFHI3SMNbyvMAH&sa=X&oi=book%5Fresult&ct=result&resnum=1

PHP & Database Resident Connection Pooling

Oracle has several transaction monitor capabilities such as the fine-grained management of database sessions and connections. This is done by separating the notion of database sessions (user handles) from connections (server handles). Using these OCI calls for session switching and session migration, it is possible for an application server or transaction monitor to multiplex several sessions over fewer physical connections, thus achieving a high degree of scalability by pooling of connections and back-end Oracle server processes.

http://www.di.unipi.it/~ghelli/didattica/bdldoc/B19306_01/appdev.102/b14250/oci09adv.htm

http://php.net/manual/en/oci8.connection.php

DRCP is especially relevant for architectures with multi-process single threaded application servers (such as PHP/Apache) that cannot perform middle-tier connection pooling. The database can still scale to tens of thousands of simultaneous connections with DRCP.

http://download.oracle.com/docs/cd/B28359_01/server.111/b28310/manproc002.htm

 

Overview of User Processes

When a user runs an application program (such as a Pro*C program) or an Oracle tool (such as Enterprise Manager or SQL*Plus), Oracle creates a user process to run the user’s application.

Connections and Sessions

Connection and session are closely related to user process but are very different in meaning.

A connection is a communication pathway between a user process and an Oracle instance. A communication pathway is established using available interprocess communication mechanisms (on a computer that runs both the user process and Oracle) or network software (when different computers run the database application and Oracle, and communicate through a network).

A session is a specific connection of a user to an Oracle instance through a user process. For example, when a user starts SQL*Plus, the user must provide a valid user name and password, and then a session is established for that user. A session lasts from the time the user connects until the time the user disconnects or exits the database application.

Multiple sessions can be created and exist concurrently for a single Oracle user using the same user name. For example, a user with the user name/password of SCOTT/TIGER can connect to the same Oracle instance several times.

In configurations without the shared server, Oracle creates a server process on behalf of each user session. However, with the shared server, many user sessions can share a single server process.

http://download.oracle.com/docs/cd/B19306_01/server.102/b14220/process.htm#i19036

Server and Client Sessions

imageA server session manages the server side of client/server communications, providing shared resources, including a shared object cache and connection pools to a single data source.

A client session is a client-side communications mechanism that works together with the server session to provide the client/server connection. You acquire client sessions from a server session at run time as required. By default, a client session shares the session cache of its parent server session. Each client session serves one client. A client session communicates with the server session on behalf of the client application.

Each client session can have only one associated server session, but a server session can support any number of client sessions.

 

http://download.oracle.com/docs/cd/B25221_04/web.1013/b13593/sesun003.htm#i1123047

 

Share

I would like to share the interesting scenario faced with the junior system administrator(hardware guy). I hope that will help us to deal with similar characters in future. Here comes the true story.

 

Story : Eighth wonder

Part 1

Once up on a time[;)] I asked a system administrator in my office to connect the front panel headphone jack to motherboard. The guy tried to connect the cables even without switching off the system (the practice normally damages motherboard severely due to static electricity). Without checking whether actually jack was working or not he told me that the task had been completed. I tested the jack myself and found my front panel jack still wasn’t working and asked him to fix it.

t_pc642 i'm multi talentedFirst troubleshooting question he asked me was “Have you connected headphone to Red jack (mic) or green jack (speaker) ?”. As I was stunned (he knew that I had experience in IT) by the brilliant question, I replied him “green”.

He tried to solve the problem with some other combination, but was unable to do so. so he concluded “This motherboard doesn’t support analog speaker connectors.” and informed me !

 

attitude_2I was speechless for a moment and i thought that was eighth wonder in this world “Intel manufactured a motherboard which doesn’t support front panel connectors of their own cabinet”. :)

I googled for the right combination, found the solution and fixed it. Later he started shouting that I’m acting against the company policy.

The Moral of the Story… 

Never argue with a fool, onlookers may not be able to tell the difference.  ~Author unknown, attributed to Mark Twain

 

Part 2

As I was worried with his reply, I consulted with his boss regarding his attitude. Though he worries about his junior’s bad manners, I got the interesting reply as the reason for his junior’s technical skills

He is having only 3 years(?)  of experience. He is just a kid!!

 

 

Part 3

zxs527_125 Later I found that system admin tried to close the cabinet to avoid further queries and problems. But the thing he forgot to do is to fix the cover properly and it was wide open at the front.

But at that time i followed the quote of “Mark Twain” properly ;) . In some situations perception might be a problem ?

Share

In previous post we saw techniques to create collections on the fly to simulate the multi-value columns in Oracle. In this part we use simple PL/SQL function to aggregate individual collection values in to single field separated by value Delimiter.

Following function creates multi-valued string from the Oracle collection More info

FUNCTION To_String (
  Nt_in        IN Varchar2Table,
  Delimiter_in IN VARCHAR2 DEFAULT ‘,’
  ) RETURN VARCHAR2
IS
     v_idx PLS_INTEGER;
     v_str VARCHAR2(4000 BYTE);
     v_dlm VARCHAR2(10);
  BEGIN
     v_idx := nt_in.FIRST;
     WHILE v_idx IS NOT NULL LOOP
        v_str := v_str || v_dlm || nt_in(v_idx);
        v_dlm := delimiter_in;
        v_idx := nt_in.NEXT(v_idx);
     END LOOP;
     RETURN v_str;
  END To_String;

The above function helps developer to pass values to Business layer while migrating multi-value column to Oracle.

 

The following Query will first aggregate the rows in to collection table and convert to the multi-value column

SELECT migration.to_string( CAST( COLLECT( NAME ) AS Varchar2Table ) ) FROM EMPLOYEEADDRESS

Result

image 

 

Migrating Sub-Values to Oracle

Oracle supports ORDBMS concepts from version 8i which allows users to create user defined types and include them as column datatypes(Complex type in SQL developer).

Prior to Oracle 9i, collections could only be used to represent a single dimension of information (a list of names or salaries). With Oracle 9i and support for multi-level collections, PL/SQL developers can now model multi-dimensional phenomena. More info

In addition to sub-value enhancements, Oracle 10, 11 versions provides more advanced ORDBMS features.

[to be continued in ORDBMS series of Oracle]

Share

This article intends to identify technique to convert textarea HTML control to Editable Hyperlink Listbox efficiently.

 

Logic

This solution uses pure HTML and Javascript.

Step 1: Bind TextArea “Double Click” event to Javascript OpenLink() function.
Step 2: Get Caret/Cursor position with in the text area
Step 3: Extract current line from text area.
Step 4: Check for valid URL format and if necessary fix URL
Step 5: Open New window/Tab with selected URL.

Getting Caret/Cursor position

Code for getting Caret/Cursor position is based on the Mr. Alex implementation available in http://blog.vishalon.net/index.php/javascript-getting-and-setting-caret-position-in-textarea.

However bug fix to count 2 characters for the IE line termination(“\r\n”) is included in this code.

 

Getting Currently Selected Line

GetCurrentLine() function uses string search functions to identify the line termination characters related to cursor position with in the textarea and to extract the selected line.

 

Code

String.prototype.trim = function() {
    return this.replace(/^\s+|\s+$/g, “”);
}

 

function OpenLink(hyperLinkID) {
    var txtHyperLink = document.getElementById(hyperLinkID);

    //Step 2: Get Caret/Cursor position with in the text area
    var CaretPosition = GetCaretPosition(txtHyperLink);

    //Step 3: Extract current line text from text area.
    var line = GetCurrentLine(txtHyperLink.value, CaretPosition);

    //Step 4: Check for valid URL format and fix URL if necessary
    if (line) {
        line = line.trim();
        if (line.length > 0) {
            if (line.indexOf(‘://’) == -1) {
                line = “
http://” + line;
            }

            //Step 5: Open New window/Tab with selected URL.
            OpenHyperLink(line);
        }
    }
}

 

function GetCaretPosition(control) {
    var CaretPos = 0;
    // IE Support
    if (document.selection) {
        control.focus();
        var Sel = document.selection.createRange();
        var Sel2 = Sel.duplicate();
        Sel2.moveToElementText(control);
        var CaretPos = 0;
        var CharactersAdded = 1;
        while (Sel2.inRange(Sel)) {
            //old GetCaretPosition always counts 1 for linetermination
            //fixed
            if (Sel2.htmlText.substr(0, 2) == “\r\n”) {
                CaretPos += 2;
                CharactersAdded = 2;
            }
            else {
                CaretPos++;
                CharactersAdded = 1;
            }                   
            Sel2.moveStart(‘character’);
        }
        CaretPos -= CharactersAdded;
    }
    // Firefox support
    else if (control.selectionStart || control.selectionStart == ’0′)
        CaretPos = control.selectionStart;

    return (CaretPos);

}

 

function GetCurrentLine(Text, Position) {
    var lineTermination = “\n”; //Mozilla opera etc
    if (document.all) { // IE
        lineTermination = “\r\n”;
    }
    var lineTerminationLength = lineTermination.length;
    var startPosition = Position;
    //always search one character position back to avoid wrong calculations
    //when cursor position is at the end of the line
    if (Position > 0)
        Position–;

    var lineStart = Text.lastIndexOf(lineTermination, Position);
    //if cursor at first line or  new line and cursor at the beginning
    if (lineStart == -1 || (lineStart <= 0 && startPosition == 0))
        lineStart = 0;
    else
        lineStart = lineStart + lineTerminationLength;

    var lineEnd = Text.indexOf(lineTermination, lineStart);
    if (lineEnd == -1)
        lineEnd = Text.length;
    return Text.substring(lineStart, lineEnd);
}

 

function OpenHyperLink(line) {
    window.open(line);
}

 

Online Sample

 

Disclaimer

  1. All data and information provided on this page is for informational purposes only. Some parts of this tutorial are taken from the specified links and references. The mentioned writings belong to their corresponding authors.

  2. The opinions expressed herein are my own personal opinions and do not represent my employer’s view in any way.

Share

Oracle ORDBMS support for multivalue columns (Version 8 onwards)

Version 8.0 and higher versions of Oracle are referred to as ORDBMS (Object-Relational Database Management System). The traditional Oracle database management system is extended to include Object-Oriented Concepts and structures such as abstract data types, nested tables, varying arrays, object views and references.

MultiValue columns through Collections feature of Oracle 8

“A collection is an ordered group of elements, all of the same type. It is a general concept that encompasses lists, arrays, and other familiar datatypes. Each element has a unique subscript that determines its position in the collection.

Oracle Offers following persistent collections

· Nested tables hold an arbitrary number of elements. They use sequential numbers as subscripts. You can define equivalent SQL types, allowing nested tables to be stored in database tables and manipulated through SQL.

· Varrays (short for variable-size arrays) hold a fixed number of elements (although you can change the number of elements at runtime). They use sequential numbers as subscripts. You can define equivalent SQL types, allowing varrays to be stored in database tables. They can be stored and retrieved through SQL, but with less flexibility than nested tables.

PL/SQL provides following additional non-persistent collection (cannot be stored in database tables)

Index-by tables, also known as associative arrays, let you look up elements using arbitrary numbers and strings for subscript values. (They are similar to hash tables in other programming languages.)

Example 1: Table with collection column type

1. SQL to Create a string collection

create or replace
TYPE Varchar2Table IS TABLE OF VARCHAR2(4000 BYTE);

2. Using Collection as a column in a table

CREATE TABLE BOOK
(
ID ROWID NOT NULL
, NAME VARCHAR2(200 CHAR) NOT NULL
, CONTENTS SABARI.VARCHAR2TABLE
, CONSTRAINT BOOK_PK PRIMARY KEY
(
ID
)
ENABLE
)
NESTED TABLE CONTENTS STORE AS BOOK_CONTENTS RETURN AS VALUE;

ALTER TABLE BOOK
ADD CONSTRAINT BOOK_UK_NAME UNIQUE
(
NAME
)
ENABLE;

The above statement creates 2 table with named “BOOK” and “BOOK_CONTENTS” !

So whenever we store contents to Book table, book lines will be inserted to the “BOOK_CONTENTS” table.

Inserting rows in to collections

INSERT INTO BOOK(ID,NAME, CONTENTS) VALUES  (1 , ‘Book1′, Varchar2Table(‘line1′, ‘line2′, ‘line3′, ‘line4′));

Query table

SELECT * FROM BOOK

image

Example 2: Creating Collections on the fly

Oracle 10g has introduced an extremely useful new group function, COLLECT. This function enables us to aggregate data into a collection, retaining multiple records of data within a single row (like a nested table). One of the main benefits of this function is that it makes “string aggregation” (one of the web’s most-requested Oracle technique) very simple.

So by using this feature we can manipulate multivalue column views even from normal RDBMS columns.

Example

SELECT CAST( COLLECT( NAME ) AS Varchar2Table ) FROM BOOK

  • The statement is simple NAME is Varchar2 data type.
  • The COLLECT function collects values in different rows in to collection.
  • CAST function casts the return values to be accessible by user defined Varchar2Table data type.

[To be Continued..]

References

http://sheikyerbouti.developpez.com/collections/collections.htm

http://www.oracle-developer.net/display.php?id=306

Disclaimer

  1. All data and information provided on this page is for informational purposes only. Some parts of this tutorial are taken from the specified links and references. The mentioned writings belong to their corresponding authors.
  2. The opinions expressed herein are my own personal opinions and do not represent my employer’s view in any way.

Share

Why do we need to Migrate ?

Multivalue databases have an edge over Relational databases with respect to many features and applications, but still there are some limitations of using this data model which limit its use in some cases .or relatively simple application, say for example “project reporting by state and fiscal”, hierarchical representation happens to be convenient; no consideration is given to other applications, which it likely complicates.  Multivalue was not “first considered in the original theories and mathematics surrounding relational database rules.”

Data Integrity

The relational model was invented explicitly to replace hierarchical technology, of which Multivalue is one version, the latter having nothing to do with mathematics. Moreover there is no reference to integrity constraints. The focus is only on some certain types of applications, and integrity of the data is still a question., the flexibility which it provides means that integrity control generally has to be done at the application level rather than the DBMS level.

Physical Concept Vs Logical Concept

The Multivalue approach has been around forever and Mr. Codd declared it to be in violation of relational principles years ago. It is neither new, nor a replacement of Relational Model, nor a solution to anything. And if the “solution” is physical, then it has nothing to do with the data model, or repeating groups. Normalization is purely a logical concept, so it has nothing to do anything at physical, repeating groups are logical too and a violation of relational principles. It is technology that does not replace relational – it is a formal model that sits between the logical R level and the physical level, based on theory.

There is no such thing as “naturally occurring repeating groups”—it’s a matter of representation and we can choose to represent it with repeating groups, or relationally, without. The former was tried and failed, the latter has not yet been tried properly but even so, it’s much better.

So If an application requires large amount of arithmetic and real time database calculations or application model requires data integrity to be maintained in database layer, RDBMS model is more preferred.

Representing Multi-value columns in RDBMS Data model

We can use First Normal Form to normalize the multi value columns. For example in our example (as mentioned in part 1) we can use the multiplicity notation in UML to show that a contact may have more than one hobby:

hobbies-uml2

As you should expect by now, we can’t represent the multivalued attribute directly in the Contacts relation scheme. Instead, we will remove the old hobbies attribute and create a new scheme, very similar to the one that we created for the phone numbers.

hobbies-scheme

• The relationship between Contacts and Hobbies is one-to-many, so we create the usual pk-fk pair. The new scheme has only one descriptive attribute, the hobby name. To uniquely identify each row of the table, we need to know both which contact this hobby belongs to and which hobby it is—so both attributes form the pk of the scheme.

[To be Continued..]

References

www.csjournals.com/IJITKM/PDF1-2/28_Meghna_Ruchi.pdf

http://www.tomjewett.com/dbdesign/dbdesign.php?page=hobbies.php

Disclaimer

  1. All data and information provided on this page is for informational purposes only. The writings belong to their corresponding authors as mentioned in links and references. The information in this weblog is provided “AS IS” and confers no rights.
  2. The opinions expressed herein are my own personal opinions and do not represent my employer’s view in any way.

Share