Hi,
I have two tables: Code and Color.
The create command for them is :
create table Color(
Partnum varchar(10),
Eng_Color char(10),
Span_Color char(20),
Frch_Color char(20),
CONSTRAINT pkPartnum PRIMARY KEY(Partnum)
)
create table Code
(
Partnum varchar(10),
Barcode varchar(11),
I2of5s varchar(13),
I2of5m varchar(13),
UPC varchar(11),
BigboxBCode varchar(11),
DrumBCode varchar(11),
TrayBCode varchar(11),
QtyBCode varchar(11),
CONSTRAINT fkPartnum FOREIGN KEY(Partnum) references Color(Partnum)
)
Now my question is,
how can i give a select statement such that I can get all the fields as
output.
Also plz note that the above is a sample. I have another 9 tables and I
need a solution
such that on being refered by Partnum, I can get all the attributes.
Thanks
Feb 14 '06
19 2944
Shwetabh (sh**********@g mail.com) writes: I understand what you are saying. But consider this scenario: A user needs a few more fields in the database and adds them to a table kept for the purpose. Now how can _those_ fields be accessed without using select *?
Changing the schema in a database is usually not something you do out of a
whim, and normally by a DBA, and not just any user.
And if a new field is added - how can you know off-hand that it is of
interest to you?
--
Erland Sommarskog, SQL Server MVP, es****@sommarsk og.se
Books Online for SQL Server 2005 at http://www.microsoft.com/technet/pro...ads/books.mspx
Books Online for SQL Server 2000 at http://www.microsoft.com/sql/prodinf...ons/books.mspx
Erland Sommarskog wrote: Shwetabh (sh**********@g mail.com) writes: I understand what you are saying. But consider this scenario: A user needs a few more fields in the database and adds them to a table kept for the purpose. Now how can _those_ fields be accessed without using select *?
Changing the schema in a database is usually not something you do out of a whim, and normally by a DBA, and not just any user.
And if a new field is added - how can you know off-hand that it is of interest to you?
-- Erland Sommarskog, SQL Server MVP, es****@sommarsk og.se
Books Online for SQL Server 2005 at http://www.microsoft.com/technet/pro...ads/books.mspx Books Online for SQL Server 2000 at http://www.microsoft.com/sql/prodinf...ons/books.mspx
Well, apparently, since the dataabse will be used for Label printing,
the DBA has to
change the schema by adding new fields according to the requirements.
Do you suggest instead of normalising the database I should create a
single table
which holds all the fields which will be used for label? Or is thr some
better way out.
Now, since I am converting legacy database, it should be possible to
add data to the table through a single query which I cannot really
foresee happening in a normalised database.
What do u suggest?
On 15 Feb 2006 20:43:49 -0800, Shwetabh wrote: Why would it be necessary to use SELECT * in such a scenario? SELECT * is slow because it requires extra work by the server to retrieve the column metadata. It's unreliable because more code may break if and when the table structure changes. It's hard to maintain because you can't easily search for column dependencies in your code during development.
(snip) I understand what you are saying. But consider this scenario: A user needs a few more fields in the database and adds them to a table kept for the purpose. Now how can _those_ fields be accessed without using select *?
Hi Shwetabh,
Easy.
In the parts of the application that have to use the new column, you can
add it to the column list in the SELECT statement at the same time
you're making the change to use the column.
And in the parts of the application that don't have to use the new
column, you don't have to change anything.
--
Hugo Kornelis, SQL Server MVP
Shwetabh (sh**********@g mail.com) writes: Well, apparently, since the dataabse will be used for Label printing, the DBA has to change the schema by adding new fields according to the requirements. Do you suggest instead of normalising the database I should create a single table which holds all the fields which will be used for label? Or is thr some better way out. Now, since I am converting legacy database, it should be possible to add data to the table through a single query which I cannot really foresee happening in a normalised database. What do u suggest?
Since I don't have the full story, but just some selected bits and pieces,
maybe I should not suggest anything.
Generally, SELECT * is bad. You talk about converting a legacy database,
but I don't know if that database is even SQL Server. And how your
question about relational database fits into this, I don't really see.
If you could give a more complete picture of what you are up to, it
might be easier to give better advice.
--
Erland Sommarskog, SQL Server MVP, es****@sommarsk og.se
Books Online for SQL Server 2005 at http://www.microsoft.com/technet/pro...ads/books.mspx
Books Online for SQL Server 2000 at http://www.microsoft.com/sql/prodinf...ons/books.mspx
Erland Sommarskog wrote: Shwetabh (sh**********@g mail.com) writes: Well, apparently, since the dataabse will be used for Label printing, the DBA has to change the schema by adding new fields according to the requirements. Do you suggest instead of normalising the database I should create a single table which holds all the fields which will be used for label? Or is thr some better way out. Now, since I am converting legacy database, it should be possible to add data to the table through a single query which I cannot really foresee happening in a normalised database. What do u suggest?
Since I don't have the full story, but just some selected bits and pieces, maybe I should not suggest anything.
Generally, SELECT * is bad. You talk about converting a legacy database, but I don't know if that database is even SQL Server. And how your question about relational database fits into this, I don't really see.
If you could give a more complete picture of what you are up to, it might be easier to give better advice.
-- Erland Sommarskog, SQL Server MVP, es****@sommarsk og.se
Books Online for SQL Server 2005 at http://www.microsoft.com/technet/pro...ads/books.mspx Books Online for SQL Server 2000 at http://www.microsoft.com/sql/prodinf...ons/books.mspx
Ok,here are the details:
I am supposed to convert DBASE IV data to MS SQL server 2000 database.
Now, there are about 40 DBASE tables each of which contains fields
ranging
from 3 to 30. Most of the fields hold either NULL values or redundant
data. In all these tables and fields, there is only one common field
"Partnum".
Now earlier, this DBASE database was used by a labelling software
"Easylabel" . It used to
retrieve the neccessary data using the field "Partnum". This software
will connect to
SQL server and retrieve the data when conversion process is complete.
Now my dillema is that should I just create a database containing all
the fields in a single
table or should I try to create relationships among different data
objects. If I put them in a single table, will the system take a
performance hit when accessing data?
If I create relationships, how can I retrieve the data from tables
where information about new fields added by users without using select
*..?
I hope I made myself clear. If any doubts, plz let me know.
Shwetabh (sh**********@g mail.com) writes: I am supposed to convert DBASE IV data to MS SQL server 2000 database. Now, there are about 40 DBASE tables each of which contains fields ranging from 3 to 30. Most of the fields hold either NULL values or redundant data. In all these tables and fields, there is only one common field "Partnum". Now earlier, this DBASE database was used by a labelling software "Easylabel" . It used to retrieve the neccessary data using the field "Partnum". This software will connect to SQL server and retrieve the data when conversion process is complete.
Now my dillema is that should I just create a database containing all the fields in a single table or should I try to create relationships among different data objects. If I put them in a single table, will the system take a performance hit when accessing data? If I create relationships, how can I retrieve the data from tables where information about new fields added by users without using select *..?
So you are saying that the application will largely be unchanged, only
the database will change? That puts quite some restriction on the work.
It would of course be nicer to work with a clean sheet and do it right.
Since I don't know the application, it is difficult to say "do this"
or "do that". But I think that you design a solution with maintainability
and extensibilty foremost in mind. I don't think one single table is
the answer to that aim. But, again, I don't know the business domain.
As for performance, what data volumes are we talking about?
--
Erland Sommarskog, SQL Server MVP, es****@sommarsk og.se
Books Online for SQL Server 2005 at http://www.microsoft.com/technet/pro...ads/books.mspx
Books Online for SQL Server 2000 at http://www.microsoft.com/sql/prodinf...ons/books.mspx
Erland Sommarskog wrote: Shwetabh (sh**********@g mail.com) writes: I am supposed to convert DBASE IV data to MS SQL server 2000 database. Now, there are about 40 DBASE tables each of which contains fields ranging from 3 to 30. Most of the fields hold either NULL values or redundant data. In all these tables and fields, there is only one common field "Partnum". Now earlier, this DBASE database was used by a labelling software "Easylabel" . It used to retrieve the neccessary data using the field "Partnum". This software will connect to SQL server and retrieve the data when conversion process is complete.
Now my dillema is that should I just create a database containing all the fields in a single table or should I try to create relationships among different data objects. If I put them in a single table, will the system take a performance hit when accessing data? If I create relationships, how can I retrieve the data from tables where information about new fields added by users without using select *..?
So you are saying that the application will largely be unchanged, only the database will change? That puts quite some restriction on the work. It would of course be nicer to work with a clean sheet and do it right.
Since I don't know the application, it is difficult to say "do this" or "do that". But I think that you design a solution with maintainability and extensibilty foremost in mind. I don't think one single table is the answer to that aim. But, again, I don't know the business domain.
As for performance, what data volumes are we talking about?
-- Erland Sommarskog, SQL Server MVP, es****@sommarsk og.se
Books Online for SQL Server 2005 at http://www.microsoft.com/technet/pro...ads/books.mspx Books Online for SQL Server 2000 at http://www.microsoft.com/sql/prodinf...ons/books.mspx
I am working on a software to manage the labelling database. The DBASE
IV database tables are to be converted to MS SQL server database. Each
table consists of around 45 to 60 records.There is only one field which
is common in all tables and is unique. I will be using that field as
the primary key. Would I be wrong if I create a database in SQL and add
all DBASE IV tables according to the names of the files they are stored
in?
I can send you the sample database if needed.
As for extensibility, since the database will be stored in seperate
tables in SQL server database, I think there should be no problem. Am I
correct in my assumption?
Awaiting your replies,
Thanks
Shwetabh wrote: I am working on a software to manage the labelling database. The DBASE IV database tables are to be converted to MS SQL server database. Each table consists of around 45 to 60 records.There is only one field which is common in all tables and is unique. I will be using that field as the primary key. Would I be wrong if I create a database in SQL and add all DBASE IV tables according to the names of the files they are stored in? I can send you the sample database if needed.
As for extensibility, since the database will be stored in seperate tables in SQL server database, I think there should be no problem. Am I correct in my assumption? Awaiting your replies, Thanks
You don't need to worry about performance. The database schema alone
isn't going to make a measurable difference to performance if your
tables average just 45-60 rows. Not unless they are likely to grow 100s
or 1000s of times bigger in the lifetime of the system.
Design a schema that will preserve data integrity and be easy to
maintain in future. Usually that means the schema should be fully
normalized but if this is just a one-off, low-value project you may
prefer to mimic the existing structure in SQL in order to minimise
changes to the application.
--
David Portas, SQL Server MVP
Whenever possible please post enough code to reproduce your problem.
Including CREATE TABLE and INSERT statements usually helps.
State what version of SQL Server you are using and specify the content
of any error messages.
SQL Server Books Online: http://msdn2.microsoft.com/library/m...S,SQL.90).aspx
--
Shwetabh (sh**********@g mail.com) writes: I am working on a software to manage the labelling database. The DBASE IV database tables are to be converted to MS SQL server database. Each table consists of around 45 to 60 records.There is only one field which is common in all tables and is unique. I will be using that field as the primary key. Would I be wrong if I create a database in SQL and add all DBASE IV tables according to the names of the files they are stored in? I can send you the sample database if needed.
As for extensibility, since the database will be stored in seperate tables in SQL server database, I think there should be no problem. Am I correct in my assumption?
As David said, with those volumes there is no reason to consider a "smart"
design for performance. As I said, focus on maintainability and
extensibility. And ease of development. That may be a single-table
design, but most likely it's a more normalised design.
--
Erland Sommarskog, SQL Server MVP, es****@sommarsk og.se
Books Online for SQL Server 2005 at http://www.microsoft.com/technet/pro...ads/books.mspx
Books Online for SQL Server 2000 at http://www.microsoft.com/sql/prodinf...ons/books.mspx
as a place to start, create a sql table for every dbf file. copy the
column names verbatim.
then use the import function to import the data.
no matter WHAT you eventually end up with, you will have to do this to
get all the data in.
from there, you will have learned a lot, and will think of ways to
change the app to make it better.
but, to get all the data in, you have to do the first step. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Rowland Hills |
last post by:
I have a table which is returning inconsistent results when I query
it!
In query analyzer:
If I do "SELECT * FROM TABLE_NAME" I get no rows returned.
If I do "SELECT COL1, COL2 FROM TABLE_NAME" I get 4 rows returned.
In Enterprise manager:
|
by: avinash |
last post by:
hi myself avi
i am developing one appliacaion in which i am using vb 6 as front end,
adodb as database library and sql sever 7 as backend.
i want to update one table for which i required data from other table. and
iretrive data from second table by giving some condition. when i get data,
then to update first table i need to use do while loop. instead of that i
want to use select statement directly in update query.
plz give me some help....
|
by: syounger |
last post by:
Hi. I have a report in Access 2000 that is based on selection made
from a series of interdependent list boxes. The boxes I have right now
are Source, Table, Column, Date. The user chooses Source first, then
the Table list box populates only tables from that source. Once a
table is chosen, only the columns for that table appear in the Column
list box. In the date box, the only dates that appear are those that
are stored against the...
|
by: Harry V |
last post by:
I'm wondering if there is a limit of a single select, delete and insert statement (command) to each dataadapter? On a form, I have a dataconnection that is shared by 3 dataadapters, one for each of three tables in an Access database. Each was created in the form designer and each has a datatable that was generated in the designer. I have no problem filling the datatables and inserting the rows into the Access tables. I DO need to select the...
|
by: Ahmet Karaca |
last post by:
Hi.
myds.Reset();
mycommand.SelectCommand.CommandText=
"Select att1 from Ing as Ingredient, Pro as Product "+
"where Pro.ad='apple' and Pro.id=Ing.id";
mycommand.Fill(myds, "Product"); // Here is the problem
listbox.DataSource = myds.Tables.DefaultView; // Here again
listbox.DataTextField = "invid"; // Here again
listbox.DataBind();
mycon.Close()
| |
by: Joe via DotNetMonster.com |
last post by:
Hi,
I'm trying to use several select statements so that I don't need to call
the function several times. The next Result set always seems to read the
first select statement. I have the following:
Dim queryString As String = "SELECT TOP 1 (.), .
FROM WHERE (. = @LessonID) AND
.='Motivate'; SELECT TOP 1 (.), .
|
by: Diffident |
last post by:
Hello All,
I am trying to filter rows in a datatable based on filtercriteria and
sortcriteria using the datatable.select() method.
I am encountering a strange behavior in this process. Here is what I am
trying to do...
---------
|
by: Ed L. |
last post by:
I think I'm seeing table-level lock contention in the following function
when I have many different concurrent callers, each with mutually distinct
values for $1. Is there a way to reimplement this function using
select-for-update (or equivalent) in order to get a row-level lock (and
thus less contention) while maintaining the function interface? The docs
seem to suggest so, but it's not clear how to return the SETOF queued_item
and also...
|
by: lasithf |
last post by:
Hi,
I am looking for a way to get multiple sql retrievals from SQL*PLUS.
here is the scenario:
I am going to execute following sql query:
select * from table1;select* from table2;select* from table3
Invalid character (for the ;) is throwing from the SQL*PLUS.
but I can run this command through an SQL Server 2000, or DB2 database. There, this command is valid and I can have a dataset with two tables.
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |