Hi Guys,
I've been thinking about a normalised schema for a folksonomy syetem for my site. I'm fairly sure this is a good way to do things, but I have a coupld of questions...
firstly, here's a quick low down on planned schema:
Users
user_id
etc.
Items
item_id
item_desc
etc.
Tags
tag_id
tag_text
ItemTags
tag_id
user_id
item_id
Okay, now here's the thing. Obviously this is quite a normalised schema. I can retrieve all of an item's / user's tags easily. What I'd need to be able to do is return the list of tags and count for each item (perhaps just an item at a time).
I can't really see any problems with this right now. But what happens if I have millions or Billions of rows. What's the proper way to retrieve tag counts for a huuuge set of data.
I don't neceserrily need to implement something, but I'd quite like to know how one would get around the performance aspect of such a huge table. Ideas are welcomed greatly..
Thanks.
i have a database and i want to add tagging. So far i have a city, state, ad, and user database. I want ppl to be able to tag there ads but i have no idea how to do it database wise. and advice
My question takes two parts; firstly, is the new table that I'm proposing going to handle the business logic I describe below, and secondly, if I put the new table in, how in hell do I use it?
Right; present schema attached.
The idea, which I hope is fairly clear from the schema, is that you send it a buch of parameters about the event, admission date, etc, and it will return all tickets matching those parameters. An example stored proc for this is below:
CREATE PROCEDURE [dbo].[getSingleTicketsByParameters] @eventIdINT, @standIdINT, @admissionDateIdINT, @bookingDateIdINT, @concessionIdINT, @bookingMinQuantityIdINT, @bookingMaxQuantityIdINT, @membershipIdINT AS SET NOCOUNT ON SELECT [tblTickets].[id], [tblTickets].[booking_date_id], [tblTickets].[booking_min_quantity_id], [tblTickets].[booking_max_quantity_id], [tblTickets].[ticket_concession_id], [tblTickets].[membership_id], [tblTickets].[event_id], [tblTickets].[stand_id], [tblTickets].[admission_date_id], [tblTickets].[price], [tblTickets].[availability], [tblTickets].[description], [tblTickets].[admin_description], [tblTickets].[ticket_open], [tblTickets].[ticket_live], [tblEvents].[event_name], [tblEvents].[event_open], [tblStands].[stand_name], [tblStands].[stand_open], [tblBookingDates].[booking_start_date], [tblBookingDates].[booking_end_date], [tblTicketConcessions].[concession_name], [tblBookingMinQuantities].[booking_quantity], [tblBookingMaxQuantities].[booking_quantity], [tblAdmissionDates].[description], [tblAdmissionDates].[admission_start_date], [tblAdmissionDates].[admission_end_date], [tblAdmissionDates].[date_open], [tblMemberships].[membership_name] FROM [tblTickets] LEFT JOIN [tblEvents] ON [tblEvents].[id] = [tblTickets].[event_id] LEFT JOIN [tblStands] ON [tblStands].[id] = [tblTickets].[stand_id] LEFT JOIN [tblBookingDates] ON [tblBookingDates].[id] = [tblTickets].[booking_date_id] LEFT JOIN [tblTicketConcessions] ON [tblTicketConcessions].[id] = [tblTickets].[ticket_concession_id] LEFT JOIN [tblBookingQuantities] AS tblBookingMinQuantities ON [tblBookingMinQuantities].[id] = [tblTickets].[booking_min_quantity_id] LEFT JOIN [tblBookingQuantities] AS tblBookingMaxQuantities ON [tblBookingMaxQuantities].[id] = [tblTickets].[booking_max_quantity_id] LEFT JOIN [tblAdmissionDates] ON [tblAdmissionDates].[id] = [tblTickets].[admission_date_id] LEFT JOIN [tblMemberships] ON [tblMemberships].[id] = [tblTickets].[membership_id] WHERE 1=1 AND ([tblEvents].[id]=@eventId OR @eventId=0) AND ([tblStands].[id]=@standId OR @standId=0) AND ([tblTicketConcessions].[id]=@concessionId OR @concessionId=0) AND ([tblAdmissionDates].[id]=@admissionDateId OR @admissionDateId=0) AND ([tblBookingDates].[id]=@bookingDateId OR @bookingDateId=0) AND ([tblBookingMinQuantities].[id]=@bookingMinQuantityId OR @bookingMinQuantityId=0) AND ([tblBookingMaxQuantities].[id]=@bookingMaxQuantityId OR @bookingMaxQuantityId=0) AND ([tblMemberships].[id]=@membershipId OR @membershipId=0) GO
So. It's all about to get horribly, horribly complex (well, it is to me) so take a deep breath.
Tickets are subject to quotas. However, quotas are subject to... well, at the moment they can be based on event, stand, admission date, concession, or any combination of these. They can also be based on an individual ticket. All quotas, however, are annual; they only apply to ticket purchases in the same year. For example: - you can't buy more than 4 tickets for date A, in stand B at event C, per year. - you can't buy more than 2 tickets for stand D per year. - you can't buy more than 4 of ticket number 123.
Now, I'm thinking that all I need to manage this is one table, and it's going to look a little like this:
tblQuotas id INT PK ticket_id INT FK event_id INT FK stand_id INT FK admission_date_id INT FK quota INT
So, if I put a record in there with an event, stand and admission date - and a quota - then I've met the first business rule that I described above. If I put in a record with just a stand id and a quota, then I've met the second sort. If I put in one with just a ticket id and a quota, then I've met the third.
Now we return to that big SQL statement above. The one that says "get me all eligible tickets that match these parameters". And it's got to get a lot bigger because I now need to not only join in tblQuotas, to see if any quotas apply to the ticket I've chosen (or to the event, stand, etc that make it up), but I've also got to join in tblBasket, and tblOrders, and tblUsers, to find out how much of any particular quota they've already used up in previous orders. Although that's only orders placed in the current year, mind. And of course I also now haveto pass the users ID in as a parameter so I can look up their order history.
Your head's hurting too, right?
So... this is where I've got to:
SELECT SUM(ticket_quantity) FROM [tblBasket] INNER JOIN [tblTickets] ON [tblBasket].[ticket_id] = [tblTickets].[id] INNER JOIN [tblOrders] ON [tblBasket].[order_id] = [tblOrders].[id] WHERE [tblTickets].[stand_id] = @standId AND [tblOrders].[user_id] = @userId AND ([tblOrders].[order_date] BETWEEN '2006/01/01' AND '2006/12/31')
What I want to do is incorporate that into the big SQL query up top, in such a way to make it only return tickets that not only match the ticket parameters but that also aren't linked to stands, admission dates or anything else, that the user has reached their quota on.
Oh, and I'm in a bit of a hurry so do try and get a move on won't you? ;)
But seriously - how do I put those two SQL querys together? Do I need one for each paramater that might have a quota attached, or is there a quicker way? All suggestions and advice, up to and including "get an easier job, dude", received gratefully :)
I'm working on a document management system that will allow the users to tag docs. Would it better in terms of performance and general maintenance to have all the tags comma de-limited in a column of the doc record, or have each tag in a row of an associated table?
If I want to find other events that occur within a specified time frame of one event, what would the logic be?
Please consider the following:
2 tables:
Booking B Events E
Fields: b.bookingid e.reqtime
I want to find all B.Bookingid that have an e.reqtime +/ 15 minutes from eachother.
I currently use the following query to find all b.bookingid with the same e.reqtime...it would be helpful to find other bookings within a 15 minute window of eachother.
Currently use:
SELECT e.reqtime, count(b.bookingid) as 'Trips'
From Booking b JOIN events e ON e.bookingid=b.bookingid and e.activity=0
I've written several survey systems in which the majority of the questionshave the same or similar responses (Yes/No, True/False, scale of 1 - 5,etc).But this latest survey system I'm working on has 8-10 sections, with avariety of question attributes and answer scales. Some items have just adescription and require a Yes/No answer, others have a description and anactive status and require a Yes/No and price answer, some require a comment,etc.Rather than build a separate response table for each survey section, I wasthinking of building one generic response table, and trying to force allsections to fit by adding columns - some of which won't apply to some items.Like this:Survey Category (will apply to all items)Survey Section (will apply to all items)Item Description (will apply to all items)Item YN (will apply to all items)Item Price (will apply to about 10% of the items)Item Points (will apply to about 10% of the items)Item Active YN (will apply to about 10% of the items)Item Fail YN (will apply to about 10% of the items)Item Comment (will apply to about 10% of the items)For instance, in the structure above the field "Item YN" would representmultiple types of answers: is the item in use?, is the item in place?, isthe item given away for free?, is the item on display?, etc. Basically,anywhere a Yes/No answer is used.The advantage is one source table (rather than 8) for storing answers, andit might be easier to query and report on.The disadvantages I see are 1) it's more difficult to understand the meaningof the responses when the answer field is named Item YN, and 2) you have anon-normalized table that's difficult for a 3rd party to understand.If I have the questions and responses in separate tables, I'll use nameslike "ItemComplimentaryYN" and "ItemUsedYN" depending on the question. It'seasier for others to learn the data.I actually don't like the "generic" approach, and probably won't use it, butI figured I'd try to get some input from others who've written surveysystems.Thanks
Got a view with a number of monthly tables joined with union all. The fields' structure is as follows:
  Report_Date   Staff_ID   Staff_Name   ...   Current_Department
In such a case any query to reflect all the columns with an additional column reflecting the said Staff's latest Department?
In other words, ones still working in the organization reflecting in the latest Department field, the Current Department and those already resigned/fired reflecting the last department they worked at with respect to the Report_Date.
I currently have an internal message system, and I want to modify the db design so users can create their own custom folders.
Currently I have just this table in use, with the bolded column, the one I want to add. With this design, I am thinking of defaulting each "folderID" in this table to a value of 0, which will denote the standard inbox folder. I think this is better because I don't think its necessary or beneficial to have each user have their own row in this table just for their standard inbox.
CREATE TABLE [dbo].[tblMessage_folders] ( [folderID] [int] IDENTITY(1,1) NOT NULL, [userID] [int] NOT NULL, [folderName] [varchar](50) NULL, [dateCreated] [smalldatetime] NULL, )
Any differing opinions, or anyone agreeing with me I would love to hear your opinions. I'm just want to be sure this doesnt create any problems I might not be seeing.
I am preparing to design an application that will archive files created by another application. In my SQL database I want to store details about the file and then the file its self. Each file is about 500kb in size and there will be about 20,000 files generated per year.
My preference is to store these files in a blob field. It makes storage, linking to file meta data, backup etc easy for me. I have already solved the technical issues surrounding pulling the file in and out of a blob field.
By my calculations I will need a server with 10GB of disk space for each year of files archived which doesn't seem outlandish for table size.
I do not want to design my application however to find out a year from now that I should have been storing these files in a traditional file system because of (... whatever ...) and just linking them by path in the sql database.
I'm curious what users of this forum believe to be the best practices surrounding this type of database?
Ok, I'm doing a football database for fixtures and stuff. The problem I am having is that in a fixture, there is both a home, and an away team. The tables as a result are something like this:
It's not exactly like that, but you get the point. The question is, can I do a fixture query which results in one record per fixture, showing both teams details. The first in a hometeam field and the second in an away team field.
Fixture contains the details about the fixture like date and fixture id and has it been played
Team contains team info like team id, name, associated graphic
TeamFixture is the table which links the fixture to it's home and away team.
TeamFixture exists to prevent a many to many type relationship.
Make sense? Sorry if this turns out to be really easy, just can't get my head around it at the mo!
I actually work in an organisation and we have to find a solution about the data consistancy in the database. our partners use to send details to the organisation and inserted directly in the database, so we want to create a new database as a buffer database to insert informations from the partners then make an update to the main database. is there a better solution instead of that?
Hello everyone,I have a webcontrol that uses database-structures alot, it uses the system tables in SQL to read column information from tables. To ease the load of the SQL server I have a property that stores this information in a cache and everything works fine.I am doing some research to find if there are anyway to get information from the SQL server that the structure from a table has changed.I want to know if a column or table has changed any values, like datatype, name, properties, etc.Any suggestions out there ?!
I have a system that basically stores a database within a database (I'msure lots have you have done this before in some form or another).At the end of the day, I'm storing the actual data generically in acolumn of type nvarchar(4000), but I want to add support for unlimitedtext. I want to do this in a smart fashion. Right now I am leaningtowards putting 2 nullable Value fields:ValueLong ntext nullableValueShort nvarchar(4000) nullableand dynamically storing the info in one or the other depending on thesize. ASP.NET does this exact very thing in it's Session State model;look at the ASPStateTempSessions table. This table has both aSessionItemShort of type varbinary (7000) and a SessionItemLong of typeImage.My question is, is it better to user varbinary (7000) and Image? I'mthinking maybe I should go down this path, simply because ASP.NET does,but I don't really know why. Does anyone know what would be the benifitof using varbinary and Image datatypes? If it's just to allow saving ofbinary data, then I don't really need that right now (and I don't thinkASP.NET does either). Are there any other reasons?thanks,dave
Hi All,Can u please suggest me some books for relational database design ordatabase modelling(Knowledgeable yet simple) i.e. from which we couldlearn database relationships(one to many,many to oneetc.....),building ER diagrams,proper usage of ER diagrams in ourdatabase(Primary key foreign key relations),designing smallmodules,relating tables and everything that relates about databasedesign....Coz I think database design is the crucial part of databaseand we must know the design part very first before starting up withdatabases.....Thanks and very grateful to all of you....Vikas
While attempting to set up sql replication in MSSQL 2005 one of my user databases is now in the systems database folder. I need to move it back to the user databases folder. Any help would be greatly appreciated.
Hi All, I am designing database where few of the master tables will reside in different database or in case different server. Scenario is Server "A" with Database "A" may host the "Accounts" table. Server "B" with Database "B" may host the "Product" table. I am designing database "Project" which will hosted in Server "A". My application requires this master tables [readonly access] as data inserted in my application refers this tables. Also there are reports to be generated which refer this tables. How do i design my database and sql queries? I am thinking of approach of having equivalent tables created in my database and writing service which keep tables in my database in sync. This will ensure good perfomance during transaction and reports as they will need to refer this table locally as opposed to different database or different server.
Any thoughts on above approach?? or any better/standard way for such scenarios ?
Thanks in Advance. Your inputs will be of great help.
Online US Searchable Map of the 50 US States. Users search criteria is the following: Query records by selecting state, county, then record. Each County table has 10-20 tables. All databases combined = 500MB and TLogs = 100MB.
How would you re-design a relational DB where users could query data by state-county-record. Currenty the DB's are created by the County of each state which creates hundreds of DB's in SQLServer with no realtionship to each US state. What would be the best design to ensure good performance, data integrity and maintenance? Would you create 1 DB with all 50 states, create 4 DB's and divide by region(N,S,E,W), 50 DB's of each state or leave it as is with each county it's on DB? Any suggestions would be appreciated.
I have created a windows library control that accesses a local sql database
I tried the following strings for connecting
Dim connectionString As String = "Data Source=localhostSQLEXPRESS;Initial Catalog=TimeSheet;Trusted_Connection = true"
Dim connectionString As String = "Data Source=localhostSQLEXPRESS;Initial Catalog=TimeSheet;Integrated Security=SSPI"
I am not running the webpage in a virtual directory but in
C:Inetpubwwwrootusercontrol
and I have a simple index.html that tries to read from an sql db but throws
the error
System.Security.SecurityException: Request for the permission of type 'System.Data.SqlClient.SqlClientPermission, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed. at System.Security.CodeAccessSecurityEngine.Check(Object demand, StackCrawlMark& stackMark, Boolean isPermSet) at System.Security.PermissionSet.Demand() at System.Data.Common.DbConnectionOptions.DemandPermission() at System.Data.SqlClient.SqlConnection.PermissionDemand() at System.Data.SqlClient.SqlConnectionFactory.PermissionDemand(DbConnection outerConnection) at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection,
etc etc
The action that failed was: Demand The type of the first permission that failed was: System.Data.SqlClient.SqlClientPermission The Zone of the assembly that failed was: Trusted
I looked into the .net config utility but it says unrestricted and I tried adding it to the trusted internet zones in ie options security
I think that a windows form connecting to a sql database running in a webpage should be simple
Hello, I am designing my first database with 5 tables for a demo project and am not sure if it works. an example below.2 of the many things I want visitors to the site to do is find a company by the industry sector they belong to,..andwhat sort of service or products they can supply. For instance a Employment agency maybe under professional services Table 1 Customer Customer_ID = primary key,,,, Sector_ID = Foreign keyComapany Name, Address, Phone, Postcode etcTabel 2 Industry SectorsSector_ID = primary key,,,,Customer_ID= foreign key banking, Education,Prof Services, etc Table 3 Trading ActivityTrading_ID = primary key,,,,Sector_ID = Foreign key, Products_ID= FkEmployment Agent, School, Lawyer etcTable 4 ProductsProducts_ID = primary key,,,,Trading_ID = foreign keySupply frozen foods, transport services, sports goods, etc Table 5 Account Account_ID = primary key,,,,Customer_ID = foreign keyAccount Name, Credit Limit, Payment Terms, Open date, Account contact etc One big point of confusion is, can I have the Customer_ID from the principal Customers tablein every table as a foreign key or must the tables be chained together one after the other as such. Advice appreciatedThanks
Hi, I need a hand with designing a database. I am collecting results from a survey which has the following questions: Call ref? How did you place your support call? Were you satisfied with the amount of time you had to wait until getting acknowledgement of the support call placed? 1 = very satisfied and 10 = very unsatisfied. How happy were you with the customer service you received upon placing the support call? 1 = very unhappy and 10 = very happy.How satisfied were you with the amount of time you had to wait until you heard from an engineer? 1 = very satisfied and 10 = very unsatisfied. How satisfied were you with the time taken to get your problem/query resolved? 1 = very satisfied and 10 = very unsatisfied Did you feel the engineer had enough knowledge to deal with your call? 1 = very good and 10 = not very good Overall how satisfied were you with the support call placed? 1 = very satisfied and 10 = very unsatisfiedIs there anything we can do to improve the quality of the support and service you received? I want to store this in a database. Obviously I want to use best practice for design, normalisation etc. The stumbling block I am coming accross is the fact that each question has a number and each question has a score from 1 to 10 and storing this in the database. Any help appreciated! Thanks Andrew
I am creating database tables for company testimonials. Database columns: name, position, companyname, comment, service we provided. My question is that for each company - may have a multitude of different services from us, and different people with different positions in the same company may make comments. What is best practice for putting this db structure together? Thanks Andrew
Can anyone tell me how can i design database architecture for the Table Category & Product...so that i can make N-level entity relation....I have database in SQL SERVER 2000.
I guess I am confused about something and need some help. I am looking at a database schema for about 20 tables in a database. I noticed that the firstcolumn in each table Is some type of Id. For example StudentId,TestId etc.Where the Id is a unique numeric sequential value. So I have some questions?1- Do these Id's act as what are called indexes for the table?(Unique indexes)2- If the answer to 1 is correct, then how do I create these unique indexes? Is it as simple as declaring the Id column as the primary key and that this value will be generated automatically upon insert? 3- Is it necessary to have an Id column for every table, or may I only do it for a few of them?4. In relation to Question2, what do I need to do, so that the Id column will automatically be created when someone inserts a value into the database table with an ID column. For example here are two sample tables StudentsInfo StudentId<PK> Name Age 1 Mark 33 2 Jill 23 3 Mary 25 PersonalInfo Name<FK> SocialSecurity Address MajorMark 324-444-3342 15 Elm ArtJill 888-888-8998 21 North ScienceMary 876-777-2344 18 Byle Music
Hi,I am planning to create a technical forum for our college. could any one give me an idea of how to design the database for the forum. what table and columns i should have?
I have got a design issue.I have got 4 tables,having relationships.Now,user will edit records and save them,but I want to save the values which were exixsting before they were edited and saved.Implying,if a record is edited 50 times,then the values of each edit needs to be saved.How best ,can I achieve this.
Hi !!We are designing a system where we ask people for their interests and store in into the database and send customize email. Following are the questions:1) Should we use Identity column as Primary Key and CustomerID column? OR we should create Custom CustomerID and use it as Primary Key? (I have read few articles about Identity column as Primary or not Primary, but need little advice what to accept)2) We have a Tables called : Interest & Customer_InterestCustomer Table:CustomerID, Customer Name, Address, Email, Signup DateInterest Table:InterestID, InterestNameCustomer_Interest: (Need suggestion for How to design this)Should Table be design like:Option1: CustomerID, InterestIDOption2: CustomerID, Interest1, Interest2, Interest3, Interest4i.e.Lets Say: Customer table has CustomerA, CustomerB, CustomerCInterest table has Interest I1, I2, I3, I4Lets Say CustomerA Signedup for Interest I1, I2, I3 and CustomerB signed up I1, I4As per Option1:Customer_Interest Table witll haveCustomerA, I1CustomerA, I2CustomerA, I3CustomerB, I1CustomerB, I4ORAs per Option2Customer_Interest (Where Interest Column is bit column..... 1 = Signed up, 0 = Not Signed upCustomerA, 1, 1, 1, 0CustomerB, 1, 0, 0, 1Which way we should design? 3) If we select Option2, and if we are displaying data in ASP.NET Page, will there be any issue if we use 3 tier architecture?Thanks !!!
I am designing an inventory database in which I need some help, I have the following entities:ItemsNotebookWireless CardADSL Modemetc...ModelsAcer centrino 1.6Acer centrino 1.733COM 4x125 hours Wi-fi access50 hours Wi-fi accessetc... PackagesPackage A:Acer centrino 1.63COM 4x125 hours Wi-fi accessPackage B:Acer centrino 1.733COM 4x150 hours Wi-fi accessI made a table for the items having the following fields: Item_ID, Item_Nameand another for the Models having: Model_ID, Model_Name, Item_Type(Foreign Key to Items table)up to this point is this correct?About the packages table, I don't know if it is correct to have a field for each model (one for notebook, other for modem, and other for wireless card) like this it would be like having 3 foreign keys to the same table but nothing distinguishes themI don't know how to relate the packages and the models table.Any recommendations for a proper design for those entities?
I am creating a knowledge base. I want the user to be able to choose a category such as Hardware, Software, Etc. then I want them to be able to choose what type of software such as word, excel, ets. It will then display in a gridview problems, solutions, submitted by, last updated, and review date. The gridview will allow users to update solutions and I would also like the ability for technicians to be able to add new Problems/solutions.
I have requirement to create table of 100 columns. Should i create 100 columns in one table or i should create three coulmn table with column id, column desc, column value with 1 row in 100 column table = 100 row in 3 column table. Which will be faster & efficient in performance, io & size.
The database will provide content management for an Intranet site.
On the site we have a number of articles which are categorised. Each categories can also have sub-categories.
The relationships would seem to be
Category---->Sub-Category----->Article
A category has one or mant sub-categories. A sub-category has one or many articles.
However some categories have articles but are no sub-categories.
Should I create a further relationship between Category and Article to cater for this instance or should their be a dummy category record in this instance?