How do you determine the base table?
My question is in relation to database theory.
If I am given a set of tables, is there a way to determ开发者_运维技巧ine the base table just by looking at them?
It is a tenet of the relational model that there is no unnecessary distinction between a Base Table (Base Relation) and a Derived one (aka virtual relation or "view"). Both types have attributes, keys and all the other features you would expect of relations and both can be used in just the same ways. As a practical matter of implementation it is necessary that the DBMS software provide some means to differentiate them but logically speaking they are the same.
The principle that base and derived relations are similar in this way is sometimes called the Principle of Interchangeability.
Actually, I'm surprised there is so much puzzlement here about your question and surprised that your question is downvoted. Base table / relation is a very common term in relational database theory and in the SQL standard. Your question seems perfectly concise and in order to me.
Disclaimer: I never heard of a "base table" before now
After some googling, the only instances where anyone is talking about "Base Tables", seems to be when describing the physical tables a view depends on.
Based on that, I would say all tables are base tables, with the possible exception of temporary tables.
According to IBM here a base table is what most would understand as "a database table", in other words the actual table itself.
But I have to say your question is a bit "quantum theory"-like - if taken literally "by just looking at them"... sorry I had to laugh because I found myself getting a headache over that one.
If I assume you meant "just by querying them" then you would have to already know the table name to write your query. Again all a bit chicken and egg.
Maybe you want to know if there is a table that contains a list of all database tables? That rather depends on the database system you are working with, and sometimes what applications. Take SAP for example. It might use an Oracle database system, and it creates a database table that contains a list of all SAP generated tables. You could think of that as the base table in the sense that it goes no further than itself.
I just thought of something else a bit cosmic: if you are implying that there must have been at least one database table at the beginning of the installation of database system, and that's what you refer to as the "base" table that you're looking for, I know of no way to determine that as a general theoretical proposition. There are going to be better people out there than me to answer that one...
...or maybe not.
If by base table you are talking about inheriting from a table, then yes you can by uniting common table fields in the base table.
For example: Base table: User(name) Tables using inheritance of the table User: Administrator, Member, etc.
But don't get confused by this inheritance, it only copies the fields, nothing else, it is not Oriented-Object stuffs.
I am assuming that you mean tell a regular table from a view.
It depends on what you mean by, "looking at them".
If you mean just looking at the data then no.
If you mean looking at a script that creates the table then yes. Also, if you mean by browsing through something like SQL Server Management Studio then again yes, because they break tables and views into different folders.
精彩评论