Results 1 to 5 of 5

Thread: Tables

  1. #1
    Join Date
    Oct 2005
    Posts
    7

    Unanswered: Tables

    Hi,

    I want to build some tables, with somthing weird for me. I was searching on psql manual and don't found nothing.

    Is it posible to have a tables inside a table on postgresql? What i want to do is to have a table (named users) a tables with user info, and inside this table in some point to all the cars this user could have. This cars are on other table outside user table. Users could own this cars, with posibiliies of some customization, i need to save this customs cars in somewhere. I wander if i could have a table inside user table, that will grow with any problem, or some other solution like that.

    I think others ways to do it, like table outside user table, a string with parsers, but now i want to do if this is possible.

    thanks for all.

  2. #2
    Join Date
    Feb 2005
    Location
    Colorado Springs
    Posts
    222
    The "traditional" way to do this is to have a table of users, a table of cars, and a 1:M linking table between them. If you want to include the cars within the users table, perhaps the Array Type in PostgreSQL could work.

  3. #3
    Join Date
    Oct 2005
    Posts
    7
    and a 1:M linking table between them
    Sorry, i can't understand that. could you explain it?

    Thanks for your answear.

  4. #4
    Join Date
    Feb 2005
    Location
    Colorado Springs
    Posts
    222
    I'll try to explain. Usually, a situation like yours is done with three tables. One contains information about each person. Another contains information about each car. A person can own more than one car, so a third table is needed to link the person to the cars he or she owns. Doing it this way, a person can own any number of cars. You asked about a table-within-a-table. This is usually not supported by database programs. However, PostgreSQL is a very powerful program and supports an Array type. Thus, you can store an array of informaiton in one column of a table. This is kind of like a table-within-a-table.

  5. #5
    Join Date
    Jun 2004
    Location
    Arizona, USA
    Posts
    1,848
    This sort of table is usually called an intersection table, and is the standard way to represent a many-to-many relationship in a relational database.
    Lou
    使大吃一惊
    "Lisa, in this house, we obey the laws of thermodynamics!" - Homer Simpson
    "I have my standards. They may be low, but I have them!" - Bette Middler
    "It's a book about a Spanish guy named Manual. You should read it." - Dilbert


Posting Permissions

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