|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Saturday, December 29, 2012 1:58 AM
Points: 5,
Visits: 8
|
|
Thanks alot. How about polymorphism in sql? Could we use stored procedures for polymorphism? And for nested relationships can we define an attribute as OId and use it in a select query to point to the table that we want use it in our nested relationship?
|
|
|
|
|
SSCrazy Eights
        
Group: General Forum Members
Last Login: Yesterday @ 3:32 PM
Points: 8,980,
Visits: 8,540
|
|
|
|
|
|
SSCertifiable
       
Group: General Forum Members
Last Login: Yesterday @ 1:07 PM
Points: 6,826,
Visits: 11,951
|
|
tz.bahrami (12/27/2012) Thanks alot. How about polymorphism in sql? Could we use stored procedures for polymorphism? And for nested relationships can we define an attribute as OId and use it in a select query to point to the table that we want use it in our nested relationship?
It depends on what you mean by that and how you want to class your entities. In the context of a database you could contrive a qualifying description of polymorphism, but in general, no. Relational database theory is built on the notion of a relation (manifested as a table in an RDBMS) representing a specific entity, and only one. In other words you would not store cars and trees in the same table even though they both inherit from 'System.Object' (drawing on .NET object hierarchy). You might store different models of cars or species of trees where car inherits from vehicle and tree inherits from plant. Or you might want a vehicle table with properties common to cars, trucks, airplanes, etc. with child tables for each of those I mentioned. It depends on how granular you want to get.
For example say you had a table that stored types of trees (named tree) and in that table you wanted to store a deciduous tree and an evergreen. You might have a column named 'max_recorded_height' and another named 'average_life_expectancy.' However, you may not want a column called 'average_needle_length' because deciduous trees do not have needles, only evergreens do. So, you may want to create a child table to tree called evergreen that would only be referred to by objects of type evergreen (who inherit from your tree object) that was instantiated within your application so it could fill those properties that only pertained to evergreens. That said, you would still look into having those properties normalized out of the tree table since not all trees will have needles.
I would suggest you do some reading on normalization, especially normal forms, start with 3NF, and read the article about the impedance mismatch I linked to above.
__________________________________________________________________________________________________ There are no special teachers of virtue, because virtue is taught by the whole community. --Plato
Believe you can and you're halfway there. --Theodore Roosevelt
Everything Should Be Made as Simple as Possible, But Not Simpler --Albert Einstein
The significant problems we face cannot be solved at the same level of thinking we were at when we created them. --Albert Einstein
1 apple is not exactly 1/8 of 8 apples. Because there are no absolutely identical apples. --Giordy
|
|
|
|
|
SSC-Dedicated
           
Group: General Forum Members
Last Login: Today @ 5:14 AM
Points: 38,118,
Visits: 30,403
|
|
tz.bahrami (12/27/2012) How about polymorphism in sql? Could we use stored procedures for polymorphism? And for nested relationships can we define an attribute as OId and use it in a select query to point to the table that we want use it in our nested relationship?
Once again... SQL Server is not an object database. T-SQL is not an object orientated language.
While you may be able to force some OO-like features into a DB, you're very likely going to end up with a poor design and a badly performing database as a result. Keep the OO in the front end, where your language is OO and not in the database.
Gail Shaw Microsoft Certified Master: SQL Server 2008, MVP SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
We walk in the dark places no others will enter We stand on the bridge and no one may pass
|
|
|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Saturday, December 29, 2012 1:58 AM
Points: 5,
Visits: 8
|
|
Thanks alot of your instructions.i find my answer.
|
|
|
|
|
SSCoach
         
Group: General Forum Members
Last Login: Monday, June 17, 2013 1:45 PM
Points: 15,442,
Visits: 9,572
|
|
There are object-oriented database engines available. Cache is one of them, for example. They have the OO properties that you are looking for. If you absolutely have to have polymorphism in a database, go with an OODBMS (Bing/Google that term if you don't know it), not with an RDBMS.
It is theoretically possible to do inheritence and polymorphism in an RDBMS. But you can't attach methods to an object, and columns aren't really properties. OODBMSs allow you to do proper inheritence, polymophism, properties, and methods. That's what they're for. They tend to be less effective at the things RDBMSs are good at, like data analysis and reporting, data mining, set-based queries, and so on. But they are good for OO data storage.
- Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC Property of The Thread
"Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon
|
|
|
|