SitePoint Sponsor

User Tag List

Results 1 to 12 of 12
  1. #1
    SitePoint Wizard
    Join Date
    May 2012
    Posts
    1,107
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Post what is mean by (cardnalty)

    Hi, I am confuse about this cardinality i found out that some of my table have 5 cardinality other table have 20..what does cardinality mean and is this important?

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,263
    Mentioned
    60 Post(s)
    Tagged
    3 Thread(s)
    Quote Originally Posted by jemz View Post
    i found out that some of my table have 5 cardinality other table have 20..
    where did you learn about this?

    i think all it means is the number of rows in the table
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  3. #3
    SitePoint Wizard
    Join Date
    May 2012
    Posts
    1,107
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by r937 View Post
    where did you learn about this?

    i think all it means is the number of rows in the table
    Hi r937, Okay so it mean by number of rows?..

  4. #4
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,263
    Mentioned
    60 Post(s)
    Tagged
    3 Thread(s)
    Quote Originally Posted by jemz View Post
    Hi r937, Okay so it mean by number of rows?..
    i'm not sure

    where did you learn about this?
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  5. #5
    SitePoint Wizard
    Join Date
    May 2012
    Posts
    1,107
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by r937 View Post
    i'm not sure

    where did you learn about this?
    Hi r937,I saw this in my wamp server,when i open my tables i and then click the structure of my table there i saw the cardinality...i am just curious about this..thank you so much for the reply.

  6. #6
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,263
    Mentioned
    60 Post(s)
    Tagged
    3 Thread(s)
    okay, just to check to make sure, run this for each table and tell me what you get --
    Code:
    SELECT COUNT(*) FROM table
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  7. #7
    SitePoint Wizard
    Join Date
    May 2012
    Posts
    1,107
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by r937 View Post
    okay, just to check to make sure, run this for each table and tell me what you get --
    Code:
    SELECT COUNT(*) FROM table
    it returns number of records 7

  8. #8
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,263
    Mentioned
    60 Post(s)
    Tagged
    3 Thread(s)
    that's weird

    could you do this for both tables please --
    Code:
    SHOW CREATE TABLE table
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  9. #9
    Keeper of the SFL StarLion's Avatar
    Join Date
    Feb 2006
    Location
    Atlanta, GA, USA
    Posts
    3,748
    Mentioned
    72 Post(s)
    Tagged
    0 Thread(s)
    The Cardinality of a column would be equal to the number of rows returned by SELECT DISTINCT `column1` FROM table1...

    how this would be calculated for a TABLE... i dont know. Because surely every row in your table has SOME uniqueness...
    Never grow up. The instant you do, you lose all ability to imagine great things, for fear of reality crashing in.

  10. #10
    SitePoint Wizard
    Join Date
    May 2012
    Posts
    1,107
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by r937 View Post
    that's weird

    could you do this for both tables please --
    Code:
    SHOW CREATE TABLE table
    Hi r937, this is the result of show create table
    CREATE TABLE `userref` ( `id` int(11) NOT NULL AUTO_INCREMENT, `First` varchar(20) NOT NULL, `Last` varchar(20) NOT NULL, `MI` varchar(1) NOT NULL, `Addss` varchar(50) NOT NULL, `phone` varchar(11) NOT NULL, `Email` varchar(30) NOT NULL, `Userident` varchar(20) NOT NULL, `Pass` varchar(200) NOT NULL, `Stat` varchar(1) NOT NULL, PRIMARY KEY (`id`)) ENGINE=MyISAM AUTO_INCREMENT=9 DEFAULT CHARSET=latin1


    i tried to select count(*) from userref
    it returns
    6
    it has 6 records.

  11. #11
    SitePoint Evangelist WebMachine's Avatar
    Join Date
    Jun 2007
    Location
    Ontario, Canada
    Posts
    411
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Stack Overflow has some good explanations of the different meanings of cardinality in databases ... http://stackoverflow.com/questions/1...y-in-databases .

    "When talking about database query optimization, cardinality refers to the data in a column of a table, specifically how many unique values are in it. This statistic helps with planning queries and optimizing the execution plans."

    or

    "When you are looking at query plans, cardinality refers to the number of rows that are expected to be returned from a particular operation."

    might be what you are looking for.

  12. #12
    SitePoint Wizard
    Join Date
    May 2012
    Posts
    1,107
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Thank you for the reply


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •